aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/lua_api.txt4
-rw-r--r--src/content_sao.h2
-rw-r--r--src/object_properties.cpp1
-rw-r--r--src/object_properties.h1
-rw-r--r--src/script/common/c_content.cpp5
5 files changed, 13 insertions, 0 deletions
diff --git a/doc/lua_api.txt b/doc/lua_api.txt
index 812b857f7..cd93ffc16 100644
--- a/doc/lua_api.txt
+++ b/doc/lua_api.txt
@@ -4199,6 +4199,10 @@ Definition tables
nametag = "", -- by default empty, for players their name is shown if empty
nametag_color = <color>, -- sets color of nametag as ColorSpec
infotext = "", -- by default empty, text to be shown when pointed at object
+ static_save = true,
+ -- ^ If false, never save this object statically. It will simply be deleted when the block gets unloaded.
+ -- ^ The get_staticdata() callback is never called then.
+ -- ^ Defaults to 'true'
}
### Entity definition (`register_entity`)
diff --git a/src/content_sao.h b/src/content_sao.h
index b62551f51..683a2fb5f 100644
--- a/src/content_sao.h
+++ b/src/content_sao.h
@@ -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,
diff --git a/src/object_properties.cpp b/src/object_properties.cpp
index 9cbaadc64..ae0305019 100644
--- a/src/object_properties.cpp
+++ b/src/object_properties.cpp
@@ -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();
}
diff --git a/src/object_properties.h b/src/object_properties.h
index 7589cec3c..fcf03383c 100644
--- a/src/object_properties.h
+++ b/src/object_properties.h
@@ -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();
diff --git a/src/script/common/c_content.cpp b/src/script/common/c_content.cpp
index 557430471..8f08de1e5 100644
--- a/src/script/common/c_content.cpp
+++ b/src/script/common/c_content.cpp
@@ -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");
}