summaryrefslogtreecommitdiff
path: root/src/script/common/c_content.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/script/common/c_content.cpp')
-rw-r--r--src/script/common/c_content.cpp86
1 files changed, 56 insertions, 30 deletions
diff --git a/src/script/common/c_content.cpp b/src/script/common/c_content.cpp
index 3dfd7ce61..6995f6b61 100644
--- a/src/script/common/c_content.cpp
+++ b/src/script/common/c_content.cpp
@@ -56,6 +56,7 @@ void read_item_definition(lua_State* L, int index,
es_ItemType, ITEM_NONE);
getstringfield(L, index, "name", def.name);
getstringfield(L, index, "description", def.description);
+ getstringfield(L, index, "short_description", def.short_description);
getstringfield(L, index, "inventory_image", def.inventory_image);
getstringfield(L, index, "inventory_overlay", def.inventory_overlay);
getstringfield(L, index, "wield_image", def.wield_image);
@@ -82,9 +83,6 @@ void read_item_definition(lua_State* L, int index,
getboolfield(L, index, "liquids_pointable", def.liquids_pointable);
- warn_if_field_exists(L, index, "tool_digging_properties",
- "Obsolete; use tool_capabilities");
-
lua_getfield(L, index, "tool_capabilities");
if(lua_istable(L, -1)){
def.tool_capabilities = new ToolCapabilities(
@@ -142,6 +140,10 @@ void push_item_definition_full(lua_State *L, const ItemDefinition &i)
lua_setfield(L, -2, "name");
lua_pushstring(L, i.description.c_str());
lua_setfield(L, -2, "description");
+ if (!i.short_description.empty()) {
+ lua_pushstring(L, i.short_description.c_str());
+ lua_setfield(L, -2, "short_description");
+ }
lua_pushstring(L, type.c_str());
lua_setfield(L, -2, "type");
lua_pushstring(L, i.inventory_image.c_str());
@@ -310,6 +312,17 @@ void read_object_properties(lua_State *L, int index,
prop->nametag_color = color;
}
lua_pop(L, 1);
+ lua_getfield(L, -1, "nametag_bgcolor");
+ if (!lua_isnil(L, -1)) {
+ if (lua_toboolean(L, -1)) {
+ video::SColor color;
+ if (read_color(L, -1, &color))
+ prop->nametag_bgcolor = color;
+ } else {
+ prop->nametag_bgcolor = nullopt;
+ }
+ }
+ lua_pop(L, 1);
lua_getfield(L, -1, "automatic_face_movement_max_rotation_per_sec");
if (lua_isnumber(L, -1)) {
@@ -328,6 +341,7 @@ void read_object_properties(lua_State *L, int index,
getfloatfield(L, -1, "zoom_fov", prop->zoom_fov);
getboolfield(L, -1, "use_texture_alpha", prop->use_texture_alpha);
getboolfield(L, -1, "shaded", prop->shaded);
+ getboolfield(L, -1, "show_on_minimap", prop->show_on_minimap);
getstringfield(L, -1, "damage_texture_modifier", prop->damage_texture_modifier);
}
@@ -400,6 +414,13 @@ void push_object_properties(lua_State *L, ObjectProperties *prop)
lua_setfield(L, -2, "nametag");
push_ARGB8(L, prop->nametag_color);
lua_setfield(L, -2, "nametag_color");
+ if (prop->nametag_bgcolor) {
+ push_ARGB8(L, prop->nametag_bgcolor.value());
+ lua_setfield(L, -2, "nametag_bgcolor");
+ } else {
+ lua_pushboolean(L, false);
+ lua_setfield(L, -2, "nametag_bgcolor");
+ }
lua_pushnumber(L, prop->automatic_face_movement_max_rotation_per_sec);
lua_setfield(L, -2, "automatic_face_movement_max_rotation_per_sec");
lua_pushlstring(L, prop->infotext.c_str(), prop->infotext.size());
@@ -416,6 +437,8 @@ void push_object_properties(lua_State *L, ObjectProperties *prop)
lua_setfield(L, -2, "shaded");
lua_pushlstring(L, prop->damage_texture_modifier.c_str(), prop->damage_texture_modifier.size());
lua_setfield(L, -2, "damage_texture_modifier");
+ lua_pushboolean(L, prop->show_on_minimap);
+ lua_setfield(L, -2, "show_on_minimap");
}
/******************************************************************************/
@@ -488,13 +511,11 @@ TileDef read_tiledef(lua_State *L, int index, u8 drawtype)
}
/******************************************************************************/
-ContentFeatures read_content_features(lua_State *L, int index)
+void read_content_features(lua_State *L, ContentFeatures &f, int index)
{
if(index < 0)
index = lua_gettop(L) + 1 + index;
- ContentFeatures f;
-
/* Cache existence of some callbacks */
lua_getfield(L, index, "on_construct");
if(!lua_isnil(L, -1)) f.has_on_construct = true;
@@ -617,22 +638,39 @@ ContentFeatures read_content_features(lua_State *L, int index)
}
lua_pop(L, 1);
- f.alpha = getintfield_default(L, index, "alpha", 255);
+ /* alpha & use_texture_alpha */
+ // This is a bit complicated due to compatibility
+
+ f.setDefaultAlphaMode();
+
+ warn_if_field_exists(L, index, "alpha",
+ "Obsolete, only limited compatibility provided; "
+ "replaced by \"use_texture_alpha\"");
+ if (getintfield_default(L, index, "alpha", 255) != 255)
+ f.alpha = ALPHAMODE_BLEND;
+
+ lua_getfield(L, index, "use_texture_alpha");
+ if (lua_isboolean(L, -1)) {
+ warn_if_field_exists(L, index, "use_texture_alpha",
+ "Boolean values are deprecated; use the new choices");
+ if (lua_toboolean(L, -1))
+ f.alpha = (f.drawtype == NDT_NORMAL) ? ALPHAMODE_CLIP : ALPHAMODE_BLEND;
+ } else if (check_field_or_nil(L, -1, LUA_TSTRING, "use_texture_alpha")) {
+ int result = f.alpha;
+ string_to_enum(ScriptApiNode::es_TextureAlphaMode, result,
+ std::string(lua_tostring(L, -1)));
+ f.alpha = static_cast<enum AlphaMode>(result);
+ }
+ lua_pop(L, 1);
- bool usealpha = getboolfield_default(L, index,
- "use_texture_alpha", false);
- if (usealpha)
- f.alpha = 0;
+ /* Other stuff */
- // Read node color.
lua_getfield(L, index, "color");
read_color(L, -1, &f.color);
lua_pop(L, 1);
getstringfield(L, index, "palette", f.palette_name);
- /* Other stuff */
-
lua_getfield(L, index, "post_effect_color");
read_color(L, -1, &f.post_effect_color);
lua_pop(L, 1);
@@ -649,20 +687,6 @@ ContentFeatures read_content_features(lua_State *L, int index)
warningstream << "Node " << f.name.c_str()
<< " has a palette, but not a suitable paramtype2." << std::endl;
- // Warn about some obsolete fields
- warn_if_field_exists(L, index, "wall_mounted",
- "Obsolete; use paramtype2 = 'wallmounted'");
- warn_if_field_exists(L, index, "light_propagates",
- "Obsolete; determined from paramtype");
- warn_if_field_exists(L, index, "dug_item",
- "Obsolete; use 'drop' field");
- warn_if_field_exists(L, index, "extra_dug_item",
- "Obsolete; use 'drop' field");
- warn_if_field_exists(L, index, "extra_dug_item_rarity",
- "Obsolete; use 'drop' field");
- warn_if_field_exists(L, index, "metadata_name",
- "Obsolete; use on_add and metadata callbacks");
-
// True for all ground-like things like stone and mud, false for eg. trees
getboolfield(L, index, "is_ground_content", f.is_ground_content);
f.light_propagates = (f.param_type == CPT_LIGHT);
@@ -797,7 +821,6 @@ ContentFeatures read_content_features(lua_State *L, int index)
getstringfield(L, index, "node_dig_prediction",
f.node_dig_prediction);
- return f;
}
void push_content_features(lua_State *L, const ContentFeatures &c)
@@ -1959,9 +1982,10 @@ void push_hud_element(lua_State *L, HudElement *elem)
HudElementStat read_hud_change(lua_State *L, HudElement *elem, void **value)
{
HudElementStat stat = HUD_STAT_NUMBER;
+ std::string statstr;
if (lua_isstring(L, 3)) {
int statint;
- std::string statstr = lua_tostring(L, 3);
+ statstr = lua_tostring(L, 3);
stat = string_to_enum(es_HudElementStat, statint, statstr) ?
(HudElementStat)statint : stat;
}
@@ -1989,6 +2013,8 @@ HudElementStat read_hud_change(lua_State *L, HudElement *elem, void **value)
break;
case HUD_STAT_ITEM:
elem->item = luaL_checknumber(L, 4);
+ if (elem->type == HUD_ELEM_WAYPOINT && statstr == "precision")
+ elem->item++;
*value = &elem->item;
break;
case HUD_STAT_DIR: