| | |
| | | if node.param2 == 0 then pos1.x = pos1.x + 1 x_velocity = 1 end |
| | | |
| | | local output_tube_connected = false |
| | | local meta1 = minetest.get_meta(pos1) |
| | | if meta1:get_int("tubelike") == 1 then |
| | | local node1 = minetest.get_node(pos1) |
| | | if minetest.get_item_group(node1.name, "tubedevice") > 0 then |
| | | output_tube_connected = true |
| | | end |
| | | tube_time = meta:get_int("tube_time") |
| | | tube_time = tube_time + tube_upgrade |
| | | local tube_time = meta:get_int("tube_time") + tube_upgrade |
| | | if tube_time >= 2 then |
| | | tube_time = 0 |
| | | if output_tube_connected then |
| | |
| | | local inv = meta:get_inventory() |
| | | if not inv:is_empty("src") or not inv:is_empty("dst") or |
| | | not inv:is_empty("upgrade1") or not inv:is_empty("upgrade2") then |
| | | minetest.chat_send_player(player:get_player_name(), |
| | | S("Machine cannot be removed because it is not empty")) |
| | | if player then |
| | | minetest.chat_send_player(player:get_player_name(), |
| | | S("Machine cannot be removed because it is not empty")) |
| | | end |
| | | return false |
| | | else |
| | | return true |
| | | end |
| | | end |
| | | |
| | | local function inv_change(pos, player, count) |
| | | local function inv_change(pos, player, count, from_list, to_list) |
| | | if minetest.is_protected(pos, player:get_player_name()) then |
| | | minetest.chat_send_player(player:get_player_name(), |
| | | S("Inventory move disallowed due to protection")) |
| | | return 0 |
| | | end |
| | | if to_list == "upgrade1" or to_list == "upgrade2" then |
| | | -- only place a single item into it, if it's empty |
| | | local empty = minetest.get_meta(pos):get_inventory():is_empty(to_list) |
| | | return empty and 1 or 0 |
| | | end |
| | | return count |
| | | end |
| | | |
| | | function technic.machine_inventory_put(pos, listname, index, stack, player) |
| | | return inv_change(pos, player, stack:get_count()) |
| | | return inv_change(pos, player, stack:get_count(), nil, listname) |
| | | end |
| | | |
| | | function technic.machine_inventory_take(pos, listname, index, stack, player) |
| | | return inv_change(pos, player, stack:get_count()) |
| | | return inv_change(pos, player, stack:get_count(), listname, nil) |
| | | end |
| | | |
| | | function technic.machine_inventory_move(pos, from_list, from_index, |
| | | to_list, to_index, count, player) |
| | | return inv_change(pos, player, count) |
| | | return inv_change(pos, player, count, from_list, to_list) |
| | | end |
| | | |