From 66f90a6101bd6c2402aa43397fc29435c72de2a1 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Sat, 3 Dec 2011 20:25:21 +0200 Subject: Make global names in default mod use good naming convention and move backwards-compatibility definitions to mods/legacy --- data/builtin.lua | 71 +++ data/mods/default/init.lua | 644 ++++++++++++------------ data/mods/experimental/init.lua | 2 +- data/mods/legacy/depends.txt | 2 + data/mods/legacy/init.lua | 1029 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 1403 insertions(+), 345 deletions(-) create mode 100644 data/mods/legacy/depends.txt create mode 100644 data/mods/legacy/init.lua (limited to 'data') diff --git a/data/builtin.lua b/data/builtin.lua index 5d6936d61..2f167acfa 100644 --- a/data/builtin.lua +++ b/data/builtin.lua @@ -340,6 +340,77 @@ minetest.craftitem_eat = function(hp_change) end end +-- +-- Default material types +-- + +function minetest.digprop_constanttime(time) + return { + diggability = "constant", + constant_time = time, + } +end + +function minetest.digprop_stonelike(toughness) + return { + diggablity = "normal", + weight = toughness * 5, + crackiness = 1, + crumbliness = -0.1, + cuttability = -0.2, + } +end + +function minetest.digprop_dirtlike(toughness) + return { + diggablity = "normal", + weight = toughness * 1.2, + crackiness = 0, + crumbliness = 1.2, + cuttability = -0.4, + } +end + +function minetest.digprop_gravellike(toughness) + return { + diggablity = "normal", + weight = toughness * 2, + crackiness = 0.2, + crumbliness = 1.5, + cuttability = -1.0, + } +end + +function minetest.digprop_woodlike(toughness) + return { + diggablity = "normal", + weight = toughness * 1.0, + crackiness = 0.75, + crumbliness = -1.0, + cuttability = 1.5, + } +end + +function minetest.digprop_leaveslike(toughness) + return { + diggablity = "normal", + weight = toughness * (-0.5), + crackiness = 0, + crumbliness = 0, + cuttability = 2.0, + } +end + +function minetest.digprop_glasslike(toughness) + return { + diggablity = "normal", + weight = toughness * 0.1, + crackiness = 2.0, + crumbliness = -1.0, + cuttability = -1.0, + } +end + -- -- Creative inventory -- diff --git a/data/mods/default/init.lua b/data/mods/default/init.lua index 7383996b1..b32b6215a 100644 --- a/data/mods/default/init.lua +++ b/data/mods/default/init.lua @@ -1,3 +1,9 @@ +-- default (Minetest 0.4 mod) +-- Most default stuff + +-- Quick documentation about the API +-- ================================= +-- -- Helper functions defined by builtin.lua: -- dump2(obj, name="_", dumped={}) -- dump(obj, dumped={}) @@ -36,7 +42,7 @@ -- ":experimental:tnt" when registering it. -- (also that mods is required to have "experimental" as a dependency) -- --- Default mod uses ":" for maintaining backwards compatibility. +-- The legacy mod uses ":" for maintaining backwards compatibility. -- -- Textures -- -------- @@ -51,18 +57,30 @@ -- MapNode representation: -- {name="name", param1=num, param2=num} -- +-- param1 and param2 are 8 bit and 4 bit integers, respectively. They +-- are reserved for certain automated functions. If you don't use these +-- functions, you can use them to store arbitrary values. +-- +-- param1 is reserved for the engine when: +-- paramtype != "none" +-- param2 is reserved for the engine when any of these are used: +-- liquidtype == "flowing" +-- drawtype == "flowingliquid" +-- drawtype == "torchlike" +-- drawtype == "signlike" +-- -- Position representation: -- {x=num, y=num, z=num} -- -- stackstring/itemstring: A stack of items in serialized format. -- eg. 'node "dirt" 5' --- eg. 'tool "WPick" 21323' +-- eg. 'tool "default:pick_wood" 21323' -- eg. 'craft "apple" 2' -- -- item: A single item in Lua table format. -- eg. {type="node", name="dirt"} -- ^ a single dirt node --- eg. {type="tool", name="WPick", wear=21323} +-- eg. {type="tool", name="default:pick_wood", wear=21323} -- ^ a wooden pick about 1/3 weared out -- eg. {type="craft", name="apple"} -- ^ an apple. @@ -113,6 +131,9 @@ -- - add_node(pos, node) -- - remove_node(pos) -- - get_node(pos) +-- ^ Returns {name="ignore", ...} for unloaded area +-- - get_node_or_nil(pos) +-- ^ Returns nil for unloaded area -- - add_luaentity(pos, name) -- - add_item(pos, itemstring) -- - add_rat(pos) @@ -215,7 +236,7 @@ -- -- Node definition options: -- { --- name = "somenode", +-- name = "modname:somenode", -- drawtype = "normal", -- visual_scale = 1.0, -- tile_images = {"unknown_block.png"}, @@ -256,7 +277,7 @@ -- cuttability = 0, -- flammability = 0, -- }, --- cookresult_item = "", -- Cannot be cooked +-- cookresult_itemstring = "", -- Cannot be cooked -- furnace_cooktime = 3.0, -- furnace_burntime = -1, -- Cannot be used as fuel -- } @@ -265,7 +286,7 @@ -- minetest.register_craftitem("modname_name", { -- image = "image.png", -- stack_max = , --- cookresult_item = itemstring (result of cooking), +-- cookresult_itemstring = itemstring (result of cooking), -- furnace_cooktime = , -- furnace_burntime =