Solarus 1.6 Tutorial [en] - #50: Metatables
How to program a global behavior of all objects of the same type without duplicating the code? Metatables, a very powerful Lua feature, are an elegant answer to that problem.
The metatable of a type specifies the shared behavior of all objects of this type. When you assign a function to the metatable of a type, everything is like if all objects of that type had this function.
You can for instance define a default event on the sensor type instead of having to search for every sensor instance.
- Video made with Solarus 1.6.
- Download Solarus : https://www.solarus-games.org/en/solarus/download
- Solarus documentation : http://www.solarus-games.org/doc/latest/
- How to program in Lua: http://www.lua.org/pil/contents.html
- Solarus Discord: https://discord.gg/yYHjJHt