1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-07-02 16:38:41 +00:00

Move craftitem_place_item as minetest.craftitem_place_item in builtin.lua

This commit is contained in:
Perttu Ahola 2011-11-30 23:52:02 +02:00
parent 1b61ca412b
commit 918c507a66
3 changed files with 49 additions and 43 deletions

View file

@ -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)
@ -296,6 +303,30 @@ function test_stackstring()
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
--