diff options
author | Gabriel Pérez-Cerezo <gabriel@gpcf.eu> | 2017-11-23 13:37:00 +0100 |
---|---|---|
committer | Gabriel Pérez-Cerezo <gabriel@gpcf.eu> | 2017-11-23 13:37:00 +0100 |
commit | 8d68fba505cf2b17c9ed8d105c04b5c2d3aab9f0 (patch) | |
tree | b9a7012024fd17116fe2fd1b4bd12f5cfb830b6e /fakeplayer.lua | |
parent | 264cd0f84e40fe5cb7eaa7e2cfd30b09818f174d (diff) |
added Milker
Diffstat (limited to 'fakeplayer.lua')
-rw-r--r-- | fakeplayer.lua | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/fakeplayer.lua b/fakeplayer.lua index d56f29a..1e1e2ab 100644 --- a/fakeplayer.lua +++ b/fakeplayer.lua @@ -49,15 +49,30 @@ local function get_feed (pos) if not inv or not inv:get_list("main") then return ItemStack(nil) end - -- minetest.chat_send_all(inv:get_stack("main", 1):get_name()) + if inv:get_list("bucket") then + return inv:get_stack("bucket", 1) + end return inv:get_stack("main", 1) end end + +local function get_inv(pos) + return function () + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + return inv + end +end + local function set_feed (pos) return function (_, stack) local meta = minetest.get_meta(pos) local inv = meta:get_inventory() - inv:set_stack("main", 1, stack) + if inv:get_list("bucket") then + inv:set_stack("bucket", 1, stack) + else + inv:set_stack("main", 1, stack) + end return end end @@ -76,7 +91,7 @@ function feedlotFakePlayer.create(pos, player_name) self.right_click = return_nil self.get_hp = return_value(10) self.set_hp = return_nil - self.get_inventory = return_nil -- returns an `InvRef` + self.get_inventory = get_inv(pos) -- returns an `InvRef` self.get_wield_list = return_empty_string self.get_wield_index = return_value(1) -- self.get_wielded_item = return_value(ItemStack(nil)) |