All entities in nanos.world are represented by a Class. In Lua, classes are represented by tables. That means that every interaction with entities (Players, Characters, Props, etc) are made with Classes/Tables functions following an OOP (Object-oriented programming pattern). In this page we will explain more about that.
If you read our Getting Started Scripting guide, you noticed we were spawning entities in the format
my_var = Entity() (with a constructor), and after that we could interact with our entity with
my_var:my_function(), this is how OOP works, you create objects and call functions/catch events on that object. Unlike other scripting games which have tons of global functions and events to interact with entities, our nanos.world scripting is a modern approach to modern programming.
As already stated, spawning Entities is easy as:
Each Class have it’s own Constructor, Properties, Functions and Events. At the bottom of this page you’ll be able to see a list of Classes which can be spawned in nanos.world.
Under the hood, our Classes follow an Inheritance Pattern, which means we have a master parent class, and it’s childs which inherits all functions, events and properties from it’s parents. You will notice that all Classes that can be spawned in the world are
Actors, because of that some Classes like Character and Prop will contain functions and events sections saying “Inherited from Actor”, which means all these functions and events are the same in all Actor’s inherited Classes, for example on all Actors it is possible to call the function: