Improve energy storage detection, increase Lua controller editor contrast
parent
b74c596b00
commit
2f7dbc1771
|
@ -73,21 +73,46 @@ local function chat(owner, text)
|
|||
return text
|
||||
end
|
||||
|
||||
local function get_radius(pos, in_dir)
|
||||
local function get_diameter(pos, in_dir)
|
||||
local dir = tubelib2.Dir6dToVector[in_dir]
|
||||
local pos2 = vector.add(pos, vector.multiply(dir, 8))
|
||||
local poses = minetest.find_nodes_in_area(pos, pos2, {"techage:ta4_pipe_inlet"})
|
||||
if #poses == 2 then
|
||||
local radius = vector.distance(poses[1], poses[2]) / 2
|
||||
if radius == 2 or radius == 3 or radius == 4 then
|
||||
return radius
|
||||
end
|
||||
local pos2, node
|
||||
|
||||
pos2 = vector.add(pos, vector.multiply(dir, 4))
|
||||
node = minetest.get_node(pos2)
|
||||
if node.name == "techage:ta3_pipe_wall_entry" then
|
||||
return
|
||||
end
|
||||
if node.name == "techage:ta4_pipe_inlet" then
|
||||
return 5
|
||||
end
|
||||
|
||||
pos2 = vector.add(pos, vector.multiply(dir, 6))
|
||||
node = minetest.get_node(pos2)
|
||||
if node.name == "techage:ta3_pipe_wall_entry" then
|
||||
return
|
||||
end
|
||||
if node.name == "techage:ta4_pipe_inlet" then
|
||||
return 7
|
||||
end
|
||||
|
||||
pos2 = vector.add(pos, vector.multiply(dir, 8))
|
||||
node = minetest.get_node(pos2)
|
||||
if node.name == "techage:ta3_pipe_wall_entry" then
|
||||
return
|
||||
end
|
||||
if node.name == "techage:ta4_pipe_inlet" then
|
||||
return 9
|
||||
end
|
||||
|
||||
pos2 = vector.add(pos, vector.multiply(dir, 10))
|
||||
local poses = minetest.find_nodes_in_area(pos, pos2, {"techage:ta4_pipe_inlet"})
|
||||
if #poses > 1 then
|
||||
return vector.distance(pos, poses[2]) + 1
|
||||
end
|
||||
return 1
|
||||
end
|
||||
|
||||
local function check_volume(pos, in_dir, owner)
|
||||
local radius = get_radius(pos, in_dir)
|
||||
local radius = (get_diameter(pos, in_dir) - 1) / 2
|
||||
if radius then
|
||||
local dir = tubelib2.Dir6dToVector[in_dir]
|
||||
local cpos = vector.add(pos, vector.multiply(dir, radius))
|
||||
|
@ -113,7 +138,7 @@ end
|
|||
|
||||
-- provide position behind the obsidian_glass
|
||||
local function check_window(pos, in_dir)
|
||||
local radius = get_radius(pos, in_dir)
|
||||
local radius = (get_diameter(pos, in_dir) - 1) / 2
|
||||
if radius then
|
||||
local dir = tubelib2.Dir6dToVector[in_dir]
|
||||
local cpos = vector.add(pos, vector.multiply(dir, radius))
|
||||
|
@ -134,7 +159,7 @@ end
|
|||
techage.register_node({"techage:ta4_pipe_inlet"}, {
|
||||
on_transfer = function(pos, in_dir, topic, payload)
|
||||
if topic == "diameter" then
|
||||
return get_radius(pos, in_dir) * 2 - 1
|
||||
return get_diameter(pos, in_dir)
|
||||
elseif topic == "integrity" then
|
||||
return check_volume(pos, in_dir, payload)
|
||||
elseif topic == "volume" then
|
||||
|
|
|
@ -180,9 +180,10 @@ local function formspec1(meta)
|
|||
default.gui_bg..
|
||||
default.gui_bg_img..
|
||||
default.gui_slots..
|
||||
"style_type[textarea;font=mono]"..
|
||||
"style_type[textarea;font=mono;textcolor=#FFFFFF;border=false]"..
|
||||
"tabheader[0,0;tab;init,func,loop,outp,notes,help;1;;true]"..
|
||||
"textarea[0.3,0.2;10,8.3;init;function init();"..init.."]"..
|
||||
"background[0.1,0.3;9.8,7.0;techage_form_mask.png]"..
|
||||
"label[0,7.3;end]"..
|
||||
"button_exit[4.4,7.5;1.8,1;cancel;Cancel]"..
|
||||
"button[6.3,7.5;1.8,1;save;Save]"..
|
||||
|
@ -198,9 +199,10 @@ local function formspec2(meta)
|
|||
default.gui_bg..
|
||||
default.gui_bg_img..
|
||||
default.gui_slots..
|
||||
"style_type[textarea;font=mono]"..
|
||||
"style_type[textarea;font=mono;textcolor=#FFFFFF;border=false]"..
|
||||
"tabheader[0,0;tab;init,func,loop,outp,notes,help;2;;true]"..
|
||||
"textarea[0.3,0.2;10,8.3;func;functions:;"..func.."]"..
|
||||
"background[0.1,0.3;9.8,7.0;techage_form_mask.png]"..
|
||||
"button_exit[4.4,7.5;1.8,1;cancel;Cancel]"..
|
||||
"button[6.3,7.5;1.8,1;save;Save]"..
|
||||
"button[8.2,7.5;1.8,1;"..cmnd.."]"
|
||||
|
@ -215,9 +217,10 @@ local function formspec3(meta)
|
|||
default.gui_bg..
|
||||
default.gui_bg_img..
|
||||
default.gui_slots..
|
||||
"style_type[textarea;font=mono]"..
|
||||
"style_type[textarea;font=mono;textcolor=#FFFFFF;border=false]"..
|
||||
"tabheader[0,0;tab;init,func,loop,outp,notes,help;3;;true]"..
|
||||
"textarea[0.3,0.2;10,8.3;loop;function loop(ticks, elapsed);"..loop.."]"..
|
||||
"background[0.1,0.3;9.8,7.0;techage_form_mask.png]"..
|
||||
"label[0,7.3;end]"..
|
||||
"button_exit[4.4,7.5;1.8,1;cancel;Cancel]"..
|
||||
"button[6.3,7.5;1.8,1;save;Save]"..
|
||||
|
@ -248,9 +251,10 @@ local function formspec5(meta)
|
|||
default.gui_bg..
|
||||
default.gui_bg_img..
|
||||
default.gui_slots..
|
||||
"style_type[textarea;font=mono]"..
|
||||
"style_type[textarea;font=mono;textcolor=#FFFFFF;border=false]"..
|
||||
"tabheader[0,0;tab;init,func,loop,outp,notes,help;5;;true]"..
|
||||
"textarea[0.3,0.2;10,8.3;notes;Notepad:;"..notes.."]"..
|
||||
"background[0.1,0.3;9.8,7.0;techage_form_mask.png]"..
|
||||
"button_exit[6.3,7.5;1.8,1;cancel;Cancel]"..
|
||||
"button[8.2,7.5;1.8,1;save;Save]"
|
||||
end
|
||||
|
@ -261,7 +265,7 @@ local function formspec6(items, pos, text)
|
|||
default.gui_bg..
|
||||
default.gui_bg_img..
|
||||
default.gui_slots..
|
||||
"style_type[textarea;font=mono]"..
|
||||
"style_type[textarea;font=mono;textcolor=#FFFFFF]"..
|
||||
"tabheader[0,0;tab;init,func,loop,outp,notes,help;6;;true]"..
|
||||
"label[0,-0.2;Functions:]"..
|
||||
"dropdown[0.3,0.2;10,8.3;functions;"..items..";"..pos.."]"..
|
||||
|
|
Loading…
Reference in New Issue