From 918c507a66aa5c05422d78a9ea30a455ddd3e124 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Wed, 30 Nov 2011 23:52:02 +0200 Subject: Move craftitem_place_item as minetest.craftitem_place_item in builtin.lua --- data/builtin.lua | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'data/builtin.lua') 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) @@ -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 -- -- cgit v1.2.3