Re-added Deployer

Initial code of MV furnace
This commit is contained in:
RealBadAngel 2013-02-01 00:28:22 +01:00
parent 86f8e17695
commit 061e6bbadc
3 changed files with 246 additions and 43 deletions

@ -8,13 +8,61 @@ minetest.register_craft({
} }
}) })
deployer_signal_on = function(pos, node)
local pos1={}
pos1.x=pos.x
pos1.y=pos.y
pos1.z=pos.z
if node.param2==3 then pos1.x=pos1.x+1 end
if node.param2==2 then pos1.z=pos1.z+1 end
if node.param2==1 then pos1.x=pos1.x-1 end
if node.param2==0 then pos1.z=pos1.z-1 end
if node.name == "technic:deployer_off" then
hacky_swap_node(pos,"technic:deployer_on")
nodeupdate(pos)
local meta = minetest.env:get_meta(pos);
local inv = meta:get_inventory()
local i=0
for _,stack in ipairs(inv:get_list("main")) do
i=i+1
if stack:get_name() ~=nil then
node1={name=stack:get_name(), param1=0, param2=node.param2}
minetest.env:place_node(pos1,node1)
stack:take_item(1);
inv:set_stack("main", i, stack)
return
end
end
end
end
deployer_signal_off = function(pos, node)
if node.name == "technic:deployer_on" then
hacky_swap_node(pos,"technic:deployer_off")
nodeupdate(pos)
end
end
minetest.register_node("technic:deployer_off", { minetest.register_node("technic:deployer_off", {
description = "Deployer", description = "Deployer",
tile_images = {"technic_deployer_top.png","technic_deployer_bottom.png","technic_deployer_side2.png","technic_deployer_side1.png", tile_images = {"technic_deployer_top.png","technic_deployer_bottom.png","technic_deployer_side2.png","technic_deployer_side1.png",
"technic_deployer_back.png","technic_deployer_front_off.png"}, "technic_deployer_back.png","technic_deployer_front_off.png"},
is_ground_content = true, is_ground_content = true,
paramtype2 = "facedir", paramtype2 = "facedir",
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon_receptor_off = 1, mesecon_effector_off = 1, mesecon = 2,tubedevice=1}, groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon = 2,tubedevice=1, tubedevice_receiver=1},
mesecons = {effector={action_on=deployer_signal_on}},
tube={insert_object=function(pos,node,stack,direction)
local meta=minetest.env:get_meta(pos)
local inv=meta:get_inventory()
return inv:add_item("main",stack)
end,
can_insert=function(pos,node,stack,direction)
local meta=minetest.env:get_meta(pos)
local inv=meta:get_inventory()
return inv:room_for_item("main",stack)
end,
input_inventory="main"},
sounds = default.node_sound_stone_defaults(), sounds = default.node_sound_stone_defaults(),
on_construct = function(pos) on_construct = function(pos)
local meta = minetest.env:get_meta(pos) local meta = minetest.env:get_meta(pos)
@ -46,46 +94,7 @@ minetest.register_node("technic:deployer_on", {
is_ground_content = true, is_ground_content = true,
paramtype2 = "facedir", paramtype2 = "facedir",
tubelike=1, tubelike=1,
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon_receptor_off = 1, mesecon_effector_off = 1, mesecon = 2,tubedevice=1,not_in_creative_inventory=1}, groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon = 2,tubedevice=1, tubedevice_receiver=1,not_in_creative_inventory=1},
mesecons = {effector={action_off=deployer_signal_off}},
sounds = default.node_sound_stone_defaults(), sounds = default.node_sound_stone_defaults(),
}) })
mesecon:register_on_signal_on(function(pos, node)
local pos1={}
pos1.x=pos.x
pos1.y=pos.y
pos1.z=pos.z
if node.param2==3 then pos1.x=pos1.x+1 end
if node.param2==2 then pos1.z=pos1.z+1 end
if node.param2==1 then pos1.x=pos1.x-1 end
if node.param2==0 then pos1.z=pos1.z-1 end
if node.name == "technic:deployer_off" then
hacky_swap_node(pos,"technic:deployer_on")
nodeupdate(pos)
local meta = minetest.env:get_meta(pos);
local inv = meta:get_inventory()
print (dump(inv))
for _,stack in ipairs(inv:get_list("main")) do
print (dump(stack:get_name()))
if stack:get_name() ~=nil then
node1={name=stack:get_name(), param1=0, param2=node.param2}
minetest.env:place_node(pos1,node1)
return
end
end
end
end)
mesecon:register_on_signal_off(function(pos, node)
if node.name == "technic:deployer_on" then
hacky_swap_node(pos,"technic:deployer_off")
nodeupdate(pos)
end
end)
mesecon:register_effector("technic:deployer_on", "technic:deployer_off")

