![]() ![]() Let's say you want to draw something in the lua client due to some user interaction with the UI (for example, the user has clicked that they want to place a new item into the world). Here are some examples of communication between client and server using call handlers: Example 1: Client renderer through user interaction Some things, like effects, cannot be created on the client at all. In some ways, you can think of the Lua client renderer as the realm of all the things that the player can see and interact with to play the game, but that do not actually exist within the simulation of the world.Īs a general rule, you can assume that the Lua client has all the same data as the server, but is read-only: new components cannot be created and data cannot be saved to existing data structures. ![]() The ghost item that exists between when the user puts down the object and when a worker actually instantiates the object also exists only on the Lua client as a result, the people in the world cannot see it and cannot interact with it. Lua is run in 2 places - on the Lua server, where the bulk of the game is processed and run, and in a smaller Lua client, which handles rendering entities to the screen in user-interactable ways.įor example, when the user selects an object to put in the world, the temporary item that is attached to the user's mouse is rendered in the Lua client, and the click to put it down in the world is caught by that client before the data itself (where the object will be put down, at what rotation, etc.) is sent to the server for processing. For examples, see the farming or the unit control services. Sometimes, though, operations in the game belong to no single hearthling or object, and these are managed by services like farming or town.Ī call handler helps the UI call a function on one of these high-level services, triggering a sequence of actions. Most operations in the game are done through the hearthling AI or by manipulating values on an object, which results in a cascade of actions that result in changes to the game state.
0 Comments
Leave a Reply. |