From: Perttu Ahola Date: Sat, 12 Nov 2011 15:46:06 +0000 (+0200) Subject: Scripting WIP: Add global environment step function on_step X-Git-Url: http://81.2.79.47:8989/gitweb/?a=commitdiff_plain;h=73bb3bc5958989db21eefb826e277dada248ceca;p=zefram%2Fminetest%2Fminetest_engine.git Scripting WIP: Add global environment step function on_step --- diff --git a/data/scripts/default.lua b/data/scripts/default.lua index dcc58097..4197cd78 100644 --- a/data/scripts/default.lua +++ b/data/scripts/default.lua @@ -138,7 +138,10 @@ end print("omg lol") print("minetest dump: "..dump(minetest)) ---local TNT = minetest.new_entity { +-- Global environment step function +function on_step(dtime) +end + local TNT = { -- Maybe handle gravity and collision this way? dunno physical = true, diff --git a/src/environment.cpp b/src/environment.cpp index d3e8fa12..29432bc5 100644 --- a/src/environment.cpp +++ b/src/environment.cpp @@ -1141,6 +1141,11 @@ void ServerEnvironment::step(float dtime) } } + /* + Step script environment (run global on_step()) + */ + scriptapi_environment_step(m_lua, dtime); + /* Step active objects */ diff --git a/src/scriptapi.cpp b/src/scriptapi.cpp index 530c1719..38166448 100644 --- a/src/scriptapi.cpp +++ b/src/scriptapi.cpp @@ -40,7 +40,9 @@ extern "C" { TODO: - Global environment step function - Random node triggers -- Object network and client-side stuff +- Object visual client-side stuff + - Blink effect + - Spritesheets and animation - Named node types and dynamic id allocation - LuaNodeMetadata blockdef.has_metadata = true/false @@ -669,6 +671,25 @@ void scriptapi_rm_object_reference(lua_State *L, ServerActiveObject *cobj) lua_settable(L, objectstable); } +/* + environment +*/ + +void scriptapi_environment_step(lua_State *L, float dtime) +{ + realitycheck(L); + assert(lua_checkstack(L, 20)); + //infostream<<"scriptapi_luaentity_step: id="<