@ -0,0 +1,193 @@
minetest.register_craft({
output = 'technic:mv_electric_furnace',
recipe = {
{'technic:stainless_steel_ingot', 'technic:electric_furnace', 'technic:stainless_steel_ingot'},
{'pipeworks:tube_000000', 'technic:mv_transformer', 'pipeworks:tube_000000'},
{'technic:stainless_steel_ingot', 'technic:mv_cable', 'technic:stainless_steel_ingot'},
}
})
mv_electric_furnace_formspec =
"invsize[8,9;]"..
"image[1,1;1,2;technic_power_meter_bg.png]"..
"list[current_name;src;3,1;1,1;]"..
"list[current_name;dst;5,1;2,2;]"..
"list[current_player;main;0,5;8,4;]"..
"label[0,0;MV Electric Furnace]"..
"label[1,3;Power level]"
minetest.register_node("technic:mv_electric_furnace", {
description = "MV Electric furnace",
tiles = {"technic_mv_electric_furnace_top.png", "technic_mv_electric_furnace_bottom.png", "technic_mv_electric_furnace_side.png",
"technic_mv_electric_furnace_side_tube.png", "technic_mv_electric_furnace_side_tube.png", "technic_mv_electric_furnace_front.png"},
paramtype2 = "facedir",
groups = {cracky=2, tubedevice=1,tubedevice_receiver=1,},
tube={insert_object=function(pos,node,stack,direction)
local meta=minetest.env:get_meta(pos)
local inv=meta:get_inventory()
return inv:add_item("src",stack)
end,
can_insert=function(pos,node,stack,direction)
local meta=minetest.env:get_meta(pos)
local inv=meta:get_inventory()
return inv:room_for_item("src",stack)
end,
},
legacy_facedir_simple = true,
sounds = default.node_sound_stone_defaults(),
technic_power_machine=1,
internal_EU_buffer=0;
interal_EU_buffer_size=2000;
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
meta:set_float("technic_mv_power_machine", 1)
meta:set_string("formspec", mv_electric_furnace_formspec)
meta:set_string("infotext", "Electric furnace")
local inv = meta:get_inventory()
inv:set_size("src", 1)
inv:set_size("dst", 4)
local EU_used = 0
local furnace_is_cookin = 0
local cooked = nil
meta:set_float("internal_EU_buffer",0)
meta:set_float("internal_EU_buffer_size",2000)
end,
can_dig = function(pos,player)
local meta = minetest.env:get_meta(pos);
local inv = meta:get_inventory()
if not inv:is_empty("dst") then
return false
elseif not inv:is_empty("src") then
return false
end
return true
end,
})
minetest.register_node("technic:mv_electric_furnace_active", {
description = "MV Electric Furnace",
tiles = {"technic_mv_electric_furnace_top.png", "technic_mv_electric_furnace_bottom.png", "technic_mv_electric_furnace_side.png",
"technic_mv_electric_furnace_side.png", "technic_mv_electric_furnace_side_tube.png", "technic_mv_electric_furnace_front_active.png"},
paramtype2 = "facedir",
light_source = 8,
drop = "technic:mv_electric_furnace",
groups = {cracky=2, tubedevice=1,tubedevice_receiver=1,not_in_creative_inventory=1},
tube={insert_object=function(pos,node,stack,direction)
local meta=minetest.env:get_meta(pos)
local inv=meta:get_inventory()
return inv:add_item("src",stack)
end,
can_insert=function(pos,node,stack,direction)
local meta=minetest.env:get_meta(pos)
local inv=meta:get_inventory()
return inv:room_for_item("src",stack)
end,
},
legacy_facedir_simple = true,
sounds = default.node_sound_stone_defaults(),
internal_EU_buffer=0;
interal_EU_buffer_size=2000;
technic_power_machine=1,
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
meta:set_float("technic_mv_power_machine", 1)
meta:set_string("formspec", mv_electric_furnace_formspec)
meta:set_string("infotext", "Electric furnace");
local inv = meta:get_inventory()
inv:set_size("src", 1)
inv:set_size("dst", 4)
local EU_used = 0
local furnace_is_cookin = 0
local cooked = nil
end,
can_dig = function(pos,player)
local meta = minetest.env:get_meta(pos);
local inv = meta:get_inventory()
if not inv:is_empty("dst") then
return false
elseif not inv:is_empty("src") then
return false
end
return true
end,
})
minetest.register_abm({
nodenames = {"technic:mv_electric_furnace","technic:mv_electric_furnace_active"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local meta = minetest.env:get_meta(pos)
internal_EU_buffer=meta:get_float("internal_EU_buffer")
internal_EU_buffer_size=meta:get_float("internal_EU_buffer")
local load = math.floor(internal_EU_buffer/2000 * 100)
meta:set_string("formspec",
"invsize[8,9;]"..
"image[1,1;1,2;technic_power_meter_bg.png^[lowpart:"..
(load)..":technic_power_meter_fg.png]"..
"list[current_name;src;3,1;1,1;]"..
"list[current_name;dst;5,1;2,2;]"..
"list[current_player;main;0,5;8,4;]"..
"label[0,0;MV Electric Furnace]"..
"label[1,3;Power level]")
local inv = meta:get_inventory()
local furnace_is_cookin = meta:get_float("furnace_is_cookin")
local srclist = inv:get_list("src")
local cooked=nil
if srclist then
cooked = minetest.get_craft_result({method = "cooking", width = 1, items = srclist})
end
if (furnace_is_cookin == 1) then
if internal_EU_buffer>=150 then
internal_EU_buffer=internal_EU_buffer-150;
meta:set_float("internal_EU_buffer",internal_EU_buffer)
meta:set_float("src_time", meta:get_float("src_time") + 3)
if cooked and cooked.item and meta:get_float("src_time") >= cooked.time then
-- check if there's room for output in "dst" list
if inv:room_for_item("dst",cooked.item) then
-- Put result in "dst" list
inv:add_item("dst", cooked.item)
-- take stuff from "src" list
srcstack = inv:get_stack("src", 1)
srcstack:take_item()
inv:set_stack("src", 1, srcstack)
else
print("Furnace inventory full!")
end
meta:set_string("src_time", 0)
end
end
end
if srclist then
cooked = minetest.get_craft_result({method = "cooking", width = 1, items = srclist})
if cooked.time>0 then
hacky_swap_node(pos,"technic:mv_electric_furnace_active")
meta:set_string("infotext","Furnace active")
meta:set_string("furnace_is_cookin",1)
meta:set_string("src_time", 0)
return
end
end
hacky_swap_node(pos,"technic:mv_electric_furnace")
meta:set_string("infotext","Furnace inactive")
meta:set_string("furnace_is_cookin",0)
meta:set_string("src_time", 0)
end,
})

@ -38,6 +38,7 @@ dofile(modpath.."/grinder.lua")
dofile(modpath.."/wires_mv.lua") dofile(modpath.."/wires_mv.lua")
dofile(modpath.."/solar_panel_mv.lua") dofile(modpath.."/solar_panel_mv.lua")
dofile(modpath.."/battery_box_mv.lua") dofile(modpath.."/battery_box_mv.lua")
dofile(modpath.."/electric_furnace_mv.lua")
--Tools --Tools
if enable_mining_drill==true then dofile(modpath.."/mining_drill.lua") end if enable_mining_drill==true then dofile(modpath.."/mining_drill.lua") end
@ -52,7 +53,7 @@ dofile(modpath.."/sonic_screwdriver.lua")
-- mesecons and tubes related -- mesecons and tubes related
--dofile(modpath.."/injector.lua") --dofile(modpath.."/injector.lua")
dofile(modpath.."/node_breaker.lua") dofile(modpath.."/node_breaker.lua")
--dofile(modpath.."/deployer.lua") dofile(modpath.."/deployer.lua")
dofile(modpath.."/constructor.lua") dofile(modpath.."/constructor.lua")
if enable_item_drop then dofile(modpath.."/item_drop.lua") end if enable_item_drop then dofile(modpath.."/item_drop.lua") end