The latest version of the ScriptENGINE 2010: 3D Engine is now available.
Download it now! No obligations or time limitations. Purchase a license at any time to activate the full version.

Data Bags

ScriptENGINE: Lua 3D Engine Article SeriesIn this article, we will look at ScriptENGINE data bags.

Data bags are used to tag data to an entity/world/scenario. Especially useful for things like entity attributes, inventories etc. All entities can store data in their data bags. The recognised data types are strings, numbers and booleans. The data bags are serialised with the entity/world data.

 

View the Demo Code

The demos are included in the ScriptENGINE SDK. Now's a great time to get the ScriptENGINE SDK from our website (including the SciTE code editor, Programmer's Reference and ScriptENGINE Demos).

Navigate to the ScriptENGINE SDK/[Data bags] Tag data to your worlds and entities folder for the example.

Open the world.e76script in the SciTE code editor. We will be referring to the world.e76script for the rest of this article.

 

The ScriptENGINE Demo Framework

The ScriptENGINE Demos are run using the runDemo.e76script framework code in the ScriptENGINE SDK/Demos folder.

 

Initialisation Code

The IWorld:getEntityDataxxx() functions are used to read data from the entity's databag. The data was originally set using the ScriptENGINE SDK World Editor, but can also be set using the IGraphics:setEntityDataxxx() functions.

These data bag values are then used to set graphical/physical properties on 3D entity.