Externalize common functions and protect inventories
| | |
| | | |
| | | ## Machine misc |
| | | Machine cannot be removed because it is not empty = La maquina no puede removerse porque no esta vacia |
| | | Inventory move disallowed due to protection = |
| | | # $1: Machine name (Includes tier) |
| | | %s Active = %s Activo |
| | | %s Idle = %s Quieto |
| | |
| | | |
| | | ## Machine misc |
| | | Machine cannot be removed because it is not empty = La macchina non può essere rimossa perchè non è vuota |
| | | Inventory move disallowed due to protection = |
| | | # $1: Machine name (Includes tier) |
| | | %s Active = %s Attivo |
| | | %s Disabled = %s Disabilitato |
| | |
| | | |
| | | ## Machine misc |
| | | Machine cannot be removed because it is not empty = |
| | | Inventory move disallowed due to protection = |
| | | # $1: Machine name (Includes tier) |
| | | %s Active = |
| | | %s Disabled = |
| | |
| | | Single node. = |
| | | Sonic Screwdriver = |
| | | Tree Tap = |
| | | |
| | | |
| | |
| | | local inv = meta:get_inventory() |
| | | inv:set_size("src", 6) |
| | | end, |
| | | can_dig = function(pos, player) |
| | | local meta = minetest.get_meta(pos); |
| | | local inv = meta:get_inventory() |
| | | if not inv:is_empty("src") then |
| | | minetest.chat_send_player(player:get_player_name(), |
| | | S("Machine cannot be removed because it is not empty")) |
| | | return false |
| | | else |
| | | return true |
| | | end |
| | | end, |
| | | can_dig = technic.machine_can_dig, |
| | | allow_metadata_inventory_put = technic.machine_inventory_put, |
| | | allow_metadata_inventory_take = technic.machine_inventory_take, |
| | | allow_metadata_inventory_move = technic.machine_inventory_move, |
| | | }) |
| | | |
| | | minetest.register_node("technic:hv_nuclear_reactor_core_active", { |
| | |
| | | type = "fixed", |
| | | fixed = nodebox |
| | | }, |
| | | can_dig = function(pos, player) |
| | | local meta = minetest.get_meta(pos); |
| | | local inv = meta:get_inventory() |
| | | if not inv:is_empty("src") then |
| | | minetest.chat_send_player(player:get_player_name(), |
| | | S("Machine cannot be removed because it is not empty")) |
| | | return false |
| | | else |
| | | return true |
| | | end |
| | | end, |
| | | can_dig = technic.machine_can_dig, |
| | | allow_metadata_inventory_put = technic.machine_inventory_put, |
| | | allow_metadata_inventory_take = technic.machine_inventory_take, |
| | | allow_metadata_inventory_move = technic.machine_inventory_move, |
| | | }) |
| | | |
| | | local check_reactor_structure = function(pos) |
| | |
| | | inv:set_size("src", 1) |
| | | inv:set_size("dst", 4) |
| | | end, |
| | | can_dig = function(pos,player) |
| | | local meta = minetest.get_meta(pos); |
| | | local inv = meta:get_inventory() |
| | | if not inv:is_empty("src") or not inv:is_empty("dst") then |
| | | minetest.chat_send_player(player:get_player_name(), |
| | | S("Machine cannot be removed because it is not empty")) |
| | | return false |
| | | else |
| | | return true |
| | | end |
| | | end, |
| | | can_dig = technic.machine_can_dig, |
| | | allow_metadata_inventory_put = technic.machine_inventory_put, |
| | | allow_metadata_inventory_take = technic.machine_inventory_take, |
| | | allow_metadata_inventory_move = technic.machine_inventory_move, |
| | | on_receive_fields = form_handler, |
| | | }) |
| | | |
| | |
| | | paramtype2 = "facedir", |
| | | groups = {cracky=2, not_in_creative_inventory=1}, |
| | | legacy_facedir_simple = true, |
| | | can_dig = function(pos,player) |
| | | local meta = minetest.get_meta(pos); |
| | | local inv = meta:get_inventory() |
| | | if not inv:is_empty("src") or not inv:is_empty("dst") then |
| | | minetest.chat_send_player(player:get_player_name(), |
| | | S("Machine cannot be removed because it is not empty")) |
| | | return false |
| | | end |
| | | return true |
| | | end, |
| | | can_dig = technic.machine_can_dig, |
| | | allow_metadata_inventory_put = technic.machine_inventory_put, |
| | | allow_metadata_inventory_take = technic.machine_inventory_take, |
| | | allow_metadata_inventory_move = technic.machine_inventory_move, |
| | | on_receive_fields = form_handler, |
| | | }) |
| | | |
| | |
| | | |
| | | minetest.register_node("technic:coal_alloy_furnace", { |
| | | description = S("Coal Alloy Furnace"), |
| | | tiles = {"technic_coal_alloy_furnace_top.png", "technic_coal_alloy_furnace_bottom.png", "technic_coal_alloy_furnace_side.png", |
| | | "technic_coal_alloy_furnace_side.png", "technic_coal_alloy_furnace_side.png", "technic_coal_alloy_furnace_front.png"}, |
| | | tiles = {"technic_coal_alloy_furnace_top.png", "technic_coal_alloy_furnace_bottom.png", |
| | | "technic_coal_alloy_furnace_side.png", "technic_coal_alloy_furnace_side.png", |
| | | "technic_coal_alloy_furnace_side.png", "technic_coal_alloy_furnace_front.png"}, |
| | | paramtype2 = "facedir", |
| | | groups = {cracky=2}, |
| | | legacy_facedir_simple = true, |
| | |
| | | inv:set_size("src2", 1) |
| | | inv:set_size("dst", 4) |
| | | end, |
| | | can_dig = function(pos,player) |
| | | local meta = minetest.env:get_meta(pos); |
| | | local inv = meta:get_inventory() |
| | | if not (inv:is_empty("fuel") or inv:is_empty("dst") or inv:is_empty("src") or inv:is_empty("src2") )then |
| | | return false |
| | | end |
| | | return true |
| | | end, |
| | | can_dig = technic.machine_can_dig, |
| | | allow_metadata_inventory_put = technic.machine_inventory_put, |
| | | allow_metadata_inventory_take = technic.machine_inventory_take, |
| | | allow_metadata_inventory_move = technic.machine_inventory_move, |
| | | }) |
| | | |
| | | minetest.register_node("technic:coal_alloy_furnace_active", { |
| | | description = "Alloy Furnace", |
| | | tiles = {"technic_coal_alloy_furnace_top.png", "technic_coal_alloy_furnace_bottom.png", "technic_coal_alloy_furnace_side.png", |
| | | "technic_coal_alloy_furnace_side.png", "technic_coal_alloy_furnace_side.png", "technic_coal_alloy_furnace_front_active.png"}, |
| | | tiles = {"technic_coal_alloy_furnace_top.png", "technic_coal_alloy_furnace_bottom.png", |
| | | "technic_coal_alloy_furnace_side.png", "technic_coal_alloy_furnace_side.png", |
| | | "technic_coal_alloy_furnace_side.png", "technic_coal_alloy_furnace_front_active.png"}, |
| | | paramtype2 = "facedir", |
| | | light_source = 8, |
| | | drop = "technic:coal_alloy_furnace", |
| | | groups = {cracky=2, not_in_creative_inventory=1}, |
| | | legacy_facedir_simple = true, |
| | | sounds = default.node_sound_stone_defaults(), |
| | | can_dig = function(pos,player) |
| | | local meta = minetest.env:get_meta(pos); |
| | | local inv = meta:get_inventory() |
| | | if not (inv:is_empty("fuel") or inv:is_empty("dst") or |
| | | inv:is_empty("src") or inv:is_empty("src2")) then |
| | | return false |
| | | end |
| | | return true |
| | | end, |
| | | can_dig = technic.machine_can_dig, |
| | | allow_metadata_inventory_put = technic.machine_inventory_put, |
| | | allow_metadata_inventory_take = technic.machine_inventory_take, |
| | | allow_metadata_inventory_move = technic.machine_inventory_move, |
| | | }) |
| | | |
| | | minetest.register_abm({ |
| | |
| | | inv:set_size("src", 1) |
| | | inv:set_size("dst", 4) |
| | | end, |
| | | can_dig = function(pos,player) |
| | | local meta = minetest.get_meta(pos) |
| | | local inv = meta:get_inventory() |
| | | if not inv:is_empty("src") or not inv:is_empty("dst") then |
| | | minetest.chat_send_player(player:get_player_name(), |
| | | S("Machine cannot be removed because it is not empty")) |
| | | return false |
| | | else |
| | | return true |
| | | end |
| | | end, |
| | | can_dig = technic.machine_can_dig, |
| | | allow_metadata_inventory_put = technic.machine_inventory_put, |
| | | allow_metadata_inventory_take = technic.machine_inventory_take, |
| | | allow_metadata_inventory_move = technic.machine_inventory_move, |
| | | }) |
| | | |
| | | minetest.register_node("technic:compressor_active", { |
| | |
| | | groups = {cracky=2, not_in_creative_inventory=1}, |
| | | legacy_facedir_simple = true, |
| | | sounds = default.node_sound_wood_defaults(), |
| | | can_dig = function(pos,player) |
| | | local meta = minetest.get_meta(pos); |
| | | local inv = meta:get_inventory() |
| | | if not inv:is_empty("src") or not inv:is_empty("dst") then |
| | | minetest.chat_send_player(player:get_player_name(), |
| | | S("Machine cannot be removed because it is not empty")) |
| | | return false |
| | | else |
| | | return true |
| | | end |
| | | end, |
| | | can_dig = technic.machine_can_dig, |
| | | allow_metadata_inventory_put = technic.machine_inventory_put, |
| | | allow_metadata_inventory_take = technic.machine_inventory_take, |
| | | allow_metadata_inventory_move = technic.machine_inventory_move, |
| | | }) |
| | | |
| | | minetest.register_abm({ |
| | |
| | | inv:set_size("src", 1) |
| | | inv:set_size("dst", 4) |
| | | end, |
| | | can_dig = function(pos,player) |
| | | local meta = minetest.get_meta(pos); |
| | | local inv = meta:get_inventory() |
| | | if not inv:is_empty("src") or not inv:is_empty("dst") then |
| | | minetest.chat_send_player(player:get_player_name(), |
| | | S("Machine cannot be removed because it is not empty")) |
| | | return false |
| | | else |
| | | return true |
| | | end |
| | | end, |
| | | can_dig = technic.machine_can_dig, |
| | | allow_metadata_inventory_put = technic.machine_inventory_put, |
| | | allow_metadata_inventory_take = technic.machine_inventory_take, |
| | | allow_metadata_inventory_move = technic.machine_inventory_move, |
| | | }) |
| | | |
| | | minetest.register_node("technic:extractor_active", { |
| | |
| | | groups = {cracky=2, not_in_creative_inventory=1}, |
| | | legacy_facedir_simple = true, |
| | | sounds = default.node_sound_wood_defaults(), |
| | | can_dig = function(pos,player) |
| | | local meta = minetest.get_meta(pos); |
| | | local inv = meta:get_inventory() |
| | | if not inv:is_empty("src") or not inv:is_empty("dst") then |
| | | minetest.chat_send_player(player:get_player_name(), |
| | | S("Machine cannot be removed because it is not empty")) |
| | | return false |
| | | else |
| | | return true |
| | | end |
| | | end, |
| | | can_dig = technic.machine_can_dig, |
| | | allow_metadata_inventory_put = technic.machine_inventory_put, |
| | | allow_metadata_inventory_take = technic.machine_inventory_take, |
| | | allow_metadata_inventory_move = technic.machine_inventory_move, |
| | | }) |
| | | |
| | | minetest.register_abm({ |
| | |
| | | local inv = meta:get_inventory() |
| | | inv:set_size("src", 1) |
| | | end, |
| | | can_dig = function(pos,player) |
| | | local meta = minetest.get_meta(pos); |
| | | local inv = meta:get_inventory() |
| | | if not inv:is_empty("src") then |
| | | minetest.chat_send_player(player:get_player_name(), |
| | | S("Machine cannot be removed because it is not empty")) |
| | | return false |
| | | end |
| | | return true |
| | | end, |
| | | can_dig = technic.machine_can_dig, |
| | | allow_metadata_inventory_put = technic.machine_inventory_put, |
| | | allow_metadata_inventory_take = technic.machine_inventory_take, |
| | | }) |
| | | |
| | | minetest.register_abm({ |
| | |
| | | local inv = meta:get_inventory() |
| | | return inv:is_empty("slot1") |
| | | end, |
| | | allow_metadata_inventory_put = technic.machine_inventory_put, |
| | | allow_metadata_inventory_take = technic.machine_inventory_take, |
| | | allow_metadata_inventory_move = technic.machine_inventory_move, |
| | | }) |
| | | |
| | | minetest.register_node("technic:constructor_mk1_on", { |
| | | description = "Constructor MK1", |
| | | tile_images = {"technic_constructor_mk1_top_on.png","technic_constructor_mk1_bottom_on.png","technic_constructor_mk1_side2_on.png","technic_constructor_mk1_side1_on.png", |
| | | "technic_constructor_back.png","technic_constructor_front_on.png"}, |
| | | is_ground_content = true, |
| | | paramtype2 = "facedir", |
| | | groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,mesecon = 2,not_in_creative_inventory=1}, |
| | | mesecons= {effector={action_off=mk1_off}}, |
| | | sounds = default.node_sound_stone_defaults(), |
| | | allow_metadata_inventory_put = technic.machine_inventory_put, |
| | | allow_metadata_inventory_take = technic.machine_inventory_take, |
| | | allow_metadata_inventory_move = technic.machine_inventory_move, |
| | | }) |
| | | |
| | | |
| | |
| | | inv:set_size("slot1", 1) |
| | | inv:set_size("slot2", 1) |
| | | end, |
| | | |
| | | can_dig = function(pos,player) |
| | | local meta = minetest.get_meta(pos) |
| | | local inv = meta:get_inventory() |
| | | if inv:is_empty("slot1")==false or inv:is_empty("slot2")==false then return false end |
| | | return true |
| | | end, |
| | | end, |
| | | allow_metadata_inventory_put = technic.machine_inventory_put, |
| | | allow_metadata_inventory_take = technic.machine_inventory_take, |
| | | allow_metadata_inventory_move = technic.machine_inventory_move, |
| | | }) |
| | | |
| | | minetest.register_node("technic:constructor_mk2_on", { |
| | |
| | | is_ground_content = true, |
| | | paramtype2 = "facedir", |
| | | groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon = 2, not_in_creative_inventory=1}, |
| | | mesecons= {effector={action_off=mk2_off}}, |
| | | mesecons = {effector={action_off=mk2_off}}, |
| | | sounds = default.node_sound_stone_defaults(), |
| | | allow_metadata_inventory_put = technic.machine_inventory_put, |
| | | allow_metadata_inventory_take = technic.machine_inventory_take, |
| | | allow_metadata_inventory_move = technic.machine_inventory_move, |
| | | }) |
| | | |
| | | |
| | |
| | | description = "Constructor MK3", |
| | | tile_images = {"technic_constructor_mk3_top_off.png","technic_constructor_mk3_bottom_off.png","technic_constructor_mk3_side2_off.png","technic_constructor_mk3_side1_off.png", |
| | | "technic_constructor_back.png","technic_constructor_front_off.png"}, |
| | | is_ground_content = true, |
| | | paramtype2 = "facedir", |
| | | groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon = 2}, |
| | | mesecons= {effector={action_on=mk3_on}}, |
| | | mesecons = {effector={action_on=mk3_on}}, |
| | | sounds = default.node_sound_stone_defaults(), |
| | | on_construct = function(pos) |
| | | local meta = minetest.get_meta(pos) |
| | |
| | | if inv:is_empty("slot1")==false or inv:is_empty("slot2")==false or inv:is_empty("slot3")==false or inv:is_empty("slot4")==false then return false end |
| | | return true |
| | | end, |
| | | allow_metadata_inventory_put = technic.machine_inventory_put, |
| | | allow_metadata_inventory_take = technic.machine_inventory_take, |
| | | allow_metadata_inventory_move = technic.machine_inventory_move, |
| | | }) |
| | | |
| | | minetest.register_node("technic:constructor_mk3_on", { |
| | |
| | | is_ground_content = true, |
| | | paramtype2 = "facedir", |
| | | groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon = 2,not_in_creative_inventory=1}, |
| | | mesecons= {effector={action_off=mk3_off}}, |
| | | mesecons = {effector={action_off=mk3_off}}, |
| | | sounds = default.node_sound_stone_defaults(), |
| | | allow_metadata_inventory_put = technic.machine_inventory_put, |
| | | allow_metadata_inventory_take = technic.machine_inventory_take, |
| | | allow_metadata_inventory_move = technic.machine_inventory_move, |
| | | }) |
| | | |
| | | |
| | |
| | | minetest.register_craftitem("technic:injector", { |
| | | description = "Injector", |
| | | stack_max = 99, |
| | | }) |
| | | |
| | | minetest.register_craft({ |
| | | output = 'technic:injector 1', |
| | |
| | | return inv:is_empty("main") |
| | | end, |
| | | on_receive_fields = function(pos, formanme, fields, sender) |
| | | local meta = minetest.env:get_meta(pos) |
| | | local mode=meta:get_string("mode") |
| | | if fields.mode then |
| | | if mode=="single items" then mode="whole stacks" |
| | | else mode="single items" |
| | | local meta = minetest.env:get_meta(pos) |
| | | local mode=meta:get_string("mode") |
| | | if fields.mode then |
| | | if mode == "single items" then |
| | | mode = "whole stacks" |
| | | else |
| | | mode = "single items" |
| | | end |
| | | meta:set_string("mode", mode) |
| | | end |
| | | local mode=meta:set_string("mode",mode) |
| | | end |
| | | meta:set_string("formspec", |
| | | meta:set_string("formspec", |
| | | "invsize[8,9;]".. |
| | | "label[0,0;Injector]".. |
| | | "button[0,1;.8,.8;mode;]".. |
| | |
| | | "list[current_name;main;0,2;8,2;]".. |
| | | "list[current_player;main;0,5;8,4;]") |
| | | end, |
| | | allow_metadata_inventory_put = technic.machine_inventory_put, |
| | | allow_metadata_inventory_take = technic.machine_inventory_take, |
| | | allow_metadata_inventory_move = technic.machine_inventory_move, |
| | | }) |
| | | |
| | | minetest.register_abm({ |
| | | nodenames = {"technic:injector"}, |
| | | interval = 1, |
| | | chance = 1, |
| | | |
| | | action = function(pos, node, active_object_count, active_object_count_wider) |
| | | local pos1={} |
| | | pos1.x = pos.x |
| | |
| | | inv:set_size("upgrade1", 1) |
| | | inv:set_size("upgrade2", 1) |
| | | end, |
| | | can_dig = function(pos, player) |
| | | local meta = minetest.get_meta(pos); |
| | | 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")) |
| | | return false |
| | | else |
| | | return true |
| | | end |
| | | end, |
| | | can_dig = technic.machine_can_dig, |
| | | allow_metadata_inventory_put = technic.machine_inventory_put, |
| | | allow_metadata_inventory_take = technic.machine_inventory_take, |
| | | allow_metadata_inventory_move = technic.machine_inventory_move, |
| | | }) |
| | | |
| | | minetest.register_node("technic:"..ltier.."_alloy_furnace_active",{ |
| | |
| | | tube = data.tube and tube or nil, |
| | | legacy_facedir_simple = true, |
| | | sounds = default.node_sound_stone_defaults(), |
| | | can_dig = function(pos, player) |
| | | local meta = minetest.get_meta(pos); |
| | | 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")) |
| | | return false |
| | | else |
| | | return true |
| | | end |
| | | end, |
| | | -- These three makes sure upgrades are not moved in or out while the furnace is active. |
| | | allow_metadata_inventory_put = function(pos, listname, index, stack, player) |
| | | if listname == "src" or listname == "dst" then |
| | | return stack:get_count() |
| | | else |
| | | return 0 -- Disallow the move |
| | | end |
| | | end, |
| | | allow_metadata_inventory_take = function(pos, listname, index, stack, player) |
| | | if listname == "src" or listname == "dst" then |
| | | return stack:get_count() |
| | | else |
| | | return 0 -- Disallow the move |
| | | end |
| | | end, |
| | | allow_metadata_inventory_move = function(pos, from_list, to_list, to_list, to_index, count, player) |
| | | return 0 |
| | | end, |
| | | can_dig = technic.machine_can_dig, |
| | | allow_metadata_inventory_put = technic.machine_inventory_put, |
| | | allow_metadata_inventory_take = technic.machine_inventory_take, |
| | | allow_metadata_inventory_move = technic.machine_inventory_move, |
| | | }) |
| | | |
| | | minetest.register_abm({ |
| | |
| | | inv:set_size("src", 1) |
| | | inv:set_size("dst", 1) |
| | | end, |
| | | can_dig = function(pos, player) |
| | | local meta = minetest.get_meta(pos); |
| | | local inv = meta:get_inventory() |
| | | if not inv:is_empty("src") or not inv:is_empty("dst") then |
| | | minetest.chat_send_player(player:get_player_name(), |
| | | S("Machine cannot be removed because it is not empty")) |
| | | return false |
| | | else |
| | | return true |
| | | end |
| | | end, |
| | | can_dig = technic.machine_can_dig, |
| | | allow_metadata_inventory_put = technic.machine_inventory_put, |
| | | allow_metadata_inventory_take = technic.machine_inventory_take, |
| | | allow_metadata_inventory_move = technic.machine_inventory_move, |
| | | }) |
| | | end |
| | | |
| | |
| | | |
| | | local S = technic.getter |
| | | |
| | | function technic.handle_machine_upgrades(meta) |
| | | -- Get the names of the upgrades |
| | | local inv = meta:get_inventory() |
| | |
| | | meta:set_int("tube_time", tube_time) |
| | | end |
| | | |
| | | |
| | | function technic.machine_can_dig(pos, player) |
| | | local meta = minetest.get_meta(pos) |
| | | 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")) |
| | | return false |
| | | else |
| | | return true |
| | | end |
| | | end |
| | | |
| | | local function inv_change(pos, player, count) |
| | | 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 |
| | | return count |
| | | end |
| | | |
| | | function technic.machine_inventory_put(pos, listname, index, stack, player) |
| | | return inv_change(pos, player, stack:get_count()) |
| | | end |
| | | |
| | | function technic.machine_inventory_take(pos, listname, index, stack, player) |
| | | return inv_change(pos, player, stack:get_count()) |
| | | end |
| | | |
| | | function technic.machine_inventory_move(pos, from_list, from_index, |
| | | to_list, to_index, count, player) |
| | | return inv_change(pos, player, count) |
| | | end |
| | | |
| | |
| | | inv:set_size("upgrade1", 1) |
| | | inv:set_size("upgrade2", 1) |
| | | end, |
| | | can_dig = function(pos, player) |
| | | local meta = minetest.get_meta(pos); |
| | | 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")) |
| | | return false |
| | | else |
| | | return true |
| | | end |
| | | end, |
| | | can_dig = technic.machine_can_dig, |
| | | allow_metadata_inventory_put = technic.machine_inventory_put, |
| | | allow_metadata_inventory_take = technic.machine_inventory_take, |
| | | allow_metadata_inventory_move = technic.machine_inventory_move, |
| | | }) |
| | | |
| | | minetest.register_node("technic:"..ltier.."_electric_furnace_active", { |
| | |
| | | inv:set_size("upgrade1", 1) |
| | | inv:set_size("upgrade2", 1) |
| | | end, |
| | | can_dig = function(pos, player) |
| | | local meta = minetest.get_meta(pos); |
| | | 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")) |
| | | return false |
| | | else |
| | | return true |
| | | end |
| | | end, |
| | | -- These three makes sure upgrades are not moved in or out while the furnace is active. |
| | | allow_metadata_inventory_put = function(pos, listname, index, stack, player) |
| | | if listname == "src" or listname == "dst" then |
| | | return stack:get_stack_max() |
| | | else |
| | | return 0 -- Disallow the move |
| | | end |
| | | end, |
| | | allow_metadata_inventory_take = function(pos, listname, index, stack, player) |
| | | if listname == "src" or listname == "dst" then |
| | | return stack:get_stack_max() |
| | | else |
| | | return 0 -- Disallow the move |
| | | end |
| | | end, |
| | | allow_metadata_inventory_move = function(pos, from_list, to_list, to_list, to_index, count, player) |
| | | return 0 |
| | | end, |
| | | can_dig = technic.machine_can_dig, |
| | | allow_metadata_inventory_put = technic.machine_inventory_put, |
| | | allow_metadata_inventory_take = technic.machine_inventory_take, |
| | | allow_metadata_inventory_move = technic.machine_inventory_move, |
| | | }) |
| | | |
| | | minetest.register_abm({ |
| | |
| | | local inv = meta:get_inventory() |
| | | inv:set_size("src", 1) |
| | | end, |
| | | can_dig = function(pos, player) |
| | | local meta = minetest.get_meta(pos) |
| | | local inv = meta:get_inventory() |
| | | if not inv:is_empty("src") then |
| | | minetest.chat_send_player(player:get_player_name(), |
| | | S("Machine cannot be removed because it is not empty")) |
| | | return false |
| | | else |
| | | return true |
| | | end |
| | | end, |
| | | can_dig = technic.machine_can_dig, |
| | | allow_metadata_inventory_put = technic.machine_inventory_put, |
| | | allow_metadata_inventory_take = technic.machine_inventory_take, |
| | | allow_metadata_inventory_move = technic.machine_inventory_move, |
| | | }) |
| | | |
| | | minetest.register_node("technic:"..ltier.."_generator_active", { |
| | | description = desc, |
| | | tiles = {"technic_"..ltier.."_generator_top.png", "technic_machine_bottom.png", |
| | |
| | | legacy_facedir_simple = true, |
| | | sounds = default.node_sound_wood_defaults(), |
| | | drop = "technic:"..ltier.."_generator", |
| | | can_dig = function(pos, player) |
| | | local meta = minetest.get_meta(pos) |
| | | local inv = meta:get_inventory() |
| | | if not inv:is_empty("src") then |
| | | minetest.chat_send_player(player:get_player_name(), |
| | | S("Machine cannot be removed because it is not empty")) |
| | | return false |
| | | else |
| | | return true |
| | | end |
| | | end, |
| | | can_dig = technic.machine_can_dig, |
| | | allow_metadata_inventory_put = technic.machine_inventory_put, |
| | | allow_metadata_inventory_take = technic.machine_inventory_take, |
| | | allow_metadata_inventory_move = technic.machine_inventory_move, |
| | | }) |
| | | minetest.register_abm({ |
| | | nodenames = {"technic:"..ltier.."_generator", "technic:"..ltier.."_generator_active"}, |
| | |
| | | inv:set_size("upgrade1", 1) |
| | | inv:set_size("upgrade2", 1) |
| | | end, |
| | | can_dig = function(pos,player) |
| | | local meta = minetest.get_meta(pos) |
| | | 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")) |
| | | return false |
| | | else |
| | | return true |
| | | end |
| | | end, |
| | | can_dig = technic.machine_can_dig, |
| | | allow_metadata_inventory_put = technic.machine_inventory_put, |
| | | allow_metadata_inventory_take = technic.machine_inventory_take, |
| | | allow_metadata_inventory_move = technic.machine_inventory_move, |
| | | }) |
| | | |
| | | minetest.register_node("technic:"..ltier.."_grinder_active",{ |
| | |
| | | legacy_facedir_simple = true, |
| | | sounds = default.node_sound_wood_defaults(), |
| | | tube = data.tube and tube or nil, |
| | | can_dig = function(pos, player) |
| | | local meta = minetest.get_meta(pos) |
| | | 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")) |
| | | return false |
| | | else |
| | | return true |
| | | end |
| | | end, |
| | | -- These three makes sure upgrades are not moved in or out while the grinder is active. |
| | | allow_metadata_inventory_put = function(pos, listname, index, stack, player) |
| | | if listname == "src" or listname == "dst" then |
| | | return stack:get_stack_max() |
| | | else |
| | | return 0 -- Disallow the move |
| | | end |
| | | end, |
| | | allow_metadata_inventory_take = function(pos, listname, index, stack, player) |
| | | if listname == "src" or listname == "dst" then |
| | | return stack:get_stack_max() |
| | | else |
| | | return 0 -- Disallow the move |
| | | end |
| | | end, |
| | | allow_metadata_inventory_move = function(pos, from_list, to_list, to_list, to_index, count, player) |
| | | return 0 |
| | | end, |
| | | can_dig = technic.machine_can_dig, |
| | | allow_metadata_inventory_put = technic.machine_inventory_put, |
| | | allow_metadata_inventory_take = technic.machine_inventory_take, |
| | | allow_metadata_inventory_move = technic.machine_inventory_move, |
| | | }) |
| | | |
| | | minetest.register_abm({ |