Added API functions to register LV and MV machines

This commit is contained in:
RealBadAngel 2013-02-03 19:28:51 +01:00
parent 5d799eb94f
commit 6123493fd7
16 changed files with 212 additions and 105 deletions

@ -198,6 +198,9 @@ end
return nil return nil
end end
register_LV_machine ("technic:alloy_furnace","RE")
register_LV_machine ("technic:alloy_furnace_active","RE")
--coal driven alloy furnace: --coal driven alloy furnace:
coal_alloy_furnace_formspec = coal_alloy_furnace_formspec =

@ -265,3 +265,6 @@ function send_cooked_alloys (pos,x_velocity,z_velocity)
end end
end end
end end
register_MV_machine ("technic:mv_alloy_furnace","RE")
register_MV_machine ("technic:mv_alloy_furnace_active","RE")

@ -1,12 +1,21 @@
power_tools ={} LV_machines = {}
registered_LV_machines_count=0
registered_power_tools_count=1 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
power_tools ={}
registered_power_tools_count=0
function register_power_tool (string1,max_charge) 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]={}
power_tools[registered_power_tools_count].tool_name=string1 power_tools[registered_power_tools_count].tool_name=string1
power_tools[registered_power_tools_count].max_charge=max_charge power_tools[registered_power_tools_count].max_charge=max_charge
registered_power_tools_count=registered_power_tools_count+1
end end
register_power_tool ("technic:mining_drill",60000) register_power_tool ("technic:mining_drill",60000)
@ -380,19 +389,14 @@ end
function check_LV_node_subp (PR_nodes,RE_nodes,LV_nodes,pos1) function check_LV_node_subp (PR_nodes,RE_nodes,LV_nodes,pos1)
meta = minetest.env:get_meta(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 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 for i in ipairs(LV_machines) do
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 == LV_machines[i].machine_name then
if minetest.env:get_node(pos1).name == "technic:generator_active" then new_node_added=add_new_cable_node(PR_nodes,pos1) end if LV_machines[i].machine_type == "PR" then
if minetest.env:get_node(pos1).name == "technic:geothermal" then new_node_added=add_new_cable_node(PR_nodes,pos1) end new_node_added=add_new_cable_node(PR_nodes,pos1)
if minetest.env:get_node(pos1).name == "technic:geothermal_active" then new_node_added=add_new_cable_node(PR_nodes,pos1) end end
if minetest.env:get_node(pos1).name == "technic:water_mill" then new_node_added=add_new_cable_node(PR_nodes,pos1) end if LV_machines[i].machine_type == "RE" then
if minetest.env:get_node(pos1).name == "technic:water_mill_active" then new_node_added=add_new_cable_node(PR_nodes,pos1) end new_node_added=add_new_cable_node(RE_nodes,pos1)
if minetest.env:get_node(pos1).name == "technic:electric_furnace" then new_node_added=add_new_cable_node(RE_nodes,pos1) end end
if minetest.env:get_node(pos1).name == "technic:electric_furnace_active" then new_node_added=add_new_cable_node(RE_nodes,pos1) end end
if minetest.env:get_node(pos1).name == "technic:alloy_furnace" then new_node_added=add_new_cable_node(RE_nodes,pos1) end 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
end end

@ -1,3 +1,14 @@
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({ minetest.register_craft({
output = 'technic:mv_battery_box 1', output = 'technic:mv_battery_box 1',
recipe = { recipe = {
@ -7,8 +18,6 @@ minetest.register_craft({
} }
}) })
mv_battery_box_formspec = mv_battery_box_formspec =
"invsize[8,9;]".. "invsize[8,9;]"..
"image[1,1;1,2;technic_power_meter_bg.png]".. "image[1,1;1,2;technic_power_meter_bg.png]"..
@ -316,10 +325,15 @@ end
function check_MV_node_subp (PR_nodes,RE_nodes,MV_nodes,pos1) function check_MV_node_subp (PR_nodes,RE_nodes,MV_nodes,pos1)
meta = minetest.env:get_meta(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 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 for i in ipairs(MV_machines) do
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 == MV_machines[i].machine_name then
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 MV_machines[i].machine_type == "PR" then
if minetest.env:get_node(pos1).name == "technic:mv_alloy_furnace" then new_node_added=add_new_MVcable_node(RE_nodes,pos1) end new_node_added=add_new_MVcable_node(PR_nodes,pos1)
if minetest.env:get_node(pos1).name == "technic:mv_alloy_furnace_active" then new_node_added=add_new_MVcable_node(RE_nodes,pos1) end end
if MV_machines[i].machine_type == "RE" then
new_node_added=add_new_MVcable_node(RE_nodes,pos1)
end
end
end
end end

@ -145,12 +145,10 @@ minetest.register_abm({
end end
meta:set_string("src_time", 0) meta:set_string("src_time", 0)
end end
end end
end end
if srclist then if srclist then
cooked = minetest.get_craft_result({method = "cooking", width = 1, items = srclist}) cooked = minetest.get_craft_result({method = "cooking", width = 1, items = srclist})
if cooked.time>0 then if cooked.time>0 then
@ -162,12 +160,14 @@ minetest.register_abm({
end end
end end
hacky_swap_node(pos,"technic:electric_furnace") hacky_swap_node(pos,"technic:electric_furnace")
meta:set_string("infotext","Furnace inactive") meta:set_string("infotext","Furnace inactive")
meta:set_string("furnace_is_cookin",0) meta:set_string("furnace_is_cookin",0)
meta:set_string("src_time", 0) meta:set_string("src_time", 0)
end,
end,
}) })
register_LV_machine ("technic:electric_furnace","RE")
register_LV_machine ("technic:electric_furnace_active","RE")

@ -262,7 +262,6 @@ function send_cooked_items (pos,x_velocity,z_velocity)
if stack then if stack then
local item0=stack:to_table() local item0=stack:to_table()
if item0 then if item0 then
print (dump(item0))
item0["count"]="1" item0["count"]="1"
local item1=tube_item({x=pos.x,y=pos.y,z=pos.z},item0) 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} item1:get_luaentity().start_pos = {x=pos.x,y=pos.y,z=pos.z}
@ -275,3 +274,6 @@ function send_cooked_items (pos,x_velocity,z_velocity)
end end
end end
end end
register_MV_machine ("technic:mv_electric_furnace","RE")
register_MV_machine ("technic:mv_electric_furnace_active","RE")

@ -137,12 +137,13 @@ minetest.register_abm({
(percent)..":default_furnace_fire_fg.png]".. (percent)..":default_furnace_fire_fg.png]"..
"list[current_player;main;0,5;8,4;]" "list[current_player;main;0,5;8,4;]"
) )
if burn_time==0 then if burn_time==0 then
hacky_swap_node (pos,"technic:generator") hacky_swap_node (pos,"technic:generator")
end end
end end
}) })
register_LV_machine ("technic:generator","PR")
register_LV_machine ("technic:generator_active","PR")

