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(
// "" = no prediction
getstringfield(L, index, "node_placement_prediction",
def.node_placement_prediction);
+
+ getintfield(L, index, "place_param2", def.place_param2);
}
/******************************************************************************/
lua_setfield(L, -2, "name");
lua_pushstring(L, i.description.c_str());
lua_setfield(L, -2, "description");
- lua_pushstring(L, i.short_description.c_str());
- lua_setfield(L, -2, "short_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());
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)) {
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);
}
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());
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");
}
/******************************************************************************/
}
/******************************************************************************/
-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;
}
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);
if (!f.palette_name.empty() &&
!(f.param_type_2 == CPT2_COLOR ||
f.param_type_2 == CPT2_COLORED_FACEDIR ||
- f.param_type_2 == CPT2_COLORED_WALLMOUNTED))
+ f.param_type_2 == CPT2_COLORED_WALLMOUNTED ||
+ f.param_type_2 == CPT2_COLORED_DEGROTATE))
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);
getstringfield(L, index, "node_dig_prediction",
f.node_dig_prediction);
- return f;
}
void push_content_features(lua_State *L, const ContentFeatures &c)
{
if(tableindex < 0)
tableindex = lua_gettop(L) + 1 + tableindex;
+
// If nil, delete list
if(lua_isnil(L, tableindex)){
inv->deleteList(name);
return;
}
- // Otherwise set list
+
+ // Get Lua-specified items to insert into the list
std::vector<ItemStack> items = read_items(L, tableindex,srv);
- int listsize = (forcesize != -1) ? forcesize : items.size();
+ size_t listsize = (forcesize >= 0) ? forcesize : items.size();
+
+ // Create or resize/clear list
InventoryList *invlist = inv->addList(name, listsize);
- int index = 0;
- for(std::vector<ItemStack>::const_iterator
- i = items.begin(); i != items.end(); ++i){
- if(forcesize != -1 && index == forcesize)
- break;
- invlist->changeItem(index, *i);
- index++;
+ if (!invlist) {
+ luaL_error(L, "inventory list: cannot create list named '%s'", name);
+ return;
}
- while(forcesize != -1 && index < forcesize){
- invlist->deleteItem(index);
- index++;
+
+ for (size_t i = 0; i < items.size(); ++i) {
+ if (i == listsize)
+ break; // Truncate provided list of items
+ invlist->changeItem(i, items[i]);
}
}