1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Add static_save property to luaentites to not save them statically. (#5112)

* Add no_static_save property to luaentites to not save them statically.
This allows for temporary objects that would get deleted anyway as soon as they are loaded again without the static saving overhead.

* Use positive meaning for static_save object property

* Invert meaning also for the LUA parameter
Note: getboolfield() does not change &result when field does not exist, so it defaults to the default value in the header file, which is 'true'.

* Extend push_object_properties()
This commit is contained in:
orwell96 2017-09-28 17:11:51 +02:00 committed by Loïc Blot
parent 2afe62952c
commit 08846cd05c
5 changed files with 13 additions and 0 deletions

View file

@ -105,6 +105,8 @@ public:
const std::string &data);
void step(float dtime, bool send_recommended);
std::string getClientInitializationData(u16 protocol_version);
bool isStaticAllowed() const
{ return m_prop.static_save; }
void getStaticData(std::string *result) const;
int punch(v3f dir,
const ToolCapabilities *toolcap=NULL,

View file

@ -66,6 +66,7 @@ std::string ObjectProperties::dump()
os << ", selectionbox=" << PP(selectionbox.MinEdge) << "," << PP(selectionbox.MaxEdge);
os << ", pointable=" << pointable;
os << ", can_zoom=" << can_zoom;
os << ", static_save=" << static_save;
return os.str();
}

View file

@ -58,6 +58,7 @@ struct ObjectProperties
std::string infotext;
//! For dropped items, this contains item information.
std::string wield_item;
bool static_save = true;
ObjectProperties();
std::string dump();

View file

@ -294,7 +294,10 @@ void read_object_properties(lua_State *L, int index,
prop->automatic_face_movement_max_rotation_per_sec = luaL_checknumber(L, -1);
}
lua_pop(L, 1);
getstringfield(L, -1, "infotext", prop->infotext);
getboolfield(L, -1, "static_save", prop->static_save);
lua_getfield(L, -1, "wield_item");
if (!lua_isnil(L, -1))
prop->wield_item = read_item(L, -1, idef).getItemString();
@ -376,6 +379,8 @@ void push_object_properties(lua_State *L, ObjectProperties *prop)
lua_setfield(L, -2, "automatic_face_movement_max_rotation_per_sec");
lua_pushlstring(L, prop->infotext.c_str(), prop->infotext.size());
lua_setfield(L, -2, "infotext");
lua_pushboolean(L, prop->static_save);
lua_setfield(L, -2, "static_save");
lua_pushlstring(L, prop->wield_item.c_str(), prop->wield_item.size());
lua_setfield(L, -2, "wield_item");
}