ULX

Author Topic: Coming in ULib v2: Self propagating tables!  (Read 4607 times)

0 Members and 1 Guest are viewing this topic.

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Coming in ULib v2: Self propagating tables!
« on: December 13, 2006, 11:17:44 AM »
In the new ULib, we'll have a cool little feature I've termed self propagating tables. It will let you share information between server and clients without lots of nasty concommands or SendLua's. Basically, you put whatever information you want to share in an appropriate table, and it will automatically send it to the server or clients for you!

Our initial version will only be for sharing from server to clients, but we'll expand upon that in future versions. Here's actual output from console:
Code: [Select]
] lua_run ULib.global.server.bob = "hi there buddy"
> ULib.global.server.bob = "hi there buddy"...
] lua_run_cl "print( ULib.global.server.bob )"
> print( ULib.global.server.bob )...
hi there buddy
] lua_run ULib.global.server.t = { joe=false, pos=Vector( 10, 780.1, 0 ) }
> ULib.global.server.t = { joe=false, pos=Vector( 10, 780.1, 0 ) }...
] lua_run_cl "print( ULib.global.server.t )"
> print( ULib.global.server.t )...
table: 0276C1C0
] lua_run_cl "print( ULib.global.server.t.joe )"
> print( ULib.global.server.t.joe )...
false
] lua_run_cl "print( ULib.global.server.t.pos )"
> print( ULib.global.server.t.pos )...
10.0000 780.1000 0.0000

The information from the table set on the server is instantly available to clients.

Client-side, this table is read-only...
Code: [Select]
] lua_run_cl "ULib.global.server.noes = 'testing'"
> ULib.global.server.noes = 'testing'...
[LC ULIB ERROR] Attempt to modify read-only table!
] lua_run_cl "print( ULib.global.server.noes )"
> print( ULib.global.server.noes )...
nil

Downsides:
* Obviously, you don't want to store a million strings here as it would have consequences on memory and network performance.
* Strings are limited to ~200 characters due to the way we have to send it.
* Only supports Angles, Vectors, Colors (since they're tables), strings, booleans, tables, and numbers
« Last Edit: December 13, 2006, 01:01:54 PM by Megiddo »
Experiencing God's grace one day at a time.

Offline Golden-Death

  • Hero Member
  • *****
  • Posts: 751
  • Karma: 0
  • Honored Lua Scripter
    • BlueFire
Re: Coming in ULib v2: Self propagating tables!
« Reply #1 on: December 13, 2006, 05:53:34 PM »
Nifty