@ -132,4 +132,7 @@ local node=minetest.env:get_node(pos)
if node.name=="default:water_source" or node.name=="default:water_flowing" then return 1 end 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 if node.name=="default:lava_source" or node.name=="default:lava_flowing" then return 2 end
return 0 return 0
end end
register_LV_machine ("technic:geothermal","PR")
register_LV_machine ("technic:geothermal_active","PR")

@ -190,7 +190,7 @@ grinder_formspec =
"list[current_name;src;3,1;1,1;]".. "list[current_name;src;3,1;1,1;]"..
"list[current_name;dst;5,1;2,2;]".. "list[current_name;dst;5,1;2,2;]"..
"list[current_player;main;0,5;8,4;]" "list[current_player;main;0,5;8,4;]"
minetest.register_node("technic:grinder", { minetest.register_node("technic:grinder", {
description = "Grinder", description = "Grinder",
@ -219,7 +219,7 @@ minetest.register_node("technic:grinder", {
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 = function(pos,player)
local meta = minetest.env:get_meta(pos); local meta = minetest.env:get_meta(pos);
local inv = meta:get_inventory() local inv = meta:get_inventory()
@ -257,18 +257,16 @@ minetest.register_abm({
"list[current_name;dst;5,1;2,2;]".. "list[current_name;dst;5,1;2,2;]"..
"list[current_player;main;0,5;8,4;]" "list[current_player;main;0,5;8,4;]"
) )
local inv = meta:get_inventory() local inv = meta:get_inventory()
-- local grinder_on = meta:get_float("grinder_on") -- local grinder_on = meta:get_float("grinder_on")
local srclist = inv:get_list("src") local srclist = inv:get_list("src")
if inv:is_empty("src") then meta:set_float("grinder_on",0) end if inv:is_empty("src") then meta:set_float("grinder_on",0) end
if (meta:get_float("grinder_on") == 1) then if (meta:get_float("grinder_on") == 1) then
if charge>=grind_cost then if charge>=grind_cost then
charge=charge-grind_cost; charge=charge-grind_cost;
@ -285,17 +283,13 @@ minetest.register_abm({
srcstack:take_item() srcstack:take_item()
inv:set_stack("src", 1, srcstack) inv:set_stack("src", 1, srcstack)
if inv:is_empty("src") then meta:set_float("grinder_on",0) end if inv:is_empty("src") then meta:set_float("grinder_on",0) end
else else
print("Grinder inventory full!") print("Grinder inventory full!")
end end
meta:set_float("src_time", 0) meta:set_float("src_time", 0)
end end
end end
end end
if (meta:get_float("grinder_on")==0) then if (meta:get_float("grinder_on")==0) then
local grinded=nil local grinded=nil
if not inv:is_empty("src") then if not inv:is_empty("src") then
@ -304,11 +298,9 @@ minetest.register_abm({
grind_time=4 grind_time=4
meta:set_float("grind_time",grind_time) meta:set_float("grind_time",grind_time)
meta:set_float("src_time", 0) meta:set_float("src_time", 0)
return return
end end
end end
end end
}) })
@ -319,8 +311,9 @@ item_name=src_item["name"]
local counter=registered_grinder_recipes_count-1 local counter=registered_grinder_recipes_count-1
for i=1, counter,1 do 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 end
return nil return nil
end end
register_LV_machine ("technic:grinder","RE")

@ -22,14 +22,14 @@ dofile(modpath.."/concrete.lua")
dofile(modpath.."/items.lua") dofile(modpath.."/items.lua")
--LV machines --LV machines
dofile(modpath.."/wires.lua")
dofile(modpath.."/battery_box.lua")
dofile(modpath.."/alloy_furnaces_commons.lua") dofile(modpath.."/alloy_furnaces_commons.lua")
dofile(modpath.."/alloy_furnace.lua") dofile(modpath.."/alloy_furnace.lua")
dofile(modpath.."/solar_panel.lua") dofile(modpath.."/solar_panel.lua")
dofile(modpath.."/geothermal.lua") dofile(modpath.."/geothermal.lua")
dofile(modpath.."/water_mill.lua") dofile(modpath.."/water_mill.lua")
dofile(modpath.."/electric_furnace.lua") dofile(modpath.."/electric_furnace.lua")
dofile(modpath.."/battery_box.lua")
dofile(modpath.."/wires.lua")
dofile(modpath.."/tool_workshop.lua") dofile(modpath.."/tool_workshop.lua")
dofile(modpath.."/music_player.lua") dofile(modpath.."/music_player.lua")
dofile(modpath.."/generator.lua") dofile(modpath.."/generator.lua")
@ -37,8 +37,8 @@ dofile(modpath.."/grinder.lua")
--MV machines --MV machines
dofile(modpath.."/wires_mv.lua") dofile(modpath.."/wires_mv.lua")
dofile(modpath.."/solar_panel_mv.lua")
dofile(modpath.."/battery_box_mv.lua") dofile(modpath.."/battery_box_mv.lua")
dofile(modpath.."/solar_panel_mv.lua")
dofile(modpath.."/electric_furnace_mv.lua") dofile(modpath.."/electric_furnace_mv.lua")
dofile(modpath.."/alloy_furnace_mv.lua") dofile(modpath.."/alloy_furnace_mv.lua")

@ -5,8 +5,8 @@ minetest.register_craftitem("technic:injector", {
minetest.register_node("technic:injector", { minetest.register_node("technic:injector", {
description = "Injector", description = "Injector",
tiles = {"technic_iron_chest_top.png", "technic_iron_chest_top.png", "technic_iron_chest_side.png", tiles = {"technic_injector_top.png", "technic_injector_bottom.png", "technic_injector_side.png",
"technic_iron_chest_side.png", "technic_iron_chest_side.png", "technic_iron_chest_front.png"}, "technic_injector_side.png", "technic_injector_side.png", "technic_injector_side.png"},
paramtype2 = "facedir", paramtype2 = "facedir",
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2}, groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
legacy_facedir_simple = true, legacy_facedir_simple = true,
@ -32,7 +32,14 @@ minetest.register_node("technic:injector", {
for _,stack in ipairs(inv:get_list("main")) do for _,stack in ipairs(inv:get_list("main")) do
if stack:get_name() ~="" then if stack:get_name() ~="" then
inv:remove_item("main",stack) 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 return
end end
end end
@ -41,33 +48,30 @@ end,
function tube_item(pos, item) 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 -- Take item in any format
local stack = ItemStack(item) local stack = ItemStack(item)
local obj = minetest.env:add_entity(pos, "technic:tubed_item") local obj = minetest.env:add_entity(pos, "technic:tubed_item")
obj:get_luaentity():set_item(stack:to_string()) 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 return obj
end end
@ -82,7 +86,8 @@ minetest.register_entity("technic:tubed_item", {
spritediv = {x=1, y=1}, spritediv = {x=1, y=1},
initial_sprite_basepos = {x=0, y=0}, initial_sprite_basepos = {x=0, y=0},
is_visible = false, is_visible = false,
start_pos={} start_pos={},
route={}
}, },
itemstring = '', itemstring = '',
@ -129,6 +134,7 @@ minetest.register_entity("technic:tubed_item", {
end, end,
on_activate = function(self, staticdata) on_activate = function(self, staticdata)
-- print (dump(staticdata))
if staticdata=="" or staticdata==nil then return end if staticdata=="" or staticdata==nil then return end
local item = minetest.deserialize(staticdata) local item = minetest.deserialize(staticdata)
local stack = ItemStack(item.itemstring) local stack = ItemStack(item.itemstring)
@ -153,16 +159,23 @@ minetest.register_entity("technic:tubed_item", {
local node = minetest.env:get_node(pos) local node = minetest.env:get_node(pos)
local meta = minetest.env:get_meta(pos) local meta = minetest.env:get_meta(pos)
tubelike=meta:get_int("tubelike") tubelike=meta:get_int("tubelike")
local stack = ItemStack(self.itemstring)
local drop_pos=nil
local velocity=self.object:getvelocity() 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 if math.abs(velocity.x)==1 then
local next_node=math.abs(pos.x-self.start_pos.x) local next_node=math.abs(pos.x-self.start_pos.x)
if next_node >= 1 then if next_node >= 1 then
self.start_pos.x=self.start_pos.x+velocity.x self.start_pos.x=self.start_pos.x+velocity.x
if check_pos_vector (self.start_pos, velocity)==0 then 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:setpos(self.start_pos)
self.object:setvelocity(velocity) self.object:setvelocity(velocity)
return return
@ -175,10 +188,14 @@ minetest.register_entity("technic:tubed_item", {
if next_node >= 1 then if next_node >= 1 then
self.start_pos.y=self.start_pos.y+velocity.y self.start_pos.y=self.start_pos.y+velocity.y
if check_pos_vector (self.start_pos, velocity)==0 then 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:setpos(self.start_pos)
self.object:setvelocity(velocity) self.object:setvelocity(velocity)
return return
end end
end end
end end
@ -188,7 +205,11 @@ minetest.register_entity("technic:tubed_item", {
if next_node >= 1 then if next_node >= 1 then
self.start_pos.z=self.start_pos.z+velocity.z self.start_pos.z=self.start_pos.z+velocity.z
if check_pos_vector (self.start_pos, velocity)==0 then 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:setpos(self.start_pos)
self.object:setvelocity(velocity) self.object:setvelocity(velocity)
return return
@ -196,6 +217,7 @@ minetest.register_entity("technic:tubed_item", {
end end
end end
end end
end end
}) })
@ -207,33 +229,32 @@ local tubelike
if velocity.x==0 then if velocity.x==0 then
meta = minetest.env:get_meta({x=pos.x-1,y=pos.y,z=pos.z}) meta = minetest.env:get_meta({x=pos.x-1,y=pos.y,z=pos.z})
tubelike=meta:get_int("tubelike") 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}) meta = minetest.env:get_meta({x=pos.x+1,y=pos.y,z=pos.z})
tubelike=meta:get_int("tubelike") 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 end
if velocity.z==0 then if velocity.z==0 then
meta = minetest.env:get_meta({x=pos.x,y=pos.y,z=pos.z+1}) meta = minetest.env:get_meta({x=pos.x,y=pos.y,z=pos.z+1})
tubelike=meta:get_int("tubelike") 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}) meta = minetest.env:get_meta({x=pos.x,y=pos.y,z=pos.z-1})
tubelike=meta:get_int("tubelike") 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 end
if velocity.y==0 then if velocity.y==0 then
meta = minetest.env:get_meta({x=pos.x,y=pos.y+1,z=pos.z}) meta = minetest.env:get_meta({x=pos.x,y=pos.y+1,z=pos.z})
tubelike=meta:get_int("tubelike") 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}) meta = minetest.env:get_meta({x=pos.x,y=pos.y-1,z=pos.z})
tubelike=meta:get_int("tubelike") 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 end
--velocity.x=0 print ("spadl")
--velocity.y=0 return 0
--velocity.z=0
end end
function check_pos_vector (pos,velocity) function check_pos_vector (pos,velocity)
@ -246,3 +267,60 @@ local meta=minetest.env:get_meta(added)
if meta:get_int("tubelike")==1 then return 1 end if meta:get_int("tubelike")==1 then return 1 end
return 0 return 0
end 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

@ -115,12 +115,8 @@ minetest.register_abm({
"button[4,4;1,2;play;Play]".. "button[4,4;1,2;play;Play]"..
"button[6,4;1,2;stop;Stop]".. "button[6,4;1,2;stop;Stop]"..
"label[4,0;Current track "..tostring(music_player_current_track).."]" "label[4,0;Current track "..tostring(music_player_current_track).."]"
) )
end end
}) })
register_LV_machine ("technic:music_player","RE")

@ -73,4 +73,6 @@ minetest.register_abm(
meta:set_float("active",0) meta:set_float("active",0)
end end
end, end,
}) })
register_LV_machine ("technic:solar_panel","PR")

@ -73,4 +73,6 @@ minetest.register_abm(
meta:set_float("active",0) meta:set_float("active",0)
end end
end, end,
}) })
register_MV_machine ("technic:solar_panel_mv","PR")

@ -95,3 +95,6 @@ minetest.register_abm({
"list[current_player;main;0,5;8,4;]") "list[current_player;main;0,5;8,4;]")
end end
}) })
register_LV_machine ("technic:tool_workshop","RE")

@ -125,4 +125,7 @@ function check_node_around_mill (pos)
local node=minetest.env:get_node(pos) local node=minetest.env:get_node(pos)
if node.name=="default:water_flowing" then return 1 end if node.name=="default:water_flowing" then return 1 end
return 0 return 0
end end
register_LV_machine ("technic:watermill","PR")
register_LV_machine ("technic:watermill_active","PR")