diff options
author | Weblate <42@minetest.ru> | 2013-06-01 13:18:52 +0200 |
---|---|---|
committer | Weblate <42@minetest.ru> | 2013-06-01 13:18:52 +0200 |
commit | 1dfc2e02b3c358af4bb20bb3cb60ac7bd3ed1124 (patch) | |
tree | 54660f353f3342f89b6259ea6a5dfedfa20dc16f /src/content_sao.cpp | |
parent | ec039a3d123120f9918812b13f5971e94546b9af (diff) | |
parent | 64627817fcca52f20948c24b60ce192b218f6ce2 (diff) | |
download | minetest-1dfc2e02b3c358af4bb20bb3cb60ac7bd3ed1124.tar.gz minetest-1dfc2e02b3c358af4bb20bb3cb60ac7bd3ed1124.tar.bz2 minetest-1dfc2e02b3c358af4bb20bb3cb60ac7bd3ed1124.zip |
Merge remote-tracking branch 'origin/master'
Diffstat (limited to 'src/content_sao.cpp')
-rw-r--r-- | src/content_sao.cpp | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/src/content_sao.cpp b/src/content_sao.cpp index 24a9186f7..cc02a7431 100644 --- a/src/content_sao.cpp +++ b/src/content_sao.cpp @@ -27,7 +27,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "tool.h" // For ToolCapabilities #include "gamedef.h" #include "player.h" -#include "scriptapi.h" +#include "cpp_api/scriptapi.h" #include "genericobject.h" #include "util/serialize.h" @@ -387,8 +387,7 @@ LuaEntitySAO::LuaEntitySAO(ServerEnvironment *env, v3f pos, LuaEntitySAO::~LuaEntitySAO() { if(m_registered){ - lua_State *L = m_env->getLua(); - scriptapi_luaentity_rm(L, m_id); + ENV_TO_SA(m_env)->luaentity_Remove(m_id); } } @@ -397,16 +396,15 @@ void LuaEntitySAO::addedToEnvironment(u32 dtime_s) ServerActiveObject::addedToEnvironment(dtime_s); // Create entity from name - lua_State *L = m_env->getLua(); - m_registered = scriptapi_luaentity_add(L, m_id, m_init_name.c_str()); + m_registered = ENV_TO_SA(m_env)->luaentity_Add(m_id, m_init_name.c_str()); if(m_registered){ // Get properties - scriptapi_luaentity_get_properties(L, m_id, &m_prop); + ENV_TO_SA(m_env)->luaentity_GetProperties(m_id, &m_prop); // Initialize HP from properties m_hp = m_prop.hp_max; // Activate entity, supplying serialized state - scriptapi_luaentity_activate(L, m_id, m_init_state.c_str(), dtime_s); + ENV_TO_SA(m_env)->luaentity_Activate(m_id, m_init_state.c_str(), dtime_s); } } @@ -515,8 +513,7 @@ void LuaEntitySAO::step(float dtime, bool send_recommended) } if(m_registered){ - lua_State *L = m_env->getLua(); - scriptapi_luaentity_step(L, m_id, dtime); + ENV_TO_SA(m_env)->luaentity_Step(m_id, dtime); } if(send_recommended == false) @@ -626,8 +623,7 @@ std::string LuaEntitySAO::getStaticData() os<<serializeString(m_init_name); // state if(m_registered){ - lua_State *L = m_env->getLua(); - std::string state = scriptapi_luaentity_get_staticdata(L, m_id); + std::string state = ENV_TO_SA(m_env)->luaentity_GetStaticdata(m_id); os<<serializeLongString(state); } else { os<<serializeLongString(m_init_state); @@ -673,8 +669,14 @@ int LuaEntitySAO::punch(v3f dir, { setHP(getHP() - result.damage); + + std::string punchername = "nil"; + + if ( puncher != 0 ) + punchername = puncher->getDescription(); + actionstream<<getDescription()<<" punched by " - <<puncher->getDescription()<<", damage "<<result.damage + <<punchername<<", damage "<<result.damage <<" hp, health now "<<getHP()<<" hp"<<std::endl; { @@ -688,8 +690,7 @@ int LuaEntitySAO::punch(v3f dir, m_removed = true; } - lua_State *L = m_env->getLua(); - scriptapi_luaentity_punch(L, m_id, puncher, + ENV_TO_SA(m_env)->luaentity_Punch(m_id, puncher, time_from_last_punch, toolcap, dir); return result.wear; @@ -702,8 +703,7 @@ void LuaEntitySAO::rightClick(ServerActiveObject *clicker) // It's best that attachments cannot be clicked if(isAttached()) return; - lua_State *L = m_env->getLua(); - scriptapi_luaentity_rightclick(L, m_id, clicker); + ENV_TO_SA(m_env)->luaentity_Rightclick(m_id, clicker); } void LuaEntitySAO::setPos(v3f pos) @@ -1307,8 +1307,13 @@ int PlayerSAO::punch(v3f dir, HitParams hitparams = getHitParams(m_armor_groups, toolcap, time_from_last_punch); + std::string punchername = "nil"; + + if ( puncher != 0 ) + punchername = puncher->getDescription(); + actionstream<<"Player "<<m_player->getName()<<" punched by " - <<puncher->getDescription()<<", damage "<<hitparams.hp + <<punchername<<", damage "<<hitparams.hp <<" HP"<<std::endl; setHP(getHP() - hitparams.hp); |