A complete introduction to scripting for games using the versatile Lua programming language and the Core game development platform. Add an array of game coding skills to your toolbox and take your game development to new heights!
The multiplayer experience in Core is achieved by sharing information back and forth between a server, and the computers of each connected player. Because that process takes time, Core has different contexts that you can use to specify code that should run just on the server, or just on individual computers, clients.
Many functions in the Core API will only work on a script in a Client or Server Context.
When a Core game starts, a version of it begins on a server. Each player that connects creates a local version of the game, with the default and client information copied to it. To create a multiplayer experience, players need information about their actions passed through the server to the other players, to be copied into their local versions of the game.
To make it easy to manage contexts inside of the Core Editor, contexts are treated like folders. Any object or script that is inside of these context folders will have that context.
Contexts are created in the Hierarchy window.
Alternatively, you can select a group of objects to be moved to a context, and choose New Server Context Containing These or New Server Context Containing These.
All Core content starts out in this context unless they are moved into a new one. Objects in the default context can have collision, and are visible to both the server and the client.
The client context can be different on each player’s individual instance of the game. It is efficient to put as much as possible in this context, because it requires no confirmation from the server, and is runs locally.
Objects in a client context cannot have collision.
The server context is used for scripts that don’t need access to the client side. Scripts in other contexts also run on the server, but in the server context they cannot be accessed by the client.