summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNovatux <nathanael.courant@laposte.net>2013-10-05 19:09:05 +0200
committerNovatux <nathanael.courant@laposte.net>2013-10-05 19:10:43 +0200
commitab197387bb103c377375343c38761f4783a0bab4 (patch)
treedb3eaf1fb6c4bb2ebb4e169379b3e3261f3fc46d
parent7546bb17fb858d11db9ea526ad73f8181f91a154 (diff)
Better deployerorigin/deployer
-rw-r--r--deployer.lua15
1 files changed, 12 insertions, 3 deletions
diff --git a/deployer.lua b/deployer.lua
index 1e8ae17..dc735b5 100644
--- a/deployer.lua
+++ b/deployer.lua
@@ -112,14 +112,19 @@ deployer_on = function(pos, node)
hacky_swap_node(pos,"pipeworks:deployer_on")
nodeupdate(pos)
- local inv = minetest.get_meta(pos):get_inventory()
+ local meta = minetest.get_meta(pos)
+ local inv = meta:get_inventory()
local invlist = inv:get_list("main")
for i, stack in ipairs(invlist) do
if stack:get_name() ~= nil and stack:get_name() ~= "" and minetest.get_node(pos_under).name == "air" then --obtain the first non-empty item slot
+ local owner = meta:get_string("owner")
local placer = {
- get_player_name = function() return "deployer" end,
+ get_player_name = function() return owner end,
getpos = function() return pos end,
get_player_control = function() return {jump=false,right=false,left=false,LMB=false,RMB=false,sneak=false,aux1=false,down=false,up=false} end,
+ is_player = function() return true end,
+ get_player_control_bits = function() return 0 end,
+ get_look_dir = function() return {x = -dir.x, y = -dir.y, z = -dir.z} end,
}
local stack2 = minetest.item_place(stack, placer, {type="node", under=pos_under, above=pos_above})
if minetest.setting_getbool("creative_mode") and not minetest.get_modpath("unified_inventory") then --infinite stacks ahoy!
@@ -181,7 +186,11 @@ minetest.register_node("pipeworks:deployer_off", {
local placer_pos = placer:getpos()
--correct for the player's height
- if placer:is_player() then placer_pos.y = placer_pos.y + 1.5 end
+ if placer:is_player() then
+ local meta = minetest.get_meta(pos)
+ meta:set_string("owner", placer:get_player_name())
+ placer_pos.y = placer_pos.y + 1.5
+ end
--correct for 6d facedir
if placer_pos then