return nil
end
+register_LV_machine ("technic:alloy_furnace","RE")
+register_LV_machine ("technic:alloy_furnace_active","RE")
+
--coal driven alloy furnace:
coal_alloy_furnace_formspec =
end
end
end
+
+register_MV_machine ("technic:mv_alloy_furnace","RE")
+register_MV_machine ("technic:mv_alloy_furnace_active","RE")
-power_tools ={}
+LV_machines = {}
+registered_LV_machines_count=0
+
+function register_LV_machine (string1,string2)
+registered_LV_machines_count=registered_LV_machines_count+1
+LV_machines[registered_LV_machines_count]={}
+LV_machines[registered_LV_machines_count].machine_name=string1
+LV_machines[registered_LV_machines_count].machine_type=string2
+end
-registered_power_tools_count=1
+power_tools ={}
+registered_power_tools_count=0
function register_power_tool (string1,max_charge)
+registered_power_tools_count=registered_power_tools_count+1
power_tools[registered_power_tools_count]={}
power_tools[registered_power_tools_count].tool_name=string1
power_tools[registered_power_tools_count].max_charge=max_charge
-registered_power_tools_count=registered_power_tools_count+1
end
register_power_tool ("technic:mining_drill",60000)
function check_LV_node_subp (PR_nodes,RE_nodes,LV_nodes,pos1)
meta = minetest.env:get_meta(pos1)
if meta:get_float("cablelike")==1 then new_node_added=add_new_cable_node(LV_nodes,pos1) end
-if minetest.env:get_node(pos1).name == "technic:solar_panel" then new_node_added=add_new_cable_node(PR_nodes,pos1) end
-if minetest.env:get_node(pos1).name == "technic:generator" then new_node_added=add_new_cable_node(PR_nodes,pos1) end
-if minetest.env:get_node(pos1).name == "technic:generator_active" then new_node_added=add_new_cable_node(PR_nodes,pos1) end
-if minetest.env:get_node(pos1).name == "technic:geothermal" then new_node_added=add_new_cable_node(PR_nodes,pos1) end
-if minetest.env:get_node(pos1).name == "technic:geothermal_active" then new_node_added=add_new_cable_node(PR_nodes,pos1) end
-if minetest.env:get_node(pos1).name == "technic:water_mill" then new_node_added=add_new_cable_node(PR_nodes,pos1) end
-if minetest.env:get_node(pos1).name == "technic:water_mill_active" then new_node_added=add_new_cable_node(PR_nodes,pos1) end
-if minetest.env:get_node(pos1).name == "technic:electric_furnace" then new_node_added=add_new_cable_node(RE_nodes,pos1) end
-if minetest.env:get_node(pos1).name == "technic:electric_furnace_active" then new_node_added=add_new_cable_node(RE_nodes,pos1) end
-if minetest.env:get_node(pos1).name == "technic:alloy_furnace" then new_node_added=add_new_cable_node(RE_nodes,pos1) end
-if minetest.env:get_node(pos1).name == "technic:alloy_furnace_active" then new_node_added=add_new_cable_node(RE_nodes,pos1) end
-if minetest.env:get_node(pos1).name == "technic:tool_workshop" then new_node_added=add_new_cable_node(RE_nodes,pos1) end
-if minetest.env:get_node(pos1).name == "technic:music_player" then new_node_added=add_new_cable_node(RE_nodes,pos1) end
-if minetest.env:get_node(pos1).name == "technic:grinder" then new_node_added=add_new_cable_node(RE_nodes,pos1) end
+for i in ipairs(LV_machines) do
+ if minetest.env:get_node(pos1).name == LV_machines[i].machine_name then
+ if LV_machines[i].machine_type == "PR" then
+ new_node_added=add_new_cable_node(PR_nodes,pos1)
+ end
+ if LV_machines[i].machine_type == "RE" then
+ new_node_added=add_new_cable_node(RE_nodes,pos1)
+ end
+ end
+end
end
-
\ No newline at end of file
+MV_machines = {}
+
+registered_MV_machines_count=0
+
+function register_MV_machine (string1,string2)
+registered_MV_machines_count=registered_MV_machines_count+1
+MV_machines[registered_MV_machines_count]={}
+MV_machines[registered_MV_machines_count].machine_name=string1
+MV_machines[registered_MV_machines_count].machine_type=string2
+end
+
minetest.register_craft({
output = 'technic:mv_battery_box 1',
recipe = {
}
})
-
-
mv_battery_box_formspec =
"invsize[8,9;]"..
"image[1,1;1,2;technic_power_meter_bg.png]"..
function check_MV_node_subp (PR_nodes,RE_nodes,MV_nodes,pos1)
meta = minetest.env:get_meta(pos1)
if meta:get_float("mv_cablelike")==1 then new_node_added=add_new_MVcable_node(MV_nodes,pos1) end
-if minetest.env:get_node(pos1).name == "technic:solar_panel_mv" then new_node_added=add_new_MVcable_node(PR_nodes,pos1) end
-if minetest.env:get_node(pos1).name == "technic:mv_electric_furnace" then new_node_added=add_new_MVcable_node(RE_nodes,pos1) end
-if minetest.env:get_node(pos1).name == "technic:mv_electric_furnace_active" then new_node_added=add_new_MVcable_node(RE_nodes,pos1) end
-if minetest.env:get_node(pos1).name == "technic:mv_alloy_furnace" then new_node_added=add_new_MVcable_node(RE_nodes,pos1) end
-if minetest.env:get_node(pos1).name == "technic:mv_alloy_furnace_active" then new_node_added=add_new_MVcable_node(RE_nodes,pos1) end
+for i in ipairs(MV_machines) do
+ if minetest.env:get_node(pos1).name == MV_machines[i].machine_name then
+ if MV_machines[i].machine_type == "PR" then
+ new_node_added=add_new_MVcable_node(PR_nodes,pos1)
+ end
+ if MV_machines[i].machine_type == "RE" then
+ new_node_added=add_new_MVcable_node(RE_nodes,pos1)
+ end
+ end
+end
end
end
meta:set_string("src_time", 0)
end
- end
+ end
end
-
-
-
+
if srclist then
cooked = minetest.get_craft_result({method = "cooking", width = 1, items = srclist})
if cooked.time>0 then
end
end
-
+
hacky_swap_node(pos,"technic:electric_furnace")
meta:set_string("infotext","Furnace inactive")
meta:set_string("furnace_is_cookin",0)
meta:set_string("src_time", 0)
-
-
-end,
+
+end,
})
+
+register_LV_machine ("technic:electric_furnace","RE")
+register_LV_machine ("technic:electric_furnace_active","RE")
if stack then
local item0=stack:to_table()
if item0 then
- print (dump(item0))
item0["count"]="1"
local item1=tube_item({x=pos.x,y=pos.y,z=pos.z},item0)
item1:get_luaentity().start_pos = {x=pos.x,y=pos.y,z=pos.z}
end
end
end
+
+register_MV_machine ("technic:mv_electric_furnace","RE")
+register_MV_machine ("technic:mv_electric_furnace_active","RE")
(percent)..":default_furnace_fire_fg.png]"..
"list[current_player;main;0,5;8,4;]"
)
-
+
if burn_time==0 then
hacky_swap_node (pos,"technic:generator")
end
-
end
})
+register_LV_machine ("technic:generator","PR")
+register_LV_machine ("technic:generator_active","PR")
if node.name=="default:water_source" or node.name=="default:water_flowing" then return 1 end
if node.name=="default:lava_source" or node.name=="default:lava_flowing" then return 2 end
return 0
-end
\ No newline at end of file
+end
+
+register_LV_machine ("technic:geothermal","PR")
+register_LV_machine ("technic:geothermal_active","PR")
"list[current_name;src;3,1;1,1;]"..
"list[current_name;dst;5,1;2,2;]"..
"list[current_player;main;0,5;8,4;]"
-
+
minetest.register_node("technic:grinder", {
description = "Grinder",
inv:set_size("src", 1)
inv:set_size("dst", 4)
- end,
+ end,
can_dig = function(pos,player)
local meta = minetest.env:get_meta(pos);
local inv = meta:get_inventory()
"list[current_name;dst;5,1;2,2;]"..
"list[current_player;main;0,5;8,4;]"
)
-
+
local inv = meta:get_inventory()
-- local grinder_on = meta:get_float("grinder_on")
-
local srclist = inv:get_list("src")
if inv:is_empty("src") then meta:set_float("grinder_on",0) end
-
-
+
if (meta:get_float("grinder_on") == 1) then
if charge>=grind_cost then
charge=charge-grind_cost;
srcstack:take_item()
inv:set_stack("src", 1, srcstack)
if inv:is_empty("src") then meta:set_float("grinder_on",0) end
-
-
-
else
print("Grinder inventory full!")
end
meta:set_float("src_time", 0)
end
- end
+ end
end
-
if (meta:get_float("grinder_on")==0) then
local grinded=nil
if not inv:is_empty("src") then
grind_time=4
meta:set_float("grind_time",grind_time)
meta:set_float("src_time", 0)
- return
+ return
end
end
-
-
end
})
local counter=registered_grinder_recipes_count-1
for i=1, counter,1 do
-if grinder_recipes[i].src_name==item_name then return ItemStack(grinder_recipes[i].dst_name) end
+ if grinder_recipes[i].src_name==item_name then return ItemStack(grinder_recipes[i].dst_name) end
end
return nil
-
end
+
+register_LV_machine ("technic:grinder","RE")
dofile(modpath.."/items.lua")
--LV machines
+dofile(modpath.."/wires.lua")
+dofile(modpath.."/battery_box.lua")
dofile(modpath.."/alloy_furnaces_commons.lua")
dofile(modpath.."/alloy_furnace.lua")
dofile(modpath.."/solar_panel.lua")
dofile(modpath.."/geothermal.lua")
dofile(modpath.."/water_mill.lua")
dofile(modpath.."/electric_furnace.lua")
-dofile(modpath.."/battery_box.lua")
-dofile(modpath.."/wires.lua")
dofile(modpath.."/tool_workshop.lua")
dofile(modpath.."/music_player.lua")
dofile(modpath.."/generator.lua")
--MV machines
dofile(modpath.."/wires_mv.lua")
-dofile(modpath.."/solar_panel_mv.lua")
dofile(modpath.."/battery_box_mv.lua")
+dofile(modpath.."/solar_panel_mv.lua")
dofile(modpath.."/electric_furnace_mv.lua")
dofile(modpath.."/alloy_furnace_mv.lua")
minetest.register_node("technic:injector", {
description = "Injector",
- tiles = {"technic_iron_chest_top.png", "technic_iron_chest_top.png", "technic_iron_chest_side.png",
- "technic_iron_chest_side.png", "technic_iron_chest_side.png", "technic_iron_chest_front.png"},
+ tiles = {"technic_injector_top.png", "technic_injector_bottom.png", "technic_injector_side.png",
+ "technic_injector_side.png", "technic_injector_side.png", "technic_injector_side.png"},
paramtype2 = "facedir",
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
legacy_facedir_simple = true,
for _,stack in ipairs(inv:get_list("main")) do
if stack:get_name() ~="" then
inv:remove_item("main",stack)
- item1=tube_item({x=pos.x+.5,y=pos.y,z=pos.z},stack)
+ pos1=pos
+ pos1.y=pos1.y
+ local x=pos1.x+1.5
+ local z=pos1.z
+ item1=tube_item({x=pos1.x,y=pos1.y,z=pos1.z},stack)
+ item1:get_luaentity().start_pos = {x=pos1.x,y=pos1.y,z=pos1.z}
+ item1:setvelocity({x=1, y=0, z=0})
+ item1:setacceleration({x=0, y=0, z=0})
return
end
end
function tube_item(pos, item)
+ local TUBE_nodes = {}
+ local CHEST_nodes = {}
+
+ TUBE_nodes[1]={}
+ TUBE_nodes[1].x=pos.x
+ TUBE_nodes[1].y=pos.y
+ TUBE_nodes[1].z=pos.z
+
+
+table_index=1
+ repeat
+ check_TUBE_node (TUBE_nodes,CHEST_nodes,table_index)
+ table_index=table_index+1
+ if TUBE_nodes[table_index]==nil then break end
+ until false
+found=table_index-1
+
+
+print("Found "..found.." tubes connected")
+print(dump(CHEST_nodes))
-- Take item in any format
local stack = ItemStack(item)
local obj = minetest.env:add_entity(pos, "technic:tubed_item")
obj:get_luaentity():set_item(stack:to_string())
- obj:get_luaentity().start_pos = {x=pos.x,y=pos.y,z=pos.z}
- obj:setacceleration({x=0, y=0, z=0})
- pos.x=pos.x+1
- local meta = minetest.env:get_meta(pos)
- if meta:get_int("tubelike")==1 then obj:setvelocity({x=1, y=0, z=0}) return obj end
- pos.x=pos.x-2
- meta = minetest.env:get_meta(pos)
- if meta:get_int("tubelike")==1 then obj:setvelocity({x=-1, y=0, z=0}) return obj end
- pos.x=pos.x+1
- pos.z=pos.z+1
- meta = minetest.env:get_meta(pos)
- if meta:get_int("tubelike")==1 then obj:setvelocity({x=0, y=0, z=1}) return obj end
- pos.z=pos.z-2
- meta = minetest.env:get_meta(pos)
- if meta:get_int("tubelike")==1 then obj:setvelocity({x=0, y=0, z=-1}) return obj end
- pos.z=pos.z+1
- pos.y=pos.y+1
- meta = minetest.env:get_meta(pos)
- if meta:get_int("tubelike")==1 then obj:setvelocity({x=0, y=1, z=0}) return obj end
- pos.y=pos.y-2
- meta = minetest.env:get_meta(pos)
- if meta:get_int("tubelike")==1 then obj:setvelocity({x=0, y=-2, z=0}) return obj end
- pos.y=pos.y+1
return obj
end
spritediv = {x=1, y=1},
initial_sprite_basepos = {x=0, y=0},
is_visible = false,
- start_pos={}
+ start_pos={},
+ route={}
},
itemstring = '',
end,
on_activate = function(self, staticdata)
+-- print (dump(staticdata))
if staticdata=="" or staticdata==nil then return end
local item = minetest.deserialize(staticdata)
local stack = ItemStack(item.itemstring)
local node = minetest.env:get_node(pos)
local meta = minetest.env:get_meta(pos)
tubelike=meta:get_int("tubelike")
+ local stack = ItemStack(self.itemstring)
+ local drop_pos=nil
+
local velocity=self.object:getvelocity()
- if not velocity then return end
+ if velocity==nil then print ("wypadl") return end
if math.abs(velocity.x)==1 then
local next_node=math.abs(pos.x-self.start_pos.x)
if next_node >= 1 then
self.start_pos.x=self.start_pos.x+velocity.x
if check_pos_vector (self.start_pos, velocity)==0 then
- check_next_step (self.start_pos, velocity)
+ if check_next_step (self.start_pos, velocity)==0 then
+ drop_pos=minetest.env:find_node_near({x=self.start_pos.x,y=self.start_pos.y,z=self.start_pos.z+velocity.x}, 1, "air")
+ if drop_pos then minetest.item_drop(stack, "", drop_pos) end
+ self.object:remove()
+ end
self.object:setpos(self.start_pos)
self.object:setvelocity(velocity)
return
if next_node >= 1 then
self.start_pos.y=self.start_pos.y+velocity.y
if check_pos_vector (self.start_pos, velocity)==0 then
- check_next_step (self.start_pos, velocity)
+ if check_next_step (self.start_pos, velocity)==0 then
+ drop_pos=minetest.env:find_node_near({x=self.start_pos.x+velocity.x,y=self.start_pos.y+velocity.y,z=self.start_pos.z+velocity.z}, 1, "air")
+ if drop_pos then minetest.item_drop(stack, "", drop_pos) end
+ self.object:remove()
+ end
self.object:setpos(self.start_pos)
self.object:setvelocity(velocity)
- return
+ return
end
end
end
if next_node >= 1 then
self.start_pos.z=self.start_pos.z+velocity.z
if check_pos_vector (self.start_pos, velocity)==0 then
- check_next_step (self.start_pos, velocity)
+ if check_next_step (self.start_pos, velocity)==0 then
+ drop_pos=minetest.env:find_node_near({x=self.start_pos.x+velocity.x,y=self.start_pos.y+velocity.y,z=self.start_pos.z+velocity.z}, 1, "air")
+ if drop_pos then minetest.item_drop(stack, "", drop_pos) end
+ self.object:remove()
+ end
self.object:setpos(self.start_pos)
self.object:setvelocity(velocity)
return
end
end
end
+
end
})
if velocity.x==0 then
meta = minetest.env:get_meta({x=pos.x-1,y=pos.y,z=pos.z})
tubelike=meta:get_int("tubelike")
-if tubelike==1 then velocity.x=-1 velocity.y=0 velocity.z=0 return end
+if tubelike==1 then velocity.x=-1 velocity.y=0 velocity.z=0 return 1 end
meta = minetest.env:get_meta({x=pos.x+1,y=pos.y,z=pos.z})
tubelike=meta:get_int("tubelike")
-if tubelike==1 then velocity.x=1 velocity.y=0 velocity.z=0 return end
+if tubelike==1 then velocity.x=1 velocity.y=0 velocity.z=0 return 1 end
end
if velocity.z==0 then
meta = minetest.env:get_meta({x=pos.x,y=pos.y,z=pos.z+1})
tubelike=meta:get_int("tubelike")
-if tubelike==1 then velocity.x=0 velocity.y=0 velocity.z=1 return end
+if tubelike==1 then velocity.x=0 velocity.y=0 velocity.z=1 return 1 end
meta = minetest.env:get_meta({x=pos.x,y=pos.y,z=pos.z-1})
tubelike=meta:get_int("tubelike")
-if tubelike==1 then velocity.x=0 velocity.y=0 velocity.z=-1 return end
+if tubelike==1 then velocity.x=0 velocity.y=0 velocity.z=-1 return 1 end
end
if velocity.y==0 then
meta = minetest.env:get_meta({x=pos.x,y=pos.y+1,z=pos.z})
tubelike=meta:get_int("tubelike")
-if tubelike==1 then velocity.x=0 velocity.y=1 velocity.z=0 return end
+if tubelike==1 then velocity.x=0 velocity.y=1 velocity.z=0 return 1 end
meta = minetest.env:get_meta({x=pos.x,y=pos.y-1,z=pos.z})
tubelike=meta:get_int("tubelike")
-if tubelike==1 then velocity.x=0 velocity.y=-1 velocity.z=0 return end
+if tubelike==1 then velocity.x=0 velocity.y=-1 velocity.z=0 return 1 end
end
---velocity.x=0
---velocity.y=0
---velocity.z=0
+print ("spadl")
+return 0
end
function check_pos_vector (pos,velocity)
if meta:get_int("tubelike")==1 then return 1 end
return 0
end
+
+function add_new_TUBE_node (TUBE_nodes,pos1,parent)
+local i=1
+ repeat
+ if TUBE_nodes[i]==nil then break end
+ if pos1.x==TUBE_nodes[i].x and pos1.y==TUBE_nodes[i].y and pos1.z==TUBE_nodes[i].z then return false end
+ i=i+1
+ until false
+TUBE_nodes[i]={}
+TUBE_nodes[i].x=pos1.x
+TUBE_nodes[i].y=pos1.y
+TUBE_nodes[i].z=pos1.z
+TUBE_nodes[i].parent_x=parent.x
+TUBE_nodes[i].parent_y=parent.y
+TUBE_nodes[i].parent_z=parent.z
+
+return true
+end
+
+function check_TUBE_node (TUBE_nodes,CHEST_nodes,i)
+ local pos1={}
+ local parent={}
+ pos1.x=TUBE_nodes[i].x
+ pos1.y=TUBE_nodes[i].y
+ pos1.z=TUBE_nodes[i].z
+ parent.x=pos1.x
+ parent.y=pos1.y
+ parent.z=pos1.z
+ new_node_added=false
+
+ pos1.x=pos1.x+1
+ check_TUBE_node_subp (TUBE_nodes,CHEST_nodes,pos1,parent)
+ pos1.x=pos1.x-2
+ check_TUBE_node_subp (TUBE_nodes,CHEST_nodes,pos1,parent)
+ pos1.x=pos1.x+1
+
+ pos1.y=pos1.y+1
+ check_TUBE_node_subp (TUBE_nodes,CHEST_nodes,pos1,parent)
+ pos1.y=pos1.y-2
+ check_TUBE_node_subp (TUBE_nodes,CHEST_nodes,pos1,parent)
+ pos1.y=pos1.y+1
+
+ pos1.z=pos1.z+1
+ check_TUBE_node_subp (TUBE_nodes,CHEST_nodes,pos1,parent)
+ pos1.z=pos1.z-2
+ check_TUBE_node_subp (TUBE_nodes,CHEST_nodes,pos1,parent)
+ pos1.z=pos1.z+1
+return new_node_added
+end
+
+function check_TUBE_node_subp (TUBE_nodes,CHEST_nodes,pos1,parent)
+meta = minetest.env:get_meta(pos1)
+if meta:get_float("tubelike")==1 then add_new_TUBE_node(TUBE_nodes,pos1,parent) return end
+nctr = minetest.env:get_node(pos1)
+if minetest.get_item_group(nctr.name, "tubedevice_receiver") == 1 then add_new_TUBE_node(CHEST_nodes,pos1,parent) return end
+end
+
"button[4,4;1,2;play;Play]"..
"button[6,4;1,2;stop;Stop]"..
"label[4,0;Current track "..tostring(music_player_current_track).."]"
-
)
-
-
-
-
end
})
+register_LV_machine ("technic:music_player","RE")
meta:set_float("active",0)
end
end,
-})
\ No newline at end of file
+})
+
+register_LV_machine ("technic:solar_panel","PR")
meta:set_float("active",0)
end
end,
-})
\ No newline at end of file
+})
+
+register_MV_machine ("technic:solar_panel_mv","PR")
"list[current_player;main;0,5;8,4;]")
end
})
+
+register_LV_machine ("technic:tool_workshop","RE")
+
local node=minetest.env:get_node(pos)
if node.name=="default:water_flowing" then return 1 end
return 0
-end
\ No newline at end of file
+end
+
+register_LV_machine ("technic:watermill","PR")
+register_LV_machine ("technic:watermill_active","PR")