|Clemens Klug (agp8x)||18.03.2016 23:16|
I have some questions about scripting for multiplayer:
1. I assume read/writeUpdateStream is for the synchronization phase, and read/writeStream for ingame?
2. What expects g_server:broadcastEvent as arguments (event, ?, connection, ?)? The script doku can't decide between 'self' and an object, altough I think the reference for an object is the right one (http://www.ls-mods.de/scriptDocumentation.php?lua_file=vehicles/specializations/SowingMachineSetSeedIndex )
3. What is the difference between Event:run() and Event:runLocally)?
|Emil Drefers (Unknown)||21.03.2016 08:00|
1. It's the other way round ;)
read/writeUpdateStream is for sync'ing data in every 'update' (update freq. is here like updateTick(), so not every frame, but every 45ms or so)
read/writeUpdate are used to sync the initial data, when a client joins
2. The first argument in broadcastEvent() is always an event.
broadcastEvent(Event:new()) seems to be the cleaner attempt
3. Generally speaking: run() is used on both sides (client and server), whereas runLocally() is used on the server side only
Note: Always think about wether or not you need an event or not.
Events are guaranteed to be transmitted, but they cost extra network bandwidth because of that.
Using the readWriteUpdate functions should therefore be prefered, if possible.
Note: Log in to post. Create a new account here.