diff options
author | Rui <rui.minetest@gmail.com> | 2017-01-10 04:39:45 +0900 |
---|---|---|
committer | Ner'zhul <nerzhul@users.noreply.github.com> | 2017-01-09 20:39:45 +0100 |
commit | ec30d49e026af2d0cb8329eb66aec48d12e79839 (patch) | |
tree | 65a96127eb50412dfbd6f5d120809a58ff510ec7 | |
parent | 8e7449e09253e138716d8dbad6a2ab5c6e089e28 (diff) | |
download | minetest-ec30d49e026af2d0cb8329eb66aec48d12e79839.tar.gz minetest-ec30d49e026af2d0cb8329eb66aec48d12e79839.tar.bz2 minetest-ec30d49e026af2d0cb8329eb66aec48d12e79839.zip |
Add staticdata parameter to add_entity (#5009)
* Add staticdata parameter to add_entity
* Add add_entity_with_staticdata to core.features
-rw-r--r-- | builtin/game/features.lua | 1 | ||||
-rw-r--r-- | doc/lua_api.txt | 2 | ||||
-rw-r--r-- | src/script/lua_api/l_env.cpp | 6 |
3 files changed, 6 insertions, 3 deletions
diff --git a/builtin/game/features.lua b/builtin/game/features.lua index 2aad458da..646b254ea 100644 --- a/builtin/game/features.lua +++ b/builtin/game/features.lua @@ -9,6 +9,7 @@ core.features = { no_legacy_abms = true, texture_names_parens = true, area_store_custom_ids = true, + add_entity_with_staticdata = true, } function core.has_feature(arg) diff --git a/doc/lua_api.txt b/doc/lua_api.txt index d05db9d49..fc0f8e1fc 100644 --- a/doc/lua_api.txt +++ b/doc/lua_api.txt @@ -2173,7 +2173,7 @@ and `minetest.auth_reload` call the authetification handler. * `minetest.get_node_timer(pos)` * Get `NodeTimerRef` -* `minetest.add_entity(pos, name)`: Spawn Lua-defined entity at position +* `minetest.add_entity(pos, name, [staticdata])`: Spawn Lua-defined entity at position * Returns `ObjectRef`, or `nil` if failed * `minetest.add_item(pos, item)`: Spawn item * Returns `ObjectRef`, or `nil` if failed diff --git a/src/script/lua_api/l_env.cpp b/src/script/lua_api/l_env.cpp index 68d10308c..3d9db7917 100644 --- a/src/script/lua_api/l_env.cpp +++ b/src/script/lua_api/l_env.cpp @@ -440,7 +440,7 @@ int ModApiEnvMod::l_get_node_timer(lua_State *L) return 1; } -// add_entity(pos, entityname) -> ObjectRef or nil +// add_entity(pos, entityname, [staticdata]) -> ObjectRef or nil // pos = {x=num, y=num, z=num} int ModApiEnvMod::l_add_entity(lua_State *L) { @@ -450,8 +450,10 @@ int ModApiEnvMod::l_add_entity(lua_State *L) v3f pos = checkFloatPos(L, 1); // content const char *name = luaL_checkstring(L, 2); + // staticdata + const char *staticdata = luaL_optstring(L, 3, ""); // Do it - ServerActiveObject *obj = new LuaEntitySAO(env, pos, name, ""); + ServerActiveObject *obj = new LuaEntitySAO(env, pos, name, staticdata); int objectid = env->addActiveObject(obj); // If failed to add, return nothing (reads as nil) if(objectid == 0) |