mirror of
https://github.com/minetest-mods/technic.git
synced 2025-01-03 03:07:36 +01:00
Externalize common functions and protect inventories
This commit is contained in:
parent
76a8acbe5b
commit
0809dd747e
@ -33,6 +33,7 @@ Rubber Fiber = Fibra de Hule
|
|||||||
|
|
||||||
## Machine misc
|
## Machine misc
|
||||||
Machine cannot be removed because it is not empty = La maquina no puede removerse porque no esta vacia
|
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)
|
# $1: Machine name (Includes tier)
|
||||||
%s Active = %s Activo
|
%s Active = %s Activo
|
||||||
%s Idle = %s Quieto
|
%s Idle = %s Quieto
|
||||||
|
@ -29,6 +29,7 @@ Rubber Fiber = Fibra di gomma
|
|||||||
|
|
||||||
## Machine misc
|
## Machine misc
|
||||||
Machine cannot be removed because it is not empty = La macchina non può essere rimossa perchè non è vuota
|
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)
|
# $1: Machine name (Includes tier)
|
||||||
%s Active = %s Attivo
|
%s Active = %s Attivo
|
||||||
%s Disabled = %s Disabilitato
|
%s Disabled = %s Disabilitato
|
||||||
|
@ -32,6 +32,7 @@ Rubber Fiber =
|
|||||||
|
|
||||||
## Machine misc
|
## Machine misc
|
||||||
Machine cannot be removed because it is not empty =
|
Machine cannot be removed because it is not empty =
|
||||||
|
Inventory move disallowed due to protection =
|
||||||
# $1: Machine name (Includes tier)
|
# $1: Machine name (Includes tier)
|
||||||
%s Active =
|
%s Active =
|
||||||
%s Disabled =
|
%s Disabled =
|
||||||
@ -159,4 +160,3 @@ Single node. =
|
|||||||
Sonic Screwdriver =
|
Sonic Screwdriver =
|
||||||
Tree Tap =
|
Tree Tap =
|
||||||
|
|
||||||
|
|
||||||
|
@ -75,17 +75,10 @@ minetest.register_node("technic:hv_nuclear_reactor_core", {
|
|||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
inv:set_size("src", 6)
|
inv:set_size("src", 6)
|
||||||
end,
|
end,
|
||||||
can_dig = function(pos, player)
|
can_dig = technic.machine_can_dig,
|
||||||
local meta = minetest.get_meta(pos);
|
allow_metadata_inventory_put = technic.machine_inventory_put,
|
||||||
local inv = meta:get_inventory()
|
allow_metadata_inventory_take = technic.machine_inventory_take,
|
||||||
if not inv:is_empty("src") then
|
allow_metadata_inventory_move = technic.machine_inventory_move,
|
||||||
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,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node("technic:hv_nuclear_reactor_core_active", {
|
minetest.register_node("technic:hv_nuclear_reactor_core_active", {
|
||||||
@ -103,17 +96,10 @@ minetest.register_node("technic:hv_nuclear_reactor_core_active", {
|
|||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = nodebox
|
fixed = nodebox
|
||||||
},
|
},
|
||||||
can_dig = function(pos, player)
|
can_dig = technic.machine_can_dig,
|
||||||
local meta = minetest.get_meta(pos);
|
allow_metadata_inventory_put = technic.machine_inventory_put,
|
||||||
local inv = meta:get_inventory()
|
allow_metadata_inventory_take = technic.machine_inventory_take,
|
||||||
if not inv:is_empty("src") then
|
allow_metadata_inventory_move = technic.machine_inventory_move,
|
||||||
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 check_reactor_structure = function(pos)
|
local check_reactor_structure = function(pos)
|
||||||
|
@ -150,17 +150,10 @@ minetest.register_node("technic:cnc", {
|
|||||||
inv:set_size("src", 1)
|
inv:set_size("src", 1)
|
||||||
inv:set_size("dst", 4)
|
inv:set_size("dst", 4)
|
||||||
end,
|
end,
|
||||||
can_dig = function(pos,player)
|
can_dig = technic.machine_can_dig,
|
||||||
local meta = minetest.get_meta(pos);
|
allow_metadata_inventory_put = technic.machine_inventory_put,
|
||||||
local inv = meta:get_inventory()
|
allow_metadata_inventory_take = technic.machine_inventory_take,
|
||||||
if not inv:is_empty("src") or not inv:is_empty("dst") then
|
allow_metadata_inventory_move = technic.machine_inventory_move,
|
||||||
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,
|
|
||||||
on_receive_fields = form_handler,
|
on_receive_fields = form_handler,
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -172,16 +165,10 @@ minetest.register_node("technic:cnc_active", {
|
|||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
groups = {cracky=2, not_in_creative_inventory=1},
|
groups = {cracky=2, not_in_creative_inventory=1},
|
||||||
legacy_facedir_simple = true,
|
legacy_facedir_simple = true,
|
||||||
can_dig = function(pos,player)
|
can_dig = technic.machine_can_dig,
|
||||||
local meta = minetest.get_meta(pos);
|
allow_metadata_inventory_put = technic.machine_inventory_put,
|
||||||
local inv = meta:get_inventory()
|
allow_metadata_inventory_take = technic.machine_inventory_take,
|
||||||
if not inv:is_empty("src") or not inv:is_empty("dst") then
|
allow_metadata_inventory_move = technic.machine_inventory_move,
|
||||||
minetest.chat_send_player(player:get_player_name(),
|
|
||||||
S("Machine cannot be removed because it is not empty"))
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
return true
|
|
||||||
end,
|
|
||||||
on_receive_fields = form_handler,
|
on_receive_fields = form_handler,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -14,8 +14,9 @@ minetest.register_craft({
|
|||||||
|
|
||||||
minetest.register_node("technic:coal_alloy_furnace", {
|
minetest.register_node("technic:coal_alloy_furnace", {
|
||||||
description = S("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",
|
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_front.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",
|
paramtype2 = "facedir",
|
||||||
groups = {cracky=2},
|
groups = {cracky=2},
|
||||||
legacy_facedir_simple = true,
|
legacy_facedir_simple = true,
|
||||||
@ -30,35 +31,27 @@ minetest.register_node("technic:coal_alloy_furnace", {
|
|||||||
inv:set_size("src2", 1)
|
inv:set_size("src2", 1)
|
||||||
inv:set_size("dst", 4)
|
inv:set_size("dst", 4)
|
||||||
end,
|
end,
|
||||||
can_dig = function(pos,player)
|
can_dig = technic.machine_can_dig,
|
||||||
local meta = minetest.env:get_meta(pos);
|
allow_metadata_inventory_put = technic.machine_inventory_put,
|
||||||
local inv = meta:get_inventory()
|
allow_metadata_inventory_take = technic.machine_inventory_take,
|
||||||
if not (inv:is_empty("fuel") or inv:is_empty("dst") or inv:is_empty("src") or inv:is_empty("src2") )then
|
allow_metadata_inventory_move = technic.machine_inventory_move,
|
||||||
return false
|
|
||||||
end
|
|
||||||
return true
|
|
||||||
end,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node("technic:coal_alloy_furnace_active", {
|
minetest.register_node("technic:coal_alloy_furnace_active", {
|
||||||
description = "Alloy Furnace",
|
description = "Alloy Furnace",
|
||||||
tiles = {"technic_coal_alloy_furnace_top.png", "technic_coal_alloy_furnace_bottom.png", "technic_coal_alloy_furnace_side.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_front_active.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",
|
paramtype2 = "facedir",
|
||||||
light_source = 8,
|
light_source = 8,
|
||||||
drop = "technic:coal_alloy_furnace",
|
drop = "technic:coal_alloy_furnace",
|
||||||
groups = {cracky=2, not_in_creative_inventory=1},
|
groups = {cracky=2, not_in_creative_inventory=1},
|
||||||
legacy_facedir_simple = true,
|
legacy_facedir_simple = true,
|
||||||
sounds = default.node_sound_stone_defaults(),
|
sounds = default.node_sound_stone_defaults(),
|
||||||
can_dig = function(pos,player)
|
can_dig = technic.machine_can_dig,
|
||||||
local meta = minetest.env:get_meta(pos);
|
allow_metadata_inventory_put = technic.machine_inventory_put,
|
||||||
local inv = meta:get_inventory()
|
allow_metadata_inventory_take = technic.machine_inventory_take,
|
||||||
if not (inv:is_empty("fuel") or inv:is_empty("dst") or
|
allow_metadata_inventory_move = technic.machine_inventory_move,
|
||||||
inv:is_empty("src") or inv:is_empty("src2")) then
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
return true
|
|
||||||
end,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
|
@ -68,17 +68,10 @@ minetest.register_node("technic:compressor", {
|
|||||||
inv:set_size("src", 1)
|
inv:set_size("src", 1)
|
||||||
inv:set_size("dst", 4)
|
inv:set_size("dst", 4)
|
||||||
end,
|
end,
|
||||||
can_dig = function(pos,player)
|
can_dig = technic.machine_can_dig,
|
||||||
local meta = minetest.get_meta(pos)
|
allow_metadata_inventory_put = technic.machine_inventory_put,
|
||||||
local inv = meta:get_inventory()
|
allow_metadata_inventory_take = technic.machine_inventory_take,
|
||||||
if not inv:is_empty("src") or not inv:is_empty("dst") then
|
allow_metadata_inventory_move = technic.machine_inventory_move,
|
||||||
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,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node("technic:compressor_active", {
|
minetest.register_node("technic:compressor_active", {
|
||||||
@ -90,17 +83,10 @@ minetest.register_node("technic:compressor_active", {
|
|||||||
groups = {cracky=2, not_in_creative_inventory=1},
|
groups = {cracky=2, not_in_creative_inventory=1},
|
||||||
legacy_facedir_simple = true,
|
legacy_facedir_simple = true,
|
||||||
sounds = default.node_sound_wood_defaults(),
|
sounds = default.node_sound_wood_defaults(),
|
||||||
can_dig = function(pos,player)
|
can_dig = technic.machine_can_dig,
|
||||||
local meta = minetest.get_meta(pos);
|
allow_metadata_inventory_put = technic.machine_inventory_put,
|
||||||
local inv = meta:get_inventory()
|
allow_metadata_inventory_take = technic.machine_inventory_take,
|
||||||
if not inv:is_empty("src") or not inv:is_empty("dst") then
|
allow_metadata_inventory_move = technic.machine_inventory_move,
|
||||||
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,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
|
@ -74,17 +74,10 @@ minetest.register_node("technic:extractor", {
|
|||||||
inv:set_size("src", 1)
|
inv:set_size("src", 1)
|
||||||
inv:set_size("dst", 4)
|
inv:set_size("dst", 4)
|
||||||
end,
|
end,
|
||||||
can_dig = function(pos,player)
|
can_dig = technic.machine_can_dig,
|
||||||
local meta = minetest.get_meta(pos);
|
allow_metadata_inventory_put = technic.machine_inventory_put,
|
||||||
local inv = meta:get_inventory()
|
allow_metadata_inventory_take = technic.machine_inventory_take,
|
||||||
if not inv:is_empty("src") or not inv:is_empty("dst") then
|
allow_metadata_inventory_move = technic.machine_inventory_move,
|
||||||
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,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node("technic:extractor_active", {
|
minetest.register_node("technic:extractor_active", {
|
||||||
@ -96,17 +89,10 @@ minetest.register_node("technic:extractor_active", {
|
|||||||
groups = {cracky=2, not_in_creative_inventory=1},
|
groups = {cracky=2, not_in_creative_inventory=1},
|
||||||
legacy_facedir_simple = true,
|
legacy_facedir_simple = true,
|
||||||
sounds = default.node_sound_wood_defaults(),
|
sounds = default.node_sound_wood_defaults(),
|
||||||
can_dig = function(pos,player)
|
can_dig = technic.machine_can_dig,
|
||||||
local meta = minetest.get_meta(pos);
|
allow_metadata_inventory_put = technic.machine_inventory_put,
|
||||||
local inv = meta:get_inventory()
|
allow_metadata_inventory_take = technic.machine_inventory_take,
|
||||||
if not inv:is_empty("src") or not inv:is_empty("dst") then
|
allow_metadata_inventory_move = technic.machine_inventory_move,
|
||||||
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,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
|
@ -33,16 +33,9 @@ minetest.register_node("technic:tool_workshop", {
|
|||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
inv:set_size("src", 1)
|
inv:set_size("src", 1)
|
||||||
end,
|
end,
|
||||||
can_dig = function(pos,player)
|
can_dig = technic.machine_can_dig,
|
||||||
local meta = minetest.get_meta(pos);
|
allow_metadata_inventory_put = technic.machine_inventory_put,
|
||||||
local inv = meta:get_inventory()
|
allow_metadata_inventory_take = technic.machine_inventory_take,
|
||||||
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,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
|
@ -74,17 +74,22 @@ minetest.register_node("technic:constructor_mk1_off", {
|
|||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
return inv:is_empty("slot1")
|
return inv:is_empty("slot1")
|
||||||
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_mk1_on", {
|
minetest.register_node("technic:constructor_mk1_on", {
|
||||||
description = "Constructor MK1",
|
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",
|
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"},
|
"technic_constructor_back.png","technic_constructor_front_on.png"},
|
||||||
is_ground_content = true,
|
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,mesecon = 2,not_in_creative_inventory=1},
|
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,mesecon = 2,not_in_creative_inventory=1},
|
||||||
mesecons= {effector={action_off=mk1_off}},
|
mesecons= {effector={action_off=mk1_off}},
|
||||||
sounds = default.node_sound_stone_defaults(),
|
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,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
@ -147,13 +152,15 @@ minetest.register_node("technic:constructor_mk2_off", {
|
|||||||
inv:set_size("slot1", 1)
|
inv:set_size("slot1", 1)
|
||||||
inv:set_size("slot2", 1)
|
inv:set_size("slot2", 1)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
can_dig = function(pos,player)
|
can_dig = function(pos,player)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
if inv:is_empty("slot1")==false or inv:is_empty("slot2")==false then return false end
|
if inv:is_empty("slot1")==false or inv:is_empty("slot2")==false then return false end
|
||||||
return true
|
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", {
|
minetest.register_node("technic:constructor_mk2_on", {
|
||||||
@ -163,8 +170,11 @@ minetest.register_node("technic:constructor_mk2_on", {
|
|||||||
is_ground_content = true,
|
is_ground_content = true,
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon = 2, not_in_creative_inventory=1},
|
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(),
|
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,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
@ -224,10 +234,9 @@ minetest.register_node("technic:constructor_mk3_off", {
|
|||||||
description = "Constructor MK3",
|
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",
|
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"},
|
"technic_constructor_back.png","technic_constructor_front_off.png"},
|
||||||
is_ground_content = true,
|
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon = 2},
|
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(),
|
sounds = default.node_sound_stone_defaults(),
|
||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
@ -258,6 +267,9 @@ minetest.register_node("technic:constructor_mk3_off", {
|
|||||||
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
|
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
|
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_mk3_on", {
|
minetest.register_node("technic:constructor_mk3_on", {
|
||||||
@ -267,8 +279,11 @@ minetest.register_node("technic:constructor_mk3_on", {
|
|||||||
is_ground_content = true,
|
is_ground_content = true,
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon = 2,not_in_creative_inventory=1},
|
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(),
|
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,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,7 +1,3 @@
|
|||||||
minetest.register_craftitem("technic:injector", {
|
|
||||||
description = "Injector",
|
|
||||||
stack_max = 99,
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = 'technic:injector 1',
|
output = 'technic:injector 1',
|
||||||
@ -39,15 +35,17 @@ minetest.register_node("technic:injector", {
|
|||||||
return inv:is_empty("main")
|
return inv:is_empty("main")
|
||||||
end,
|
end,
|
||||||
on_receive_fields = function(pos, formanme, fields, sender)
|
on_receive_fields = function(pos, formanme, fields, sender)
|
||||||
local meta = minetest.env:get_meta(pos)
|
local meta = minetest.env:get_meta(pos)
|
||||||
local mode=meta:get_string("mode")
|
local mode=meta:get_string("mode")
|
||||||
if fields.mode then
|
if fields.mode then
|
||||||
if mode=="single items" then mode="whole stacks"
|
if mode == "single items" then
|
||||||
else mode="single items"
|
mode = "whole stacks"
|
||||||
|
else
|
||||||
|
mode = "single items"
|
||||||
|
end
|
||||||
|
meta:set_string("mode", mode)
|
||||||
end
|
end
|
||||||
local mode=meta:set_string("mode",mode)
|
meta:set_string("formspec",
|
||||||
end
|
|
||||||
meta:set_string("formspec",
|
|
||||||
"invsize[8,9;]"..
|
"invsize[8,9;]"..
|
||||||
"label[0,0;Injector]"..
|
"label[0,0;Injector]"..
|
||||||
"button[0,1;.8,.8;mode;]"..
|
"button[0,1;.8,.8;mode;]"..
|
||||||
@ -55,13 +53,15 @@ minetest.register_node("technic:injector", {
|
|||||||
"list[current_name;main;0,2;8,2;]"..
|
"list[current_name;main;0,2;8,2;]"..
|
||||||
"list[current_player;main;0,5;8,4;]")
|
"list[current_player;main;0,5;8,4;]")
|
||||||
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_abm({
|
minetest.register_abm({
|
||||||
nodenames = {"technic:injector"},
|
nodenames = {"technic:injector"},
|
||||||
interval = 1,
|
interval = 1,
|
||||||
chance = 1,
|
chance = 1,
|
||||||
|
|
||||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||||
local pos1={}
|
local pos1={}
|
||||||
pos1.x = pos.x
|
pos1.x = pos.x
|
||||||
|
@ -134,18 +134,10 @@ function technic.register_alloy_furnace(data)
|
|||||||
inv:set_size("upgrade1", 1)
|
inv:set_size("upgrade1", 1)
|
||||||
inv:set_size("upgrade2", 1)
|
inv:set_size("upgrade2", 1)
|
||||||
end,
|
end,
|
||||||
can_dig = function(pos, player)
|
can_dig = technic.machine_can_dig,
|
||||||
local meta = minetest.get_meta(pos);
|
allow_metadata_inventory_put = technic.machine_inventory_put,
|
||||||
local inv = meta:get_inventory()
|
allow_metadata_inventory_take = technic.machine_inventory_take,
|
||||||
if not inv:is_empty("src") or not inv:is_empty("dst") or
|
allow_metadata_inventory_move = technic.machine_inventory_move,
|
||||||
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,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node("technic:"..ltier.."_alloy_furnace_active",{
|
minetest.register_node("technic:"..ltier.."_alloy_furnace_active",{
|
||||||
@ -163,36 +155,10 @@ function technic.register_alloy_furnace(data)
|
|||||||
tube = data.tube and tube or nil,
|
tube = data.tube and tube or nil,
|
||||||
legacy_facedir_simple = true,
|
legacy_facedir_simple = true,
|
||||||
sounds = default.node_sound_stone_defaults(),
|
sounds = default.node_sound_stone_defaults(),
|
||||||
can_dig = function(pos, player)
|
can_dig = technic.machine_can_dig,
|
||||||
local meta = minetest.get_meta(pos);
|
allow_metadata_inventory_put = technic.machine_inventory_put,
|
||||||
local inv = meta:get_inventory()
|
allow_metadata_inventory_take = technic.machine_inventory_take,
|
||||||
if not inv:is_empty("src") or not inv:is_empty("dst") or
|
allow_metadata_inventory_move = technic.machine_inventory_move,
|
||||||
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,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
|
@ -47,17 +47,10 @@ function technic.register_battery_box(data)
|
|||||||
inv:set_size("src", 1)
|
inv:set_size("src", 1)
|
||||||
inv:set_size("dst", 1)
|
inv:set_size("dst", 1)
|
||||||
end,
|
end,
|
||||||
can_dig = function(pos, player)
|
can_dig = technic.machine_can_dig,
|
||||||
local meta = minetest.get_meta(pos);
|
allow_metadata_inventory_put = technic.machine_inventory_put,
|
||||||
local inv = meta:get_inventory()
|
allow_metadata_inventory_take = technic.machine_inventory_take,
|
||||||
if not inv:is_empty("src") or not inv:is_empty("dst") then
|
allow_metadata_inventory_move = technic.machine_inventory_move,
|
||||||
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,
|
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
|
|
||||||
|
local S = technic.getter
|
||||||
|
|
||||||
function technic.handle_machine_upgrades(meta)
|
function technic.handle_machine_upgrades(meta)
|
||||||
-- Get the names of the upgrades
|
-- Get the names of the upgrades
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
@ -109,3 +111,39 @@ function technic.handle_machine_pipeworks(pos, tube_upgrade)
|
|||||||
meta:set_int("tube_time", tube_time)
|
meta:set_int("tube_time", tube_time)
|
||||||
end
|
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
|
||||||
|
|
||||||
|
@ -69,18 +69,10 @@ function technic.register_electric_furnace(data)
|
|||||||
inv:set_size("upgrade1", 1)
|
inv:set_size("upgrade1", 1)
|
||||||
inv:set_size("upgrade2", 1)
|
inv:set_size("upgrade2", 1)
|
||||||
end,
|
end,
|
||||||
can_dig = function(pos, player)
|
can_dig = technic.machine_can_dig,
|
||||||
local meta = minetest.get_meta(pos);
|
allow_metadata_inventory_put = technic.machine_inventory_put,
|
||||||
local inv = meta:get_inventory()
|
allow_metadata_inventory_take = technic.machine_inventory_take,
|
||||||
if not inv:is_empty("src") or not inv:is_empty("dst") or
|
allow_metadata_inventory_move = technic.machine_inventory_move,
|
||||||
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,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node("technic:"..ltier.."_electric_furnace_active", {
|
minetest.register_node("technic:"..ltier.."_electric_furnace_active", {
|
||||||
@ -110,36 +102,10 @@ function technic.register_electric_furnace(data)
|
|||||||
inv:set_size("upgrade1", 1)
|
inv:set_size("upgrade1", 1)
|
||||||
inv:set_size("upgrade2", 1)
|
inv:set_size("upgrade2", 1)
|
||||||
end,
|
end,
|
||||||
can_dig = function(pos, player)
|
can_dig = technic.machine_can_dig,
|
||||||
local meta = minetest.get_meta(pos);
|
allow_metadata_inventory_put = technic.machine_inventory_put,
|
||||||
local inv = meta:get_inventory()
|
allow_metadata_inventory_take = technic.machine_inventory_take,
|
||||||
if not inv:is_empty("src") or not inv:is_empty("dst") or
|
allow_metadata_inventory_move = technic.machine_inventory_move,
|
||||||
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,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
|
@ -31,18 +31,12 @@ function technic.register_generator(data)
|
|||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
inv:set_size("src", 1)
|
inv:set_size("src", 1)
|
||||||
end,
|
end,
|
||||||
can_dig = function(pos, player)
|
can_dig = technic.machine_can_dig,
|
||||||
local meta = minetest.get_meta(pos)
|
allow_metadata_inventory_put = technic.machine_inventory_put,
|
||||||
local inv = meta:get_inventory()
|
allow_metadata_inventory_take = technic.machine_inventory_take,
|
||||||
if not inv:is_empty("src") then
|
allow_metadata_inventory_move = technic.machine_inventory_move,
|
||||||
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,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node("technic:"..ltier.."_generator_active", {
|
minetest.register_node("technic:"..ltier.."_generator_active", {
|
||||||
description = desc,
|
description = desc,
|
||||||
tiles = {"technic_"..ltier.."_generator_top.png", "technic_machine_bottom.png",
|
tiles = {"technic_"..ltier.."_generator_top.png", "technic_machine_bottom.png",
|
||||||
@ -54,17 +48,10 @@ function technic.register_generator(data)
|
|||||||
legacy_facedir_simple = true,
|
legacy_facedir_simple = true,
|
||||||
sounds = default.node_sound_wood_defaults(),
|
sounds = default.node_sound_wood_defaults(),
|
||||||
drop = "technic:"..ltier.."_generator",
|
drop = "technic:"..ltier.."_generator",
|
||||||
can_dig = function(pos, player)
|
can_dig = technic.machine_can_dig,
|
||||||
local meta = minetest.get_meta(pos)
|
allow_metadata_inventory_put = technic.machine_inventory_put,
|
||||||
local inv = meta:get_inventory()
|
allow_metadata_inventory_take = technic.machine_inventory_take,
|
||||||
if not inv:is_empty("src") then
|
allow_metadata_inventory_move = technic.machine_inventory_move,
|
||||||
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,
|
|
||||||
})
|
})
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames = {"technic:"..ltier.."_generator", "technic:"..ltier.."_generator_active"},
|
nodenames = {"technic:"..ltier.."_generator", "technic:"..ltier.."_generator_active"},
|
||||||
|
@ -64,18 +64,10 @@ function technic.register_grinder(data)
|
|||||||
inv:set_size("upgrade1", 1)
|
inv:set_size("upgrade1", 1)
|
||||||
inv:set_size("upgrade2", 1)
|
inv:set_size("upgrade2", 1)
|
||||||
end,
|
end,
|
||||||
can_dig = function(pos,player)
|
can_dig = technic.machine_can_dig,
|
||||||
local meta = minetest.get_meta(pos)
|
allow_metadata_inventory_put = technic.machine_inventory_put,
|
||||||
local inv = meta:get_inventory()
|
allow_metadata_inventory_take = technic.machine_inventory_take,
|
||||||
if not inv:is_empty("src") or not inv:is_empty("dst") or
|
allow_metadata_inventory_move = technic.machine_inventory_move,
|
||||||
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,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node("technic:"..ltier.."_grinder_active",{
|
minetest.register_node("technic:"..ltier.."_grinder_active",{
|
||||||
@ -88,36 +80,10 @@ function technic.register_grinder(data)
|
|||||||
legacy_facedir_simple = true,
|
legacy_facedir_simple = true,
|
||||||
sounds = default.node_sound_wood_defaults(),
|
sounds = default.node_sound_wood_defaults(),
|
||||||
tube = data.tube and tube or nil,
|
tube = data.tube and tube or nil,
|
||||||
can_dig = function(pos, player)
|
can_dig = technic.machine_can_dig,
|
||||||
local meta = minetest.get_meta(pos)
|
allow_metadata_inventory_put = technic.machine_inventory_put,
|
||||||
local inv = meta:get_inventory()
|
allow_metadata_inventory_take = technic.machine_inventory_take,
|
||||||
if not inv:is_empty("src") or not inv:is_empty("dst") or
|
allow_metadata_inventory_move = technic.machine_inventory_move,
|
||||||
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,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
|
Loading…
Reference in New Issue
Block a user