summaryrefslogtreecommitdiff
path: root/data/builtin.lua
diff options
context:
space:
mode:
Diffstat (limited to 'data/builtin.lua')
-rw-r--r--data/builtin.lua31
1 files changed, 31 insertions, 0 deletions
diff --git a/data/builtin.lua b/data/builtin.lua
index dc41caf69..c3e426db5 100644
--- a/data/builtin.lua
+++ b/data/builtin.lua
@@ -1,3 +1,10 @@
+--
+-- This file contains built-in stuff in Minetest implemented in Lua.
+--
+-- It is always loaded and executed after registration of the C API,
+-- before loading and running any mods.
+--
+
function basic_dump2(o)
if type(o) == "number" then
return tostring(o)
@@ -297,6 +304,30 @@ end
test_stackstring()
--
+-- craftitem helpers
+--
+
+minetest.craftitem_place_item = function(item, placer, pos)
+ --print("craftitem_place_item")
+ --print("item: " .. dump(item))
+ --print("placer: " .. dump(placer))
+ --print("pos: " .. dump(pos))
+ minetest.env:add_item(pos, 'CraftItem "' .. item .. '" 1')
+ return true
+end
+
+minetest.craftitem_eat = function(hp_change)
+ return function(item, user, pointed_thing) -- closure
+ --print("craftitem_eat(" .. hp_change .. ")")
+ --print("item: " .. dump(item))
+ --print("user: " .. dump(user))
+ --print("pointed_thing: " .. dump(pointed_thing))
+ user:set_hp(user:get_hp() + hp_change)
+ return true
+ end
+end
+
+--
-- Callback registration
--