Engine/Objects

From Minetest Developer Wiki
< Engine
Revision as of 22:56, 23 December 2019 by Wuzzy (talk | contribs) (Add UnofficialLua warning)
Jump to navigation Jump to search
Mbox warning.png This page contains unofficial, low-quality Lua API documentation and is likely to be outdated or wrong. Do not rely on it!
For the official and up-to-date documentation, see Lua API Documentation.
Mbox warning.png This page has been proposed for deletion for the following reason: "Contains unofficial and potentially outdated, redundant and inconsistent Lua API information"
If you don't think that this page should be deleted, please explain why on the talk page.

ActiveObjects aka objects are objects in the environment, consisting of roughly everything that is not part of the voxel world (=Map)

SAO = ServerActiveObject CAO = ClientActiveObject

serverobject.{h,cpp} clientobject.{h,cpp} content_sao.{h,cpp} content_cao.{h,cpp}

All objects have a server- and a client-side counterpart. The server-side object types that currently exist are

  • TestSAO (a small test thing)
  • ItemSAO (old item; not used)
  • LuaEntitySAO (all entities defined in Lua; basically everything other than the players), and
  • PlayerSAO (the player objects which enable standard object interaction for players. Players also have a ServerRemotePlayer or something like that which handles the things in which players are different to other objects).

Client-side objects:

  • TestCAO (obvious)
  • ItemCAO (obvious)
  • GenericCAO (everything else; LuaEntitySAOs and PlayerSAOs register as this on the client-side. This enables them to have the exact same capabilities in terms of looks, client-side interaction and stuff.)

If eg. implementing meshes to go through the regular Lua->server->client pipeline, one'll want to implement them in GenericCAO, through ObjectProperties. ObjectProperties should contain the filename of the mesh (which should be transferred like images), and possibly some small additional information.

All the players on the server have an associated PlayerSAO object, of which generally all will appear on clients as GenericCAO client-side objects.

The CAO of each player also exists on the player's clients itself, just like the other players. It is always hidden and is used for nothing. It doesn't cause any considerable overhead and filtering it out server-side would make the systems messier. On a client, the local player is a separate thing (a LocalPlayer, added to the environment in Client::Client(); it is similar to the ServerRemotePlayers mentioned earlier).