diff options
author | Perttu Ahola <celeron55@gmail.com> | 2012-03-29 13:35:20 +0300 |
---|---|---|
committer | Perttu Ahola <celeron55@gmail.com> | 2012-03-29 13:35:20 +0300 |
commit | 440e9cdbef19d154f134a85c7e2601f0aff63459 (patch) | |
tree | e139e83c88d67c5847b1675ab5cb2f5f900161af /src/scriptapi.cpp | |
parent | ace005bf7cd9687a49b1813bc091240660d21963 (diff) | |
download | minetest-440e9cdbef19d154f134a85c7e2601f0aff63459.tar.gz minetest-440e9cdbef19d154f134a85c7e2601f0aff63459.tar.bz2 minetest-440e9cdbef19d154f134a85c7e2601f0aff63459.zip |
Rework tool_capabilities a bit (maxwear->uses, scale dig time according to leveldiff)
Diffstat (limited to 'src/scriptapi.cpp')
-rw-r--r-- | src/scriptapi.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/scriptapi.cpp b/src/scriptapi.cpp index 38d681e9b..863e2ba28 100644 --- a/src/scriptapi.cpp +++ b/src/scriptapi.cpp @@ -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()); } |