]> git.lizzy.rs Git - minetest.git/blobdiff - src/script/common/c_content.cpp
Revert "Add support for using arbitrary meshes as items"
[minetest.git] / src / script / common / c_content.cpp
index 3754fc2ff9f8f886d8d1873b185791348da771f8..36a5c2ddd700e96d21304d1317a342e091015eaa 100644 (file)
@@ -76,7 +76,7 @@ ItemDefinition 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",
-                       "deprecated: use tool_capabilities");
+                       "Deprecated; use tool_capabilities");
 
        lua_getfield(L, index, "tool_capabilities");
        if(lua_istable(L, -1)){
@@ -100,6 +100,9 @@ ItemDefinition read_item_definition(lua_State* L,int index,
                lua_getfield(L, -1, "place");
                read_soundspec(L, -1, def.sound_place);
                lua_pop(L, 1);
+               lua_getfield(L, -1, "place_failed");
+               read_soundspec(L, -1, def.sound_place_failed);
+               lua_pop(L, 1);
        }
        lua_pop(L, 1);
 
@@ -197,6 +200,22 @@ void read_object_properties(lua_State *L, int index,
                prop->automatic_face_movement_dir_offset = 0.0;
        }
        lua_pop(L, 1);
+       getboolfield(L, -1, "backface_culling", prop->backface_culling);
+
+       getstringfield(L, -1, "nametag", prop->nametag);
+       lua_getfield(L, -1, "nametag_color");
+       if (!lua_isnil(L, -1)) {
+               video::SColor color = prop->nametag_color;
+               if (read_color(L, -1, &color))
+                       prop->nametag_color = color;
+       }
+       lua_pop(L, 1);
+
+       lua_getfield(L, -1, "automatic_face_movement_max_rotation_per_sec");
+       if (lua_isnumber(L, -1)) {
+               prop->automatic_face_movement_max_rotation_per_sec = luaL_checknumber(L, -1);
+       }
+       lua_pop(L, 1);
 }
 
 /******************************************************************************/
@@ -255,6 +274,14 @@ void push_object_properties(lua_State *L, ObjectProperties *prop)
        else
                lua_pushboolean(L, false);
        lua_setfield(L, -2, "automatic_face_movement_dir");
+       lua_pushboolean(L, prop->backface_culling);
+       lua_setfield(L, -2, "backface_culling");
+       lua_pushlstring(L, prop->nametag.c_str(), prop->nametag.size());
+       lua_setfield(L, -2, "nametag");
+       push_ARGB8(L, prop->nametag_color);
+       lua_setfield(L, -2, "nametag_color");
+       lua_pushnumber(L, prop->automatic_face_movement_max_rotation_per_sec);
+       lua_setfield(L, -2, "automatic_face_movement_max_rotation_per_sec");
 }
 
 /******************************************************************************/
@@ -427,17 +454,17 @@ ContentFeatures read_content_features(lua_State *L, int index)
 
        // Warn about some deprecated fields
        warn_if_field_exists(L, index, "wall_mounted",
-                       "deprecated: use paramtype2 = 'wallmounted'");
+                       "Deprecated; use paramtype2 = 'wallmounted'");
        warn_if_field_exists(L, index, "light_propagates",
-                       "deprecated: determined from paramtype");
+                       "Deprecated; determined from paramtype");
        warn_if_field_exists(L, index, "dug_item",
-                       "deprecated: use 'drop' field");
+                       "Deprecated; use 'drop' field");
        warn_if_field_exists(L, index, "extra_dug_item",
-                       "deprecated: use 'drop' field");
+                       "Deprecated; use 'drop' field");
        warn_if_field_exists(L, index, "extra_dug_item_rarity",
-                       "deprecated: use 'drop' field");
+                       "Deprecated; use 'drop' field");
        warn_if_field_exists(L, index, "metadata_name",
-                       "deprecated: use on_add and metadata callbacks");
+                       "Deprecated; 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);
@@ -639,14 +666,13 @@ void pushnode(lua_State *L, const MapNode &n, INodeDefManager *ndef)
 
 /******************************************************************************/
 void warn_if_field_exists(lua_State *L, int table,
-               const char *fieldname, const std::string &message)
+               const char *name, const std::string &message)
 {
-       lua_getfield(L, table, fieldname);
-       if(!lua_isnil(L, -1)){
-//TODO find way to access backtrace fct from here
-               //              infostream<<script_get_backtrace(L)<<std::endl;
-               infostream<<"WARNING: field \""<<fieldname<<"\": "
-                               <<message<<std::endl;
+       lua_getfield(L, table, name);
+       if (!lua_isnil(L, -1)) {
+               warningstream << "Field \"" << name << "\": "
+                               << message << std::endl;
+               infostream << script_get_backtrace(L) << std::endl;
        }
        lua_pop(L, 1);
 }
@@ -705,7 +731,7 @@ ItemStack read_item(lua_State* L, int index,Server* srv)
                }
                catch(SerializationError &e)
                {
-                       infostream<<"WARNING: unable to create item from itemstring"
+                       warningstream<<"unable to create item from itemstring"
                                        <<": "<<itemstring<<std::endl;
                        return ItemStack();
                }
@@ -840,14 +866,14 @@ ToolCapabilities read_tool_capabilities(
                                getintfield(L, table_groupcap, "uses", groupcap.uses);
                                // DEPRECATED: maxwear
                                float maxwear = 0;
-                               if(getfloatfield(L, table_groupcap, "maxwear", maxwear)){
-                                       if(maxwear != 0)
+                               if (getfloatfield(L, table_groupcap, "maxwear", maxwear)){
+                                       if (maxwear != 0)
                                                groupcap.uses = 1.0/maxwear;
                                        else
                                                groupcap.uses = 0;
-                                       infostream<<script_get_backtrace(L)<<std::endl;
-                                       infostream<<"WARNING: field \"maxwear\" is deprecated; "
-                                                       <<"should replace with uses=1/maxwear"<<std::endl;
+                                       warningstream << "Field \"maxwear\" is deprecated; "
+                                                       << "replace with uses=1/maxwear" << std::endl;
+                                       infostream << script_get_backtrace(L) << std::endl;
                                }
                                // Read "times" table
                                lua_getfield(L, table_groupcap, "times");
@@ -1232,4 +1258,3 @@ void read_json_value(lua_State *L, Json::Value &root, int index, u8 recursion)
        }
        lua_pop(L, 1); // Pop value
 }
-