quarry and power distribution improvements
This commit is contained in:
parent
22c561a6e2
commit
f10dae4a20
@ -24,7 +24,7 @@ local CRD = function(pos) return (minetest.registered_nodes[techage.get_node_lvm
|
|||||||
|
|
||||||
local S = techage.S
|
local S = techage.S
|
||||||
|
|
||||||
local STANDBY_TICKS = 6
|
local STANDBY_TICKS = 3
|
||||||
local COUNTDOWN_TICKS = 4
|
local COUNTDOWN_TICKS = 4
|
||||||
local CYCLE_TIME = 4
|
local CYCLE_TIME = 4
|
||||||
|
|
||||||
@ -122,6 +122,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
local function keep_running(pos, elapsed)
|
local function keep_running(pos, elapsed)
|
||||||
|
print("autocrafter keep_running")
|
||||||
local nvm = techage.get_nvm(pos)
|
local nvm = techage.get_nvm(pos)
|
||||||
local crd = CRD(pos)
|
local crd = CRD(pos)
|
||||||
local inv = M(pos):get_inventory()
|
local inv = M(pos):get_inventory()
|
||||||
|
@ -22,8 +22,8 @@ local S = techage.S
|
|||||||
|
|
||||||
local SRC_INV_SIZE = 8
|
local SRC_INV_SIZE = 8
|
||||||
|
|
||||||
local COUNTDOWN_TICKS = 10
|
local STANDBY_TICKS = 3
|
||||||
local STANDBY_TICKS = 10
|
local COUNTDOWN_TICKS = 4
|
||||||
local CYCLE_TIME = 4
|
local CYCLE_TIME = 4
|
||||||
|
|
||||||
local INFO = [[Turn port on/off: command = 'port', payload = red/green/blue/yellow=on/off]]
|
local INFO = [[Turn port on/off: command = 'port', payload = red/green/blue/yellow=on/off]]
|
||||||
|
@ -18,8 +18,8 @@ local M = minetest.get_meta
|
|||||||
local CRD = function(pos) return (minetest.registered_nodes[techage.get_node_lvm(pos).name] or {}).consumer end
|
local CRD = function(pos) return (minetest.registered_nodes[techage.get_node_lvm(pos).name] or {}).consumer end
|
||||||
|
|
||||||
local S = techage.S
|
local S = techage.S
|
||||||
local STANDBY_TICKS = 5
|
local STANDBY_TICKS = 3
|
||||||
local COUNTDOWN_TICKS = 6
|
local COUNTDOWN_TICKS = 4
|
||||||
local CYCLE_TIME = 6
|
local CYCLE_TIME = 6
|
||||||
|
|
||||||
local recipes = techage.recipes
|
local recipes = techage.recipes
|
||||||
|
@ -19,8 +19,8 @@ local S = techage.S
|
|||||||
-- Consumer Related Data
|
-- Consumer Related Data
|
||||||
local CRD = function(pos) return (minetest.registered_nodes[techage.get_node_lvm(pos).name] or {}).consumer end
|
local CRD = function(pos) return (minetest.registered_nodes[techage.get_node_lvm(pos).name] or {}).consumer end
|
||||||
|
|
||||||
local STANDBY_TICKS = 10
|
local STANDBY_TICKS = 3
|
||||||
local COUNTDOWN_TICKS = 10
|
local COUNTDOWN_TICKS = 4
|
||||||
local CYCLE_TIME = 4
|
local CYCLE_TIME = 4
|
||||||
|
|
||||||
local Probability = {}
|
local Probability = {}
|
||||||
|
@ -19,7 +19,7 @@ local S = techage.S
|
|||||||
-- Consumer Related Data
|
-- Consumer Related Data
|
||||||
local CRD = function(pos) return (minetest.registered_nodes[techage.get_node_lvm(pos).name] or {}).consumer end
|
local CRD = function(pos) return (minetest.registered_nodes[techage.get_node_lvm(pos).name] or {}).consumer end
|
||||||
|
|
||||||
local STANDBY_TICKS = 6
|
local STANDBY_TICKS = 3
|
||||||
local COUNTDOWN_TICKS = 4
|
local COUNTDOWN_TICKS = 4
|
||||||
local CYCLE_TIME = 4
|
local CYCLE_TIME = 4
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ local S = techage.S
|
|||||||
-- Consumer Related Data
|
-- Consumer Related Data
|
||||||
local CRD = function(pos) return (minetest.registered_nodes[techage.get_node_lvm(pos).name] or {}).consumer end
|
local CRD = function(pos) return (minetest.registered_nodes[techage.get_node_lvm(pos).name] or {}).consumer end
|
||||||
|
|
||||||
local STANDBY_TICKS = 6
|
local STANDBY_TICKS = 3
|
||||||
local COUNTDOWN_TICKS = 4
|
local COUNTDOWN_TICKS = 4
|
||||||
local CYCLE_TIME = 4
|
local CYCLE_TIME = 4
|
||||||
|
|
||||||
|
@ -19,8 +19,8 @@ local CRD = function(pos) return (minetest.registered_nodes[techage.get_node_lvm
|
|||||||
|
|
||||||
local S = techage.S
|
local S = techage.S
|
||||||
|
|
||||||
local STANDBY_TICKS = 4
|
local STANDBY_TICKS = 2
|
||||||
local COUNTDOWN_TICKS = 2
|
local COUNTDOWN_TICKS = 3
|
||||||
local CYCLE_TIME = 8
|
local CYCLE_TIME = 8
|
||||||
|
|
||||||
local function formspec(self, pos, nvm)
|
local function formspec(self, pos, nvm)
|
||||||
|
@ -29,8 +29,8 @@ local S = techage.S
|
|||||||
-- Consumer Related Data
|
-- Consumer Related Data
|
||||||
local CRD = function(pos) return (minetest.registered_nodes[techage.get_node_lvm(pos).name] or {}).consumer end
|
local CRD = function(pos) return (minetest.registered_nodes[techage.get_node_lvm(pos).name] or {}).consumer end
|
||||||
|
|
||||||
local STANDBY_TICKS = 5
|
local STANDBY_TICKS = 3
|
||||||
local COUNTDOWN_TICKS = 5
|
local COUNTDOWN_TICKS = 4
|
||||||
local CYCLE_TIME = 2
|
local CYCLE_TIME = 2
|
||||||
|
|
||||||
local function ta4_formspec(self, pos, nvm)
|
local function ta4_formspec(self, pos, nvm)
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
Quarry machine to dig stones and other ground blocks.
|
Quarry machine to dig stones and other ground blocks.
|
||||||
|
|
||||||
The Quarry digs a hole 5x5 blocks large and up to 80 blocks deep.
|
The Quarry digs a hole (default) 5x5 blocks large and up to 80 blocks deep.
|
||||||
It starts at the given level (0 is same level as the quarry block,
|
It starts at the given level (0 is same level as the quarry block,
|
||||||
1 is one level higher and so on)) and goes down to the given depth number.
|
1 is one level higher and so on)) and goes down to the given depth number.
|
||||||
It digs one block every 4 seconds.
|
It digs one block every 4 seconds.
|
||||||
@ -26,27 +26,33 @@ local CRD = function(pos) return (minetest.registered_nodes[techage.get_node_lvm
|
|||||||
|
|
||||||
local S = techage.S
|
local S = techage.S
|
||||||
|
|
||||||
local CYCLE_TIME = 4
|
local CYCLE_TIME = 3
|
||||||
local STANDBY_TICKS = 4
|
local STANDBY_TICKS = 4
|
||||||
local COUNTDOWN_TICKS = 4
|
local COUNTDOWN_TICKS = 4
|
||||||
|
|
||||||
local Side2Facedir = {F=0, R=1, B=2, L=3, D=4, U=5}
|
local Side2Facedir = {F=0, R=1, B=2, L=3, D=4, U=5}
|
||||||
local Depth2Idx = {[1]=1 ,[2]=2, [3]=3, [5]=4, [10]=5, [15]=6, [20]=7, [25]=8, [40]=9, [60]=10, [80]=11}
|
local Depth2Idx = {[1]=1 ,[2]=2, [3]=3, [5]=4, [10]=5, [15]=6, [20]=7, [25]=8, [40]=9, [60]=10, [80]=11}
|
||||||
|
local Holesize2Idx = {["3x3"] = 1, ["5x5"] = 2, ["7x7"] = 3, ["9x9"] = 4, ["11x11"] = 5}
|
||||||
|
local Holesize2Diameter = {["3x3"] = 3, ["5x5"] = 5, ["7x7"] = 7, ["9x9"] = 9, ["11x11"] = 11}
|
||||||
local Level2Idx = {[2]=1, [1]=2, [0]=3, [-1]=4, [-2]=5, [-3]=6,
|
local Level2Idx = {[2]=1, [1]=2, [0]=3, [-1]=4, [-2]=5, [-3]=6,
|
||||||
[-5]=7, [-10]=8, [-15]=9, [-20]=10}
|
[-5]=7, [-10]=8, [-15]=9, [-20]=10}
|
||||||
|
|
||||||
local function formspec(self, pos, nvm)
|
local function formspec(self, pos, nvm)
|
||||||
local tooltip = S("Start level = 0\nmeans the same Y-level\nas the quarry is placed")
|
local tooltip = S("Start level = 0\nmeans the same level\nas the quarry is placed")
|
||||||
|
local level_idx = Level2Idx[nvm.start_level or 1] or 2
|
||||||
|
local depth_idx = Depth2Idx[nvm.quarry_depth or 1] or 1
|
||||||
|
local hsize_idx = Holesize2Idx[nvm.hole_size or "5x5"] or 2
|
||||||
local level = nvm.level or "-"
|
local level = nvm.level or "-"
|
||||||
local index = nvm.index or "-"
|
local hsize_list = "5x5"
|
||||||
|
if CRD(pos).stage == 4 then
|
||||||
|
hsize_list = "3x3,5x5,7x7,9x9,11x11"
|
||||||
|
end
|
||||||
local depth_list = "1,2,3,5,10,15,20,25,40,60,80"
|
local depth_list = "1,2,3,5,10,15,20,25,40,60,80"
|
||||||
if CRD(pos).stage == 3 then
|
if CRD(pos).stage == 3 then
|
||||||
depth_list = "1,2,3,5,10,15,20,25,40"
|
depth_list = "1,2,3,5,10,15,20,25,40"
|
||||||
elseif CRD(pos).stage == 2 then
|
elseif CRD(pos).stage == 2 then
|
||||||
depth_list = "1,2,3,5,10,15,20"
|
depth_list = "1,2,3,5,10,15,20"
|
||||||
end
|
end
|
||||||
nvm.quarry_depth = nvm.quarry_depth or 1
|
|
||||||
nvm.start_level = nvm.start_level or -1
|
|
||||||
|
|
||||||
return "size[8,8]"..
|
return "size[8,8]"..
|
||||||
default.gui_bg..
|
default.gui_bg..
|
||||||
@ -55,11 +61,12 @@ local function formspec(self, pos, nvm)
|
|||||||
"box[0,-0.1;7.8,0.5;#c6e8ff]"..
|
"box[0,-0.1;7.8,0.5;#c6e8ff]"..
|
||||||
"label[3.5,-0.1;"..minetest.colorize( "#000000", S("Quarry")).."]"..
|
"label[3.5,-0.1;"..minetest.colorize( "#000000", S("Quarry")).."]"..
|
||||||
techage.question_mark_help(8, tooltip)..
|
techage.question_mark_help(8, tooltip)..
|
||||||
"dropdown[0,0.8;1.5;level;2,1,0,-1,-2,-3,-5,-10,-15,-20;"..Level2Idx[nvm.start_level].."]"..
|
"dropdown[0,0.8;1.5;level;2,1,0,-1,-2,-3,-5,-10,-15,-20;"..level_idx.."]"..
|
||||||
"label[1.6,0.9;"..S("Start level").."]"..
|
"label[1.6,0.9;"..S("Start level").."]"..
|
||||||
"dropdown[0,1.8;1.5;depth;"..depth_list..";"..Depth2Idx[nvm.quarry_depth].."]"..
|
"dropdown[0,1.8;1.5;depth;"..depth_list..";"..depth_idx.."]"..
|
||||||
"label[1.6,1.9;"..S("Digging depth").."]"..
|
"label[1.6,1.9;"..S("Digging depth").." ("..level..")]"..
|
||||||
"label[0,2.9;"..S("level").."="..level..", "..S("pos=")..index.."/25]"..
|
"dropdown[0,2.8;1.5;hole_size;"..hsize_list..";"..hsize_idx.."]"..
|
||||||
|
"label[1.6,2.9;"..S("Hole size").."]"..
|
||||||
"list[context;main;5,0.8;3,3;]"..
|
"list[context;main;5,0.8;3,3;]"..
|
||||||
"image[4,0.8;1,1;"..techage.get_power_image(pos, nvm).."]"..
|
"image[4,0.8;1,1;"..techage.get_power_image(pos, nvm).."]"..
|
||||||
"image_button[4,2.8;1,1;".. self:get_state_button_image(nvm) ..";state_button;]"..
|
"image_button[4,2.8;1,1;".. self:get_state_button_image(nvm) ..";state_button;]"..
|
||||||
@ -123,32 +130,25 @@ local function allow_metadata_inventory_take(pos, listname, index, stack, player
|
|||||||
return stack:get_count()
|
return stack:get_count()
|
||||||
end
|
end
|
||||||
|
|
||||||
local QuarryPath = {
|
|
||||||
3,3,3,3,2,
|
|
||||||
1,1,1,1,2,
|
|
||||||
3,3,3,3,2,
|
|
||||||
1,1,1,1,2,
|
|
||||||
3,3,3,3,2,
|
|
||||||
}
|
|
||||||
|
|
||||||
local function get_next_pos(pos, facedir, idx)
|
local function get_quarry_pos(pos, xoffs, zoffs)
|
||||||
facedir = (facedir + QuarryPath[idx]) % 4
|
return {x = pos.x + xoffs - 1, y = pos.y, z = pos.z + zoffs - 1}
|
||||||
return vector.add(pos, core.facedir_to_dir(facedir))
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- pos is the quarry pos, y_pos the current dug level
|
-- pos is the quarry pos
|
||||||
local function get_corner_positions(pos, facedir, y_pos)
|
local function get_corner_positions(pos, facedir, hole_diameter)
|
||||||
local start_pos = get_pos(pos, facedir, "L")
|
local _pos = get_pos(pos, facedir, "L")
|
||||||
local pos1 = get_pos(start_pos, facedir, "F", 2)
|
local pos1 = get_pos(_pos, facedir, "F", math.floor((hole_diameter - 1) / 2))
|
||||||
local pos2 = get_pos(start_pos, facedir, "B", 2)
|
local pos2 = get_pos(_pos, facedir, "B", math.floor((hole_diameter - 1) / 2))
|
||||||
pos2 = get_pos(pos2, facedir, "L", 4)
|
pos2 = get_pos(pos2, facedir, "L", hole_diameter - 1)
|
||||||
pos1.y = y_pos
|
if pos1.x > pos2.x then pos1.x, pos2.x = pos2.x, pos1.x end
|
||||||
pos2.y = y_pos
|
if pos1.y > pos2.y then pos1.y, pos2.y = pos2.y, pos1.y end
|
||||||
|
if pos1.z > pos2.z then pos1.z, pos2.z = pos2.z, pos1.z end
|
||||||
return pos1, pos2
|
return pos1, pos2
|
||||||
end
|
end
|
||||||
|
|
||||||
local function is_air_level(pos1, pos2)
|
local function is_air_level(pos1, pos2, hole_diameter)
|
||||||
return #minetest.find_nodes_in_area(pos1, pos2, {"air"}) == 25
|
return #minetest.find_nodes_in_area(pos1, pos2, {"air"}) == hole_diameter * hole_diameter
|
||||||
end
|
end
|
||||||
|
|
||||||
local function mark_area(pos1, pos2, owner)
|
local function mark_area(pos1, pos2, owner)
|
||||||
@ -177,39 +177,41 @@ end
|
|||||||
local function quarry_task(pos, crd, nvm)
|
local function quarry_task(pos, crd, nvm)
|
||||||
nvm.start_level = nvm.start_level or 0
|
nvm.start_level = nvm.start_level or 0
|
||||||
nvm.quarry_depth = nvm.quarry_depth or 1
|
nvm.quarry_depth = nvm.quarry_depth or 1
|
||||||
|
nvm.hole_diameter = nvm.hole_diameter or 5
|
||||||
local y_first = pos.y + nvm.start_level
|
local y_first = pos.y + nvm.start_level
|
||||||
local y_last = y_first - nvm.quarry_depth + 1
|
local y_last = y_first - nvm.quarry_depth + 1
|
||||||
local facedir = minetest.get_node(pos).param2
|
local facedir = minetest.get_node(pos).param2
|
||||||
local owner = M(pos):get_string("owner")
|
local owner = M(pos):get_string("owner")
|
||||||
|
|
||||||
|
local pos1, pos2 = get_corner_positions(pos, facedir, nvm.hole_diameter)
|
||||||
nvm.level = 1
|
nvm.level = 1
|
||||||
for y_curr = y_first, y_last, -1 do
|
for y_curr = y_first, y_last, -1 do
|
||||||
local pos1, pos2 = get_corner_positions(pos, facedir, y_curr)
|
pos1.y = y_curr
|
||||||
local qpos = {x = pos1.x, y = pos1.y, z = pos1.z}
|
pos2.y = y_curr
|
||||||
|
|
||||||
if minetest.is_area_protected(pos1, pos2, owner, 5) then
|
if minetest.is_area_protected(pos1, pos2, owner, 5) then
|
||||||
crd.State:fault(pos, nvm, S("area is protected"))
|
crd.State:fault(pos, nvm, S("area is protected"))
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if not is_air_level(pos1, pos2) then
|
if not is_air_level(pos1, pos2, nvm.hole_diameter) then
|
||||||
mark_area(pos1, pos2, owner)
|
mark_area(pos1, pos2, owner)
|
||||||
coroutine.yield()
|
coroutine.yield()
|
||||||
|
|
||||||
nvm.index = 1
|
for zoffs = 1, nvm.hole_diameter do
|
||||||
for i = 1, 25 do
|
for xoffs = 1, nvm.hole_diameter do
|
||||||
local item_name = peek_node(qpos)
|
local qpos = get_quarry_pos(pos1, xoffs, zoffs)
|
||||||
if item_name then
|
local item_name = peek_node(qpos)
|
||||||
if add_to_inv(pos, item_name) then
|
if item_name then
|
||||||
minetest.remove_node(qpos)
|
if add_to_inv(pos, item_name) then
|
||||||
crd.State:keep_running(pos, nvm, COUNTDOWN_TICKS, 1)
|
minetest.remove_node(qpos)
|
||||||
else
|
crd.State:keep_running(pos, nvm, COUNTDOWN_TICKS, 1)
|
||||||
crd.State:blocked(pos, nvm, S("inventory full"))
|
else
|
||||||
|
crd.State:blocked(pos, nvm, S("inventory full"))
|
||||||
|
end
|
||||||
|
coroutine.yield()
|
||||||
end
|
end
|
||||||
coroutine.yield()
|
|
||||||
end
|
end
|
||||||
qpos = get_next_pos(qpos, facedir, i)
|
|
||||||
nvm.index = nvm.index + 1
|
|
||||||
end
|
end
|
||||||
techage.unmark_position(owner)
|
techage.unmark_position(owner)
|
||||||
end
|
end
|
||||||
@ -257,6 +259,11 @@ local function on_receive_fields(pos, formname, fields, player)
|
|||||||
if fields.depth then
|
if fields.depth then
|
||||||
if tonumber(fields.depth) ~= nvm.quarry_depth then
|
if tonumber(fields.depth) ~= nvm.quarry_depth then
|
||||||
nvm.quarry_depth = tonumber(fields.depth)
|
nvm.quarry_depth = tonumber(fields.depth)
|
||||||
|
if CRD(pos).stage == 2 then
|
||||||
|
nvm.quarry_depth = math.min(nvm.quarry_depth, 20)
|
||||||
|
elseif CRD(pos).stage == 3 then
|
||||||
|
nvm.quarry_depth = math.min(nvm.quarry_depth, 40)
|
||||||
|
end
|
||||||
mem.co = nil
|
mem.co = nil
|
||||||
CRD(pos).State:stop(pos, nvm)
|
CRD(pos).State:stop(pos, nvm)
|
||||||
end
|
end
|
||||||
@ -270,6 +277,20 @@ local function on_receive_fields(pos, formname, fields, player)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if fields.hole_size then
|
||||||
|
if CRD(pos).stage == 4 then
|
||||||
|
if fields.hole_size ~= nvm.hole_size then
|
||||||
|
nvm.hole_size = fields.hole_size
|
||||||
|
nvm.hole_diameter = Holesize2Diameter[fields.hole_size or "5x5"] or 5
|
||||||
|
mem.co = nil
|
||||||
|
CRD(pos).State:stop(pos, nvm)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
nvm.hole_size = "5x5"
|
||||||
|
nvm.hole_diameter = 5
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
CRD(pos).State:state_button_event(pos, nvm, fields)
|
CRD(pos).State:state_button_event(pos, nvm, fields)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -163,7 +163,7 @@ end
|
|||||||
-- returns the node name, if node can be dropped, otherwise nil
|
-- returns the node name, if node can be dropped, otherwise nil
|
||||||
function techage.dropped_node(node, ndef)
|
function techage.dropped_node(node, ndef)
|
||||||
if node.name == "air" then return end
|
if node.name == "air" then return end
|
||||||
if ndef.buildable_to == true then return end
|
--if ndef.buildable_to == true then return end
|
||||||
if ndef.drop == "" then return end
|
if ndef.drop == "" then return end
|
||||||
if type(ndef.drop) == "table" then
|
if type(ndef.drop) == "table" then
|
||||||
return handle_drop(ndef.drop)
|
return handle_drop(ndef.drop)
|
||||||
|
@ -152,11 +152,11 @@ end
|
|||||||
-- consumes power
|
-- consumes power
|
||||||
function techage.needs_power(nvm)
|
function techage.needs_power(nvm)
|
||||||
local state = nvm.techage_state or STOPPED
|
local state = nvm.techage_state or STOPPED
|
||||||
return state < BLOCKED
|
return state == RUNNING or state == NOPOWER
|
||||||
end
|
end
|
||||||
|
|
||||||
function techage.needs_power2(state)
|
function techage.needs_power2(state)
|
||||||
return state < BLOCKED
|
return state == RUNNING or state == NOPOWER
|
||||||
end
|
end
|
||||||
|
|
||||||
function techage.get_state_string(nvm)
|
function techage.get_state_string(nvm)
|
||||||
|
@ -23,8 +23,8 @@ local recipes = techage.recipes
|
|||||||
|
|
||||||
local Liquids = {} -- {hash(pos) = {name = outdir},...}
|
local Liquids = {} -- {hash(pos) = {name = outdir},...}
|
||||||
|
|
||||||
local STANDBY_TICKS = 4
|
local STANDBY_TICKS = 2
|
||||||
local COUNTDOWN_TICKS = 4
|
local COUNTDOWN_TICKS = 3
|
||||||
local CYCLE_TIME = 10
|
local CYCLE_TIME = 10
|
||||||
|
|
||||||
-- to mark the pump source and destinstion node
|
-- to mark the pump source and destinstion node
|
||||||
|
@ -23,7 +23,7 @@ local liquid = techage.liquid
|
|||||||
local networks = techage.networks
|
local networks = techage.networks
|
||||||
|
|
||||||
local CYCLE_TIME = 2
|
local CYCLE_TIME = 2
|
||||||
local STANDBY_TICKS = 5
|
local STANDBY_TICKS = 3
|
||||||
local PWR_NEEDED = 30
|
local PWR_NEEDED = 30
|
||||||
local PWR_UNITS_PER_HYDROGEN_ITEM = 80
|
local PWR_UNITS_PER_HYDROGEN_ITEM = 80
|
||||||
local CAPACITY = 200
|
local CAPACITY = 200
|
||||||
|
@ -23,7 +23,7 @@ local liquid = techage.liquid
|
|||||||
local networks = techage.networks
|
local networks = techage.networks
|
||||||
|
|
||||||
local CYCLE_TIME = 2
|
local CYCLE_TIME = 2
|
||||||
local STANDBY_TICKS = 5
|
local STANDBY_TICKS = 4
|
||||||
local PWR_CAPA = 25
|
local PWR_CAPA = 25
|
||||||
local PWR_UNITS_PER_HYDROGEN_ITEM = 80
|
local PWR_UNITS_PER_HYDROGEN_ITEM = 80
|
||||||
local CAPACITY = 100
|
local CAPACITY = 100
|
||||||
|
@ -21,8 +21,8 @@ local networks = techage.networks
|
|||||||
local liquid = techage.liquid
|
local liquid = techage.liquid
|
||||||
local Flip = techage.networks.Flip
|
local Flip = techage.networks.Flip
|
||||||
|
|
||||||
local STANDBY_TICKS = 5
|
local STANDBY_TICKS = 3
|
||||||
local COUNTDOWN_TICKS = 5
|
local COUNTDOWN_TICKS = 4
|
||||||
local CYCLE_TIME = 2
|
local CYCLE_TIME = 2
|
||||||
local CAPA = 4
|
local CAPA = 4
|
||||||
|
|
||||||
|
@ -19,8 +19,8 @@ local S = techage.S
|
|||||||
-- Consumer Related Data
|
-- Consumer Related Data
|
||||||
local CRD = function(pos) return (minetest.registered_nodes[techage.get_node_lvm(pos).name] or {}).consumer end
|
local CRD = function(pos) return (minetest.registered_nodes[techage.get_node_lvm(pos).name] or {}).consumer end
|
||||||
|
|
||||||
local STANDBY_TICKS = 5
|
local STANDBY_TICKS = 2
|
||||||
local COUNTDOWN_TICKS = 6
|
local COUNTDOWN_TICKS = 4
|
||||||
local CYCLE_TIME = 16
|
local CYCLE_TIME = 16
|
||||||
|
|
||||||
local formspec0 = "size[5,4]"..
|
local formspec0 = "size[5,4]"..
|
||||||
|
@ -24,7 +24,7 @@ local liquid = techage.liquid
|
|||||||
local CRD = function(pos) return (minetest.registered_nodes[techage.get_node_lvm(pos).name] or {}).consumer end
|
local CRD = function(pos) return (minetest.registered_nodes[techage.get_node_lvm(pos).name] or {}).consumer end
|
||||||
local CRDN = function(node) return (minetest.registered_nodes[node.name] or {}).consumer end
|
local CRDN = function(node) return (minetest.registered_nodes[node.name] or {}).consumer end
|
||||||
|
|
||||||
local STANDBY_TICKS = 1
|
local STANDBY_TICKS = 2
|
||||||
local COUNTDOWN_TICKS = 10
|
local COUNTDOWN_TICKS = 10
|
||||||
local CYCLE_TIME = 8
|
local CYCLE_TIME = 8
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
]]--
|
]]--
|
||||||
|
|
||||||
local N = function(pos) return techage.get_node_lvm(pos).name end
|
local N = function(pos) return techage.get_node_lvm(pos).name end
|
||||||
|
local P2S = function(pos) if pos then return minetest.pos_to_string(pos) end end
|
||||||
local net_def = techage.networks.net_def
|
local net_def = techage.networks.net_def
|
||||||
|
|
||||||
local STOPPED = techage.power.STOPPED
|
local STOPPED = techage.power.STOPPED
|
||||||
@ -56,7 +57,7 @@ local function get_generator_sum(tbl, tlib_type)
|
|||||||
local def = nvm[tlib_type] -- power related network data
|
local def = nvm[tlib_type] -- power related network data
|
||||||
if def and def["gstate"] ~= STOPPED then
|
if def and def["gstate"] ~= STOPPED then
|
||||||
def["galive"] = (def["galive"] or 1) - 1
|
def["galive"] = (def["galive"] or 1) - 1
|
||||||
if def["galive"] > 0 then
|
if def["galive"] >= 0 then
|
||||||
sum = sum + (def.curr_power or v.nominal)
|
sum = sum + (def.curr_power or v.nominal)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -71,10 +72,11 @@ local function get_consumer_sum(tbl, tlib_type)
|
|||||||
local def = nvm[tlib_type] -- power related network data
|
local def = nvm[tlib_type] -- power related network data
|
||||||
if def and def["cstate"] ~= STOPPED then
|
if def and def["cstate"] ~= STOPPED then
|
||||||
def["calive"] = (def["calive"] or 1) - 1
|
def["calive"] = (def["calive"] or 1) - 1
|
||||||
if def["calive"] > 0 then
|
if def["calive"] >= 0 then
|
||||||
sum = sum + v.nominal
|
sum = sum + v.nominal
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
--print(N(v.pos), P2S(v.pos), def["cstate"], def["calive"])
|
||||||
end
|
end
|
||||||
return sum
|
return sum
|
||||||
end
|
end
|
||||||
|
@ -151,7 +151,7 @@ function techage.power.consumer_stop(pos, Cable)
|
|||||||
local nvm = techage.get_nvm(pos)
|
local nvm = techage.get_nvm(pos)
|
||||||
local tlib_type = Cable.tube_type
|
local tlib_type = Cable.tube_type
|
||||||
nvm[tlib_type] = nvm[tlib_type] or {}
|
nvm[tlib_type] = nvm[tlib_type] or {}
|
||||||
nvm[tlib_type]["calive"] = 0
|
nvm[tlib_type]["calive"] = -1
|
||||||
nvm[tlib_type]["cstate"] = STOPPED
|
nvm[tlib_type]["cstate"] = STOPPED
|
||||||
nvm[tlib_type]["taken"] = 0
|
nvm[tlib_type]["taken"] = 0
|
||||||
end
|
end
|
||||||
@ -195,7 +195,7 @@ function techage.power.generator_stop(pos, Cable, outdir)
|
|||||||
local nvm = techage.get_nvm(pos)
|
local nvm = techage.get_nvm(pos)
|
||||||
local tlib_type = Cable.tube_type
|
local tlib_type = Cable.tube_type
|
||||||
nvm[tlib_type] = nvm[tlib_type] or {}
|
nvm[tlib_type] = nvm[tlib_type] or {}
|
||||||
nvm[tlib_type]["galive"] = 0
|
nvm[tlib_type]["galive"] = -1
|
||||||
nvm[tlib_type]["gstate"] = STOPPED
|
nvm[tlib_type]["gstate"] = STOPPED
|
||||||
nvm[tlib_type]["given"] = 0
|
nvm[tlib_type]["given"] = 0
|
||||||
end
|
end
|
||||||
|
@ -188,10 +188,12 @@ minetest.register_node("techage:power_pole2", {
|
|||||||
after_place_node = function(pos, placer, itemstack, pointed_thing)
|
after_place_node = function(pos, placer, itemstack, pointed_thing)
|
||||||
M(pos):set_string("owner", placer:get_player_name())
|
M(pos):set_string("owner", placer:get_player_name())
|
||||||
if techage.is_protected(pos, placer:get_player_name()) then
|
if techage.is_protected(pos, placer:get_player_name()) then
|
||||||
|
minetest.chat_send_player(placer:get_player_name(), "position is protected ")
|
||||||
minetest.remove_node(pos)
|
minetest.remove_node(pos)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
if not Cable:after_place_tube(pos, placer, pointed_thing) then
|
if not Cable:after_place_tube(pos, placer, pointed_thing) then
|
||||||
|
minetest.chat_send_player(placer:get_player_name(), "invalid pole position ")
|
||||||
minetest.remove_node(pos)
|
minetest.remove_node(pos)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
@ -252,6 +254,7 @@ minetest.register_node("techage:power_pole", {
|
|||||||
after_place_node = function(pos, placer, itemstack, pointed_thing)
|
after_place_node = function(pos, placer, itemstack, pointed_thing)
|
||||||
M(pos):set_string("owner", placer:get_player_name())
|
M(pos):set_string("owner", placer:get_player_name())
|
||||||
if techage.is_protected(pos, placer:get_player_name()) then
|
if techage.is_protected(pos, placer:get_player_name()) then
|
||||||
|
minetest.chat_send_player(placer:get_player_name(), "position is protected ")
|
||||||
minetest.remove_node(pos)
|
minetest.remove_node(pos)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
@ -39,7 +39,7 @@ local function generator_data(gen_tbl)
|
|||||||
if nvm.ele1 and nvm.ele1.gstate and nvm.ele1.gstate ~= STOPPED then
|
if nvm.ele1 and nvm.ele1.gstate and nvm.ele1.gstate ~= STOPPED then
|
||||||
tbl.num_on = tbl.num_on + 1
|
tbl.num_on = tbl.num_on + 1
|
||||||
tbl.pow_on = tbl.pow_on + (nvm.ele1.curr_power or gen.nominal or 0)
|
tbl.pow_on = tbl.pow_on + (nvm.ele1.curr_power or gen.nominal or 0)
|
||||||
if (nvm.ele1.galive or 0) > 0 then
|
if (nvm.ele1.galive or -1) >= 0 then
|
||||||
tbl.num_act = tbl.num_act + 1
|
tbl.num_act = tbl.num_act + 1
|
||||||
tbl.pow_act = tbl.pow_act + (nvm.ele1.curr_power or gen.nominal or 0)
|
tbl.pow_act = tbl.pow_act + (nvm.ele1.curr_power or gen.nominal or 0)
|
||||||
if (nvm.ele1.given or 0) > 0 then
|
if (nvm.ele1.given or 0) > 0 then
|
||||||
@ -65,7 +65,7 @@ local function consumer_data(con_tbl)
|
|||||||
if nvm.ele1 and nvm.ele1.cstate and nvm.ele1.cstate ~= STOPPED then
|
if nvm.ele1 and nvm.ele1.cstate and nvm.ele1.cstate ~= STOPPED then
|
||||||
tbl.num_on = tbl.num_on + 1
|
tbl.num_on = tbl.num_on + 1
|
||||||
tbl.pow_on = tbl.pow_on + (gen.nominal or 0)
|
tbl.pow_on = tbl.pow_on + (gen.nominal or 0)
|
||||||
if (nvm.ele1.calive or 0) > 0 then
|
if (nvm.ele1.calive or -1) >= 0 then
|
||||||
tbl.num_act = tbl.num_act + 1
|
tbl.num_act = tbl.num_act + 1
|
||||||
tbl.pow_act = tbl.pow_act + (gen.nominal or 0)
|
tbl.pow_act = tbl.pow_act + (gen.nominal or 0)
|
||||||
if (nvm.ele1.taken or 0) > 0 then
|
if (nvm.ele1.taken or 0) > 0 then
|
||||||
|
Loading…
Reference in New Issue
Block a user