Skip to content

Commit 1164d2f

Browse files
committed
Add support for pulling items out of controller using techage
1 parent 7f28f7e commit 1164d2f

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

lua/controller.lua

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,28 @@ local function register_controller()
506506
techage.register_node({"drawers:controller"}, {
507507
on_push_item = function(pos, in_dir, stack)
508508
return controller_insert_to_drawers(pos, stack)
509-
end
509+
end,
510+
on_pull_item = function(pos, in_dir, num, item_name)
511+
if not item_name then
512+
return
513+
end
514+
515+
local item = ItemStack(item_name)
516+
local drawers_index = controller_get_drawer_index(pos, item:get_name())
517+
518+
if not drawers_index[item:get_name()] then
519+
-- we can't do anything: the requested item doesn't exist
520+
return
521+
end
522+
523+
item:set_count(num)
524+
local taken_stack = drawers.drawer_take_item(drawers_index[item:get_name()]["drawer_pos"], item)
525+
526+
-- prevent crash if taken_stack ended up with a nil value
527+
if taken_stack then
528+
return taken_stack
529+
end
530+
end,
510531
})
511532
end
512533
end

0 commit comments

Comments
 (0)