Add Pump node that fills up reservoirs automatically
This commit is contained in:
parent
05c5b6730b
commit
0dd80eda1c
@ -21,3 +21,4 @@ dofile(path.."/reservoir.lua")
|
||||
dofile(path.."/lava_furnace_fueler.lua")
|
||||
dofile(path.."/bucket_filler.lua")
|
||||
dofile(path.."/bucket_emptier.lua")
|
||||
dofile(path.."/pump.lua")
|
||||
|
@ -97,7 +97,9 @@ local function on_player_receive_fields(player, formname, fields)
|
||||
local pos = forms[playerName].position
|
||||
if minetest.is_protected(pos, playerName) then return true end
|
||||
|
||||
if fields[ON_OFF_BTN] then
|
||||
if fields.quit then
|
||||
forms[playerName] = nil
|
||||
elseif fields[ON_OFF_BTN] then
|
||||
logistica.toggle_machine_on_off(pos)
|
||||
show_emptier_formspec(playerName, pos)
|
||||
end
|
||||
@ -123,7 +125,7 @@ function logistica.register_bucket_emptier(desc, name, tiles)
|
||||
local lname = name:gsub("%s", "_"):lower()
|
||||
local emptier_name = "logistica:"..lname
|
||||
|
||||
logistica.bucketemptiers[emptier_name] = true
|
||||
logistica.bucket_emptiers[emptier_name] = true
|
||||
local def = {
|
||||
description = S(desc),
|
||||
tiles = tiles,
|
||||
|
@ -138,7 +138,7 @@ end)
|
||||
function logistica.register_bucket_filler(desc, name, tiles)
|
||||
local lname = string.lower(name:gsub(" ", "_"))
|
||||
local filler_name = "logistica:"..lname
|
||||
logistica.bucketfillers[filler_name] = true
|
||||
logistica.bucket_fillers[filler_name] = true
|
||||
local grps = {oddly_breakable_by_hand = 3, cracky = 3, handy = 1, pickaxey = 1, }
|
||||
grps[logistica.TIER_ALL] = 1
|
||||
local def = {
|
||||
|
172
api/pump.lua
Normal file
172
api/pump.lua
Normal file
@ -0,0 +1,172 @@
|
||||
local S = logistica.TRANSLATOR
|
||||
|
||||
local PUMP_MAX_RANGE = logistica.settings.pump_max_range
|
||||
local PUMP_MAX_DEPTH = logistica.settings.pump_max_depth
|
||||
|
||||
local META_OWNER = "pumpowner"
|
||||
|
||||
local FORMSPEC_NAME = "logistica_pump"
|
||||
local INV_INPUT = "input"
|
||||
local INV_MAIN = "main"
|
||||
|
||||
local ON_OFF_BTN = "onffbtn"
|
||||
|
||||
local forms = {}
|
||||
|
||||
--------------------------------
|
||||
-- Formspec
|
||||
--------------------------------
|
||||
|
||||
local function get_pump_formspec(pos, _isOn)
|
||||
local isOn = _isOn
|
||||
-- local posForm = "nodemeta:"..pos.x..","..pos.y..","..pos.z
|
||||
if isOn == nil then isOn = logistica.is_machine_on(pos) end
|
||||
return "formspec_version[4]"..
|
||||
"size["..logistica.inv_size(10.5, 4.0).."]" ..
|
||||
logistica.ui.background..
|
||||
"label[0.4,0.4;"..S("Pumps liquids directly into neighbouring reservoirs (one on each side)").."]"..
|
||||
"label[0.4,0.8;"..S("Or if there are none, or are full, pumps into any network reservoirs").."]"..
|
||||
"label[0.4,1.2;"..S("Max horizontal range, on each side of pump: ")..tostring(PUMP_MAX_RANGE).."]"..
|
||||
"label[0.4,1.6;"..S("Max vertical range, starting below the pump: ")..tostring(PUMP_MAX_DEPTH).."]"..
|
||||
"label[0.4,2.0;"..S("MUST be placed directly above liquid surface, without gaps to liquid").."]"..
|
||||
logistica.ui.on_off_btn(isOn, 0.4, 2.8, ON_OFF_BTN, S("Enable"))
|
||||
end
|
||||
|
||||
local function show_pump_formspec(playerName, pos)
|
||||
if not forms[playerName] then forms[playerName] = {position = pos} end
|
||||
minetest.show_formspec(playerName, FORMSPEC_NAME, get_pump_formspec(pos))
|
||||
end
|
||||
|
||||
--------------------------------
|
||||
-- Callbacks
|
||||
--------------------------------
|
||||
|
||||
local function pump_after_place(pos, placer, itemstack)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size(INV_INPUT, 24)
|
||||
inv:set_size(INV_MAIN, 4)
|
||||
if placer and placer:is_player() then
|
||||
meta:set_string(META_OWNER, placer:get_player_name())
|
||||
end
|
||||
logistica.set_node_tooltip_from_state(pos)
|
||||
logistica.on_pump_change(pos)
|
||||
end
|
||||
|
||||
local function pump_can_dig(pos)
|
||||
return true
|
||||
end
|
||||
|
||||
local function pump_allow_metadata_inv_put(pos, listname, index, stack, player)
|
||||
return stack:get_count()
|
||||
end
|
||||
|
||||
local function pump_allow_metadata_inv_take(pos, listname, index, stack, player)
|
||||
return stack:get_count()
|
||||
end
|
||||
|
||||
local function pump_allow_metadata_inv_move(pos, from_list, from_index, to_list, to_index, count, player)
|
||||
return count
|
||||
end
|
||||
|
||||
local function pump_on_inv_change(pos)
|
||||
end
|
||||
|
||||
local function on_pump_rightclick(pos, node, clicker, itemstack, pointed_thing)
|
||||
if not clicker or not clicker:is_player() then return end
|
||||
if minetest.is_protected(pos, clicker:get_player_name()) then return end
|
||||
show_pump_formspec(clicker:get_player_name(), pos)
|
||||
end
|
||||
|
||||
local function on_player_receive_fields(player, formname, fields)
|
||||
if not player or not player:is_player() then return false end
|
||||
if formname ~= FORMSPEC_NAME then return false end
|
||||
local playerName = player:get_player_name()
|
||||
if not forms[playerName] then return false end
|
||||
local pos = forms[playerName].position
|
||||
if minetest.is_protected(pos, playerName) then return true end
|
||||
|
||||
if fields.quit then
|
||||
forms[playerName] = nil
|
||||
elseif fields[ON_OFF_BTN] then
|
||||
logistica.toggle_machine_on_off(pos)
|
||||
show_pump_formspec(playerName, pos)
|
||||
end
|
||||
end
|
||||
|
||||
----------------------------------------------------------------
|
||||
-- Minetest registration
|
||||
----------------------------------------------------------------
|
||||
|
||||
minetest.register_on_player_receive_fields(on_player_receive_fields)
|
||||
|
||||
minetest.register_on_leaveplayer(function(objRef, _)
|
||||
if objRef:is_player() then
|
||||
forms[objRef:get_player_name()] = nil
|
||||
end
|
||||
end)
|
||||
|
||||
--------------------------------
|
||||
-- Public API
|
||||
--------------------------------
|
||||
|
||||
function logistica.register_pump(desc, name, tiles, tilesOn)
|
||||
local lname = name:gsub("%s", "_"):lower()
|
||||
local pump_name = "logistica:"..lname
|
||||
local pump_name_on = pump_name.."_on"
|
||||
|
||||
logistica.pumps[pump_name] = true
|
||||
logistica.pumps[pump_name_on] = true
|
||||
|
||||
local def = {
|
||||
description = S(desc),
|
||||
tiles = tiles,
|
||||
paramtype2 = "facedir",
|
||||
groups = { cracky= 2, pickaxey = 2, [logistica.TIER_ALL] = 1 },
|
||||
is_ground_content = false,
|
||||
sounds = logistica.sound_mod.node_sound_stone_defaults(),
|
||||
can_dig = pump_can_dig,
|
||||
drop = pump_name,
|
||||
on_timer = logistica.on_timer_powered(logistica.pump_timer),
|
||||
after_place_node = pump_after_place,
|
||||
after_dig_node = logistica.on_supplier_change,
|
||||
on_rightclick = on_pump_rightclick,
|
||||
on_metadata_inventory_move = pump_on_inv_change,
|
||||
on_metadata_inventory_put = pump_on_inv_change,
|
||||
on_metadata_inventory_take = pump_on_inv_change,
|
||||
allow_metadata_inventory_put = pump_allow_metadata_inv_put,
|
||||
allow_metadata_inventory_move = pump_allow_metadata_inv_move,
|
||||
allow_metadata_inventory_take = pump_allow_metadata_inv_take,
|
||||
logistica = {
|
||||
on_power = logistica.pump_on_power,
|
||||
on_connect_to_network = function(pos, networkId)
|
||||
logistica.start_node_timer(pos, 1)
|
||||
end,
|
||||
},
|
||||
_mcl_hardness = 3,
|
||||
_mcl_blast_resistance = 10,
|
||||
}
|
||||
|
||||
minetest.register_node(pump_name, def)
|
||||
|
||||
local def_on = table.copy(def)
|
||||
def_on.tiles = tilesOn
|
||||
def_on.groups.not_in_creative_inventory = 1
|
||||
|
||||
minetest.register_node(pump_name_on, def_on)
|
||||
|
||||
local def_disabled = table.copy(def)
|
||||
local tiles_disabled = {}
|
||||
for k, v in pairs(def.tiles) do tiles_disabled[k] = v.."^logistica_disabled.png" end
|
||||
|
||||
def_disabled.tiles = tiles_disabled
|
||||
def_disabled.groups = { oddly_breakable_by_hand = 3, cracky = 3, choppy = 3, not_in_creative_inventory = 1, pickaxey = 1, axey = 1, handy = 1 }
|
||||
def_disabled.on_construct = nil
|
||||
def_disabled.after_dig_node = nil
|
||||
def_disabled.on_punch = nil
|
||||
def_disabled.on_rightclick = nil
|
||||
def_disabled.on_timer = nil
|
||||
def_disabled.logistica = nil
|
||||
|
||||
minetest.register_node(pump_name.."_disabled", def_disabled)
|
||||
end
|
@ -6,7 +6,6 @@ local INV_MAIN = "main"
|
||||
local TIMER_SHORT = 1.0
|
||||
local TIMER_LONG = 3.0
|
||||
|
||||
|
||||
function logistica.emptier_on_power(pos, power)
|
||||
if power then
|
||||
logistica.start_node_timer(pos, TIMER_SHORT)
|
||||
|
@ -4,8 +4,9 @@ logistica.injectors = {}
|
||||
logistica.requesters = {}
|
||||
logistica.suppliers = {}
|
||||
logistica.craftsups = {}
|
||||
logistica.bucketemptiers = {}
|
||||
logistica.bucketfillers = {}
|
||||
logistica.bucket_emptiers = {}
|
||||
logistica.bucket_fillers = {}
|
||||
logistica.pumps = {}
|
||||
logistica.mass_storage = {}
|
||||
logistica.item_storage = {}
|
||||
logistica.misc_machines = {}
|
||||
@ -24,7 +25,7 @@ function logistica.is_machine(name)
|
||||
or logistica.is_item_storage(name) or logistica.is_controller(name) or logistica.is_injector(name)
|
||||
or logistica.is_crafting_supplier(name) or logistica.is_trashcan(name) or logistica.is_vaccuum_supplier(name)
|
||||
or logistica.is_misc(name) or logistica.is_reservoir(name) or logistica.is_bucket_filler(name)
|
||||
or logistica.is_bucket_emptier(name)
|
||||
or logistica.is_bucket_emptier(name) or logistica.is_pump(name)
|
||||
end
|
||||
|
||||
function logistica.is_cable(name)
|
||||
@ -76,9 +77,13 @@ function logistica.is_reservoir(name)
|
||||
end
|
||||
|
||||
function logistica.is_bucket_filler(name)
|
||||
return logistica.bucketfillers[name] ~= nil
|
||||
return logistica.bucket_fillers[name] ~= nil
|
||||
end
|
||||
|
||||
function logistica.is_bucket_emptier(name)
|
||||
return logistica.bucketemptiers[name] ~= nil
|
||||
return logistica.bucket_emptiers[name] ~= nil
|
||||
end
|
||||
|
||||
function logistica.is_pump(name)
|
||||
return logistica.pumps[name] ~= nil
|
||||
end
|
||||
|
@ -22,3 +22,4 @@ dofile(path.."/reservoir.lua")
|
||||
dofile(path.."/lava_furnace_fueler.lua")
|
||||
dofile(path.."/bucket_filler.lua")
|
||||
dofile(path.."/bucket_emptier.lua")
|
||||
dofile(path.."/pump.lua")
|
||||
|
@ -3,6 +3,8 @@ local HARD_NETWORK_NODE_LIMIT = 4000 -- A network cannot consist of more than th
|
||||
local STATUS_OK = 0
|
||||
local CREATE_NETWORK_STATUS_FAIL_OTHER_NETWORK = -1
|
||||
local CREATE_NETWORK_STATUS_TOO_MANY_NODES = -2
|
||||
local ON_SUFFIX = "_on"
|
||||
local DISABLED_SUFFIX = "_disabled"
|
||||
|
||||
local META_STORED_NETWORK = "logisticanet"
|
||||
|
||||
@ -120,9 +122,17 @@ local function clear_network(networkName)
|
||||
networks[networkName] = nil
|
||||
end
|
||||
|
||||
local function ends_with(str, ending)
|
||||
return str:sub(-#ending) == ending
|
||||
end
|
||||
|
||||
local function break_logistica_node(pos)
|
||||
local node = minetest.get_node(pos)
|
||||
logistica.swap_node(pos, node.name .. "_disabled")
|
||||
local nodeName = node.name
|
||||
if ends_with(nodeName, ON_SUFFIX) then
|
||||
nodeName = nodeName:sub(1, #node.name - #ON_SUFFIX)
|
||||
end
|
||||
logistica.swap_node(pos, nodeName .. DISABLED_SUFFIX)
|
||||
end
|
||||
|
||||
-- returns a numberOfNetworks (which is 0, 1, 2), networkOrNil
|
||||
@ -200,7 +210,9 @@ local function recursive_scan_for_nodes_for_controller(network, positionHashes,
|
||||
network.item_storage[otherHash] = true
|
||||
valid = true
|
||||
end
|
||||
if logistica.is_misc(otherName) then
|
||||
if logistica.is_misc(otherName)
|
||||
or logistica.is_pump(otherName)
|
||||
then
|
||||
network.misc[otherHash] = true
|
||||
valid = true
|
||||
end
|
||||
@ -366,12 +378,6 @@ local ITEM_STORAGE_OPS = {
|
||||
update_cache_node_removed = function(_) end,
|
||||
}
|
||||
|
||||
local ACCESS_POINT_OPS = {
|
||||
get_list = function(network) return network.misc end,
|
||||
update_cache_node_added = function(_) end,
|
||||
update_cache_node_removed = function(_) end,
|
||||
}
|
||||
|
||||
local TRASHCAN_OPS = {
|
||||
get_list = function(network) return network.trashcans end,
|
||||
update_cache_node_added = function(_) end,
|
||||
@ -384,7 +390,7 @@ local RESERVOIR_OPS = {
|
||||
update_cache_node_removed = function(_) end,
|
||||
}
|
||||
|
||||
local LAVA_FURNACE_FUELER_OPS = {
|
||||
local MISC_OPS = {
|
||||
get_list = function(network) return network.misc end,
|
||||
update_cache_node_added = function(_) end,
|
||||
update_cache_node_removed = function(_) end,
|
||||
@ -509,7 +515,7 @@ function logistica.on_item_storage_change(pos, oldNode, oldMeta)
|
||||
end
|
||||
|
||||
function logistica.on_access_point_change(pos, oldNode, oldMeta)
|
||||
on_node_change(pos, oldNode, oldMeta, ACCESS_POINT_OPS)
|
||||
on_node_change(pos, oldNode, oldMeta, MISC_OPS)
|
||||
end
|
||||
|
||||
function logistica.on_trashcan_change(pos, oldNode, oldMeta)
|
||||
@ -521,5 +527,9 @@ function logistica.on_reservoir_change(pos, oldNode, oldMeta)
|
||||
end
|
||||
|
||||
function logistica.on_lava_furnace_fueler_change(pos, oldNode, oldMeta)
|
||||
on_node_change(pos, oldNode, oldMeta, LAVA_FURNACE_FUELER_OPS)
|
||||
on_node_change(pos, oldNode, oldMeta, MISC_OPS)
|
||||
end
|
||||
|
||||
function logistica.on_pump_change(pos, oldNode, oldMeta)
|
||||
on_node_change(pos, oldNode, oldMeta, MISC_OPS)
|
||||
end
|
||||
|
190
logic/pump.lua
Normal file
190
logic/pump.lua
Normal file
@ -0,0 +1,190 @@
|
||||
local PUMP_MAX_RANGE = logistica.settings.pump_max_range
|
||||
local PUMP_MAX_DEPTH = logistica.settings.pump_max_depth
|
||||
|
||||
local PUMP_NODES_PER_ROW = 2 * PUMP_MAX_RANGE + 1
|
||||
local PUMP_NODES_PER_LAYER = PUMP_NODES_PER_ROW * PUMP_NODES_PER_ROW
|
||||
local PUMP_INDEX_MAX = PUMP_NODES_PER_LAYER * PUMP_MAX_DEPTH
|
||||
|
||||
local META_PUMP_INDEX = "pumpix"
|
||||
local META_OWNER = "pumpowner"
|
||||
local META_LAST_LAYER = "pumplsl"
|
||||
local META_LAST_LAYER_HAD_SUCCESS = "pumplss"
|
||||
|
||||
local ON_SUFFIX = "_on"
|
||||
|
||||
local MAX_CHECKS_PER_TIMER = PUMP_NODES_PER_LAYER -- limits how many nodes the index can advance per timer
|
||||
|
||||
local TIMER_SHORT = 1.0
|
||||
local TIMER_LONG = 3.0
|
||||
|
||||
local SOURCES_TO_NAMES = nil
|
||||
|
||||
local PUMP_NEIGHBORS = {
|
||||
vector.new(-1, 0, 0),
|
||||
vector.new( 1, 0, 0),
|
||||
vector.new( 0, 0, 1),
|
||||
vector.new( 0, 0, -1),
|
||||
}
|
||||
|
||||
local function ends_with(str, ending)
|
||||
return str:sub(-#ending) == ending
|
||||
end
|
||||
|
||||
local function sources_to_names()
|
||||
if not SOURCES_TO_NAMES then SOURCES_TO_NAMES = logistica.reservoir_get_all_sources_to_names_map() end
|
||||
return SOURCES_TO_NAMES
|
||||
end
|
||||
|
||||
local function pump_get_index(meta)
|
||||
return meta:get_int(META_PUMP_INDEX)
|
||||
end
|
||||
|
||||
local function pump_set_index(meta, newIndex)
|
||||
meta:set_int(META_PUMP_INDEX, newIndex)
|
||||
end
|
||||
|
||||
local function get_owner_name(meta)
|
||||
return meta:get_string(META_OWNER)
|
||||
end
|
||||
|
||||
local function get_last_layer(meta)
|
||||
return meta:get_int(META_LAST_LAYER)
|
||||
end
|
||||
|
||||
local function set_last_layer(meta, layerInt)
|
||||
meta:set_int(META_LAST_LAYER, layerInt)
|
||||
end
|
||||
|
||||
local function get_last_layer_success(meta)
|
||||
return meta:get_int(META_LAST_LAYER_HAD_SUCCESS) == 0
|
||||
end
|
||||
|
||||
local function set_last_layer_success(meta, success)
|
||||
meta:set_int(META_LAST_LAYER_HAD_SUCCESS, success and 0 or 1)
|
||||
end
|
||||
|
||||
-- returns nil if target position does not have a valid liquid source
|
||||
-- otherwise returns table {nodeName = "name", isRenewable = true/false, bucketName = "bucket_itemstack_name"}
|
||||
local function get_valid_source(targetPosition, ownerName)
|
||||
logistica.load_position(targetPosition)
|
||||
|
||||
if minetest.is_protected(targetPosition, ownerName) then return nil end
|
||||
|
||||
local node = minetest.get_node_or_nil(targetPosition)
|
||||
if not node then return nil end
|
||||
|
||||
local liquidName = sources_to_names()[node.name]
|
||||
if not liquidName then return nil end
|
||||
|
||||
-- ensure it's really a source node
|
||||
local nodeDef = minetest.registered_nodes[node.name]
|
||||
if nodeDef.liquidtype ~= "source" then return nil end
|
||||
|
||||
local bucketName = logistica.reservoir_get_full_bucket_for_liquid(liquidName)
|
||||
if not bucketName then return nil end
|
||||
|
||||
-- otherwise its valid
|
||||
local isRenewable = nodeDef.liquid_renewable ; if isRenewable == nil then isRenewable = true end -- default value is true, per api docs
|
||||
return {
|
||||
nodeName = node.name,
|
||||
isRenewable = isRenewable,
|
||||
bucketName = bucketName,
|
||||
}
|
||||
end
|
||||
|
||||
-- returns a vector of the position associated with this index
|
||||
local function pump_index_to_position(pumpPosition, pumpIndex)
|
||||
local x = pumpIndex % PUMP_NODES_PER_LAYER % PUMP_NODES_PER_ROW
|
||||
local y = -math.floor(pumpIndex / PUMP_NODES_PER_LAYER)
|
||||
local z = math.floor((pumpIndex % PUMP_NODES_PER_LAYER) / PUMP_NODES_PER_ROW)
|
||||
return vector.add(pumpPosition, vector.new(x - PUMP_MAX_RANGE, y - 1, z - PUMP_MAX_RANGE))
|
||||
end
|
||||
|
||||
-- returns true if succeeded, false if not
|
||||
local function put_liquid_in_neighboring_reservoirs(pumpPosition, bucketItemStack)
|
||||
for _, v in ipairs(PUMP_NEIGHBORS) do
|
||||
local neighborPos = vector.add(pumpPosition, v)
|
||||
logistica.load_position(neighborPos)
|
||||
local neighborNode = minetest.get_node_or_nil(neighborPos)
|
||||
if neighborNode and logistica.is_reservoir(neighborNode.name) then
|
||||
local resultStack = logistica.reservoir_use_item_on(neighborPos, bucketItemStack, neighborNode)
|
||||
if resultStack ~= nil then return true end
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
-- returns true if succeeded, false if not
|
||||
local function put_liquid_in_network_reservoirs(pumpPosition, bucketItemStack, network)
|
||||
if not network then return false end
|
||||
local resultStack = logistica.use_bucket_for_liquid_in_network(pumpPosition, bucketItemStack)
|
||||
return resultStack ~= nil -- if we got a replacement, it was successfully emptied into network
|
||||
end
|
||||
|
||||
function logistica.pump_on_power(pos, power)
|
||||
local node = minetest.get_node_or_nil(pos)
|
||||
if power then
|
||||
logistica.start_node_timer(pos, TIMER_SHORT)
|
||||
if node and not ends_with(node.name, ON_SUFFIX) then
|
||||
logistica.swap_node(pos, node.name..ON_SUFFIX)
|
||||
end
|
||||
else
|
||||
if node and ends_with(node.name, ON_SUFFIX) then
|
||||
logistica.swap_node(pos, node.name:sub(1, #node.name - #ON_SUFFIX))
|
||||
end
|
||||
end
|
||||
logistica.set_node_tooltip_from_state(pos, nil, power)
|
||||
end
|
||||
|
||||
|
||||
function logistica.pump_timer(pos, _)
|
||||
local network = logistica.get_network_or_nil(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
|
||||
local count = 1
|
||||
local success = false
|
||||
local index = pump_get_index(meta)
|
||||
local owner = get_owner_name(meta)
|
||||
|
||||
local lastLayer = get_last_layer(meta)
|
||||
local lastLayerSuccess = get_last_layer_success(meta)
|
||||
|
||||
repeat
|
||||
local targetPosition = pump_index_to_position(pos, index)
|
||||
if targetPosition.y ~= lastLayer then
|
||||
-- new layer reached
|
||||
if lastLayerSuccess then -- let index continue as normal, but reset last layer success
|
||||
set_last_layer_success(meta, false)
|
||||
else -- reset index back to 0, and target position with it
|
||||
index = 0
|
||||
targetPosition = pump_index_to_position(pos, index)
|
||||
end
|
||||
set_last_layer(meta, targetPosition.y)
|
||||
end
|
||||
|
||||
local sourceInfo = get_valid_source(targetPosition, owner)
|
||||
if sourceInfo then
|
||||
local bucketItemStack = ItemStack(sourceInfo.bucketName)
|
||||
success = put_liquid_in_neighboring_reservoirs(pos, bucketItemStack)
|
||||
if not success then
|
||||
success = put_liquid_in_network_reservoirs(pos, bucketItemStack, network)
|
||||
end
|
||||
|
||||
if success then
|
||||
set_last_layer_success(meta, true)
|
||||
if not sourceInfo.isRenewable then -- renewable liquids are not removed to reduce lag
|
||||
minetest.remove_node(targetPosition)
|
||||
end
|
||||
end
|
||||
end
|
||||
index = (index + 1) % PUMP_INDEX_MAX
|
||||
count = count + 1
|
||||
until (count > MAX_CHECKS_PER_TIMER or success)
|
||||
|
||||
if success then logistica.start_node_timer(pos, TIMER_SHORT)
|
||||
else logistica.start_node_timer(pos, TIMER_LONG) end
|
||||
|
||||
pump_set_index(meta, index) -- save index even if no success
|
||||
|
||||
return false
|
||||
end
|
@ -204,6 +204,10 @@ function logistica.reservoir_get_all_buckets_to_names_map()
|
||||
return table.copy(BUCKET_TO_NAME)
|
||||
end
|
||||
|
||||
function logistica.reservoir_get_all_sources_to_names_map()
|
||||
return table.copy(SOURCE_TO_NAME)
|
||||
end
|
||||
|
||||
function logistica.reservoir_get_empty_bucket_for_liquid(liquidName)
|
||||
return get_empty_bucket_needed_for(liquidName)
|
||||
end
|
||||
|
@ -207,6 +207,27 @@ logistica.register_lava_furnace_fueler("Lava Furnace Fueler", "lava_furnace_fuel
|
||||
"logistica_fueler_front.png",
|
||||
})
|
||||
|
||||
--------------------------------
|
||||
-- Liquid Pump
|
||||
--------------------------------
|
||||
|
||||
logistica.register_pump("Liquid Pump", "pump",
|
||||
{
|
||||
"logistica_pump_top.png", "logistica_pump_bottom.png", "logistica_pump_side.png"
|
||||
},
|
||||
{ "logistica_pump_top.png", "logistica_pump_bottom.png", {
|
||||
image = "logistica_pump_side_on.png",
|
||||
backface_culling = false,
|
||||
animation = {
|
||||
type = "vertical_frames",
|
||||
aspect_w = 16,
|
||||
aspect_h = 16,
|
||||
length = 1
|
||||
},
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
--------------------------------
|
||||
-- Mass Storage
|
||||
--------------------------------
|
||||
|
@ -209,3 +209,12 @@ minetest.register_craft({
|
||||
{L("silverin_plate"), "", L("silverin_plate")},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = L("pump"),
|
||||
recipe = {
|
||||
{L("silverin_plate"), itemstrings.empty_bucket, L("silverin_plate")},
|
||||
{L("optic_cable"), itemstrings.crystal , L("photonizer")},
|
||||
{L("silverin_plate"), L("compression_tank"), L("silverin_plate")},
|
||||
}
|
||||
})
|
||||
|
@ -4,3 +4,5 @@ logistica_wap_upgrade_step (How much distance each upgrade to the WAP adds) int
|
||||
logistica_wifi_upgrader_hard_mode (Make Wireless Upgrader's minigame harder) bool false
|
||||
logistica_cable_size (Changes the visual/hitbox size of cables) enum Medium Small,Medium,Large,XLarge
|
||||
logistica_enable_large_liquid_tank (Enable the Large Liquid Tank) bool true
|
||||
logistica_pump_max_range (Sets from how far sideways from the Liquid Pump it can take liquids from) int 5 1 10
|
||||
logistica_pump_max_depth (Sets how far below the Liquid Pump it can take liquids from) int 5 1 32
|
||||
|
BIN
textures/logistica_pump_bottom.png
Normal file
BIN
textures/logistica_pump_bottom.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.1 KiB |
BIN
textures/logistica_pump_side.png
Normal file
BIN
textures/logistica_pump_side.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.2 KiB |
BIN
textures/logistica_pump_side_on.png
Normal file
BIN
textures/logistica_pump_side_on.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.6 KiB |
BIN
textures/logistica_pump_top.png
Normal file
BIN
textures/logistica_pump_top.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.2 KiB |
@ -8,9 +8,12 @@ local function get_bool (key, default)
|
||||
return minetest.settings:get_bool(L(key), default)
|
||||
end
|
||||
|
||||
local function get_int (key, default)
|
||||
local function get_int(key, default, min, max)
|
||||
local val = minetest.settings:get(L(key)) or default
|
||||
return tonumber(val)
|
||||
local result = tonumber(val)
|
||||
if min then result = math.max(min, result) end
|
||||
if max then result = math.min(max, result) end
|
||||
return result
|
||||
end
|
||||
|
||||
local function get_cable_size_from_settings()
|
||||
@ -25,12 +28,16 @@ end
|
||||
-- Settings
|
||||
--------------------------------
|
||||
|
||||
logistica.settings.wap_max_range = get_int("wap_max_range", 64000)
|
||||
logistica.settings.wap_max_range = get_int("wap_max_range", 64000, 1, 64000)
|
||||
|
||||
logistica.settings.wap_upgrade_step = get_int("wap_upgrade_step", 250)
|
||||
logistica.settings.wap_upgrade_step = get_int("wap_upgrade_step", 250, 10, 5000)
|
||||
|
||||
logistica.settings.wifi_upgrader_hard_mode = get_bool("wifi_upgrader_hard_mode", false)
|
||||
|
||||
logistica.settings.cable_size = get_cable_size_from_settings()
|
||||
|
||||
logistica.settings.large_liquid_tank_enabled = get_bool("enable_large_liquid_tank", true)
|
||||
|
||||
logistica.settings.pump_max_range = get_int("pump_max_range", 5, 1, 10)
|
||||
|
||||
logistica.settings.pump_max_depth = get_int("pump_max_depth", 5, 1, 32)
|
||||
|
Loading…
x
Reference in New Issue
Block a user