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

Rework tool_capabilities a bit (maxwear->uses, scale dig time according to leveldiff)

This commit is contained in:
Perttu Ahola 2012-03-29 13:35:20 +03:00
parent ace005bf7c
commit 440e9cdbef
5 changed files with 137 additions and 75 deletions

View file

@ -670,8 +670,19 @@ static ToolCapabilities read_tool_capabilities(
// This will be created
ToolGroupCap groupcap;
// Read simple parameters
getfloatfield(L, table_groupcap, "maxwear", groupcap.maxwear);
getintfield(L, table_groupcap, "maxlevel", groupcap.maxlevel);
getintfield(L, table_groupcap, "uses", groupcap.uses);
// DEPRECATED: maxwear
float 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;
}
// Read "times" table
lua_getfield(L, table_groupcap, "times");
if(lua_istable(L, -1)){
@ -725,8 +736,8 @@ static void set_tool_capabilities(lua_State *L, int table,
// Set subtable "times"
lua_setfield(L, -2, "times");
// Set simple parameters
setfloatfield(L, -1, "maxwear", groupcap.maxwear);
setintfield(L, -1, "maxlevel", groupcap.maxlevel);
setintfield(L, -1, "uses", groupcap.uses);
// Insert groupcap table into groupcaps table
lua_setfield(L, -2, name.c_str());
}