aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2012-03-31 13:50:25 +0300
committerPerttu Ahola <celeron55@gmail.com>2012-03-31 13:50:25 +0300
commitdc70f50b5901732f928c439060dcbbcc6a5dfeb7 (patch)
treef1f69273b321476124023832b70ef9bd15b3d5ee
parente297c739139ad0116ebdcda7a8dc5884d89f5a96 (diff)
downloadminetest-dc70f50b5901732f928c439060dcbbcc6a5dfeb7.tar.gz
minetest-dc70f50b5901732f928c439060dcbbcc6a5dfeb7.tar.bz2
minetest-dc70f50b5901732f928c439060dcbbcc6a5dfeb7.zip
initial_properties field in entity definition
-rw-r--r--doc/lua_api.txt7
-rw-r--r--games/minimal/mods/experimental/init.lua21
-rw-r--r--src/scriptapi.cpp7
3 files changed, 22 insertions, 13 deletions
diff --git a/doc/lua_api.txt b/doc/lua_api.txt
index db8ae25b1..b068a8a01 100644
--- a/doc/lua_api.txt
+++ b/doc/lua_api.txt
@@ -792,8 +792,10 @@ Object Properties
Entity definition (register_entity)
{
- Everything from object properties,
- -- entity specific --
+ (Deprecated: Everything in object properties is read directly from here)
+
+ initial_properties = <initial object properties>,
+
on_activate = function(self, staticdata),
on_step = function(self, dtime),
on_punch = function(self, hitter),
@@ -801,6 +803,7 @@ Entity definition (register_entity)
get_staticdata = function(self),
^ Called sometimes; the string returned is passed to on_activate when
the entity is re-activated from static state
+
# Also you can define arbitrary member variables here
myvariable = whatever,
}
diff --git a/games/minimal/mods/experimental/init.lua b/games/minimal/mods/experimental/init.lua
index 55ea64132..11f32b3f9 100644
--- a/games/minimal/mods/experimental/init.lua
+++ b/games/minimal/mods/experimental/init.lua
@@ -409,16 +409,17 @@ minetest.register_alias("TNT", "experimental:tnt")
--
minetest.register_entity("experimental:dummyball", {
- -- Static definition
- hp_max = 20,
- physical = false,
- collisionbox = {-0.4,-0.4,-0.4, 0.4,0.4,0.4},
- visual = "sprite",
- visual_size = {x=1, y=1},
- textures = {"experimental_dummyball.png"},
- spritediv = {x=1, y=3},
- initial_sprite_basepos = {x=0, y=0},
- -- Dynamic variables
+ initial_properties = {
+ hp_max = 20,
+ physical = false,
+ collisionbox = {-0.4,-0.4,-0.4, 0.4,0.4,0.4},
+ visual = "sprite",
+ visual_size = {x=1, y=1},
+ textures = {"experimental_dummyball.png"},
+ spritediv = {x=1, y=3},
+ initial_sprite_basepos = {x=0, y=0},
+ },
+
phase = 0,
phasetimer = 0,
diff --git a/src/scriptapi.cpp b/src/scriptapi.cpp
index 4ca114a0c..a9f54627d 100644
--- a/src/scriptapi.cpp
+++ b/src/scriptapi.cpp
@@ -4887,8 +4887,13 @@ void scriptapi_luaentity_get_properties(lua_State *L, u16 id,
// Set default values that differ from ObjectProperties defaults
prop->hp_max = 10;
- // Read stuff
+ // Deprecated: read object properties directly
read_object_properties(L, -1, prop);
+
+ // Read initial_properties
+ lua_getfield(L, -1, "initial_properties");
+ read_object_properties(L, -1, prop);
+ lua_pop(L, 1);
}
void scriptapi_luaentity_step(lua_State *L, u16 id, float dtime)