Fix mass storage rotation; Added a misc machine category; Cleanup and minor improvements
This commit is contained in:
parent
92914ba66b
commit
3b0ecb62e5
@ -40,10 +40,16 @@ local function after_controller_place(pos)
|
||||
logistica.start_controller_timer(pos)
|
||||
end
|
||||
|
||||
----------------------------------------------------------------
|
||||
-- registration stuff
|
||||
----------------------------------------------------------------
|
||||
|
||||
minetest.register_on_player_receive_fields(on_controller_receive_fields)
|
||||
|
||||
----------------------------------------------------------------
|
||||
-- Public Registration API
|
||||
----------------------------------------------------------------
|
||||
|
||||
--[[
|
||||
The definition table will get the fololwing fields overriden (and currently originals are not called):
|
||||
- on_construct
|
||||
|
@ -315,8 +315,8 @@ local function on_mass_storage_right_click(pos, node, clicker, itemstack, pointe
|
||||
show_mass_storage_formspec(pos, name)
|
||||
end
|
||||
|
||||
local function on_mass_storage_rotate(pos, node, player, mode)
|
||||
logistica.update_mass_storage_front_image(pos)
|
||||
local function on_mass_storage_rotate(pos, node, player, mode, newParam2)
|
||||
logistica.update_mass_storage_front_image(pos, newParam2)
|
||||
end
|
||||
|
||||
----------------------------------------------------------------
|
||||
@ -329,7 +329,7 @@ minetest.register_on_player_receive_fields(on_receive_storage_formspec)
|
||||
-- Public Registration API
|
||||
----------------------------------------------------------------
|
||||
|
||||
function logistica.register_mass_storage(simpleName, numSlots, numItemsPerSlot, numUpgradeSlots)
|
||||
function logistica.register_mass_storage(simpleName, description, numSlots, numItemsPerSlot, numUpgradeSlots, tiles)
|
||||
local lname = string.lower(string.gsub(simpleName, " ", "_"))
|
||||
local storageName = "logistica:mass_storage_"..lname
|
||||
local grps = {cracky = 1, choppy = 1, oddly_breakable_by_hand = 1}
|
||||
@ -338,10 +338,8 @@ function logistica.register_mass_storage(simpleName, numSlots, numItemsPerSlot,
|
||||
logistica.mass_storage[storageName] = true
|
||||
|
||||
local def = {
|
||||
description = simpleName.." Mass Storage\n(Empty)",
|
||||
tiles = { "logistica_"..lname.."_mass_storage.png", "logistica_"..lname.."_mass_storage.png",
|
||||
"logistica_"..lname.."_mass_storage.png", "logistica_"..lname.."_mass_storage.png",
|
||||
"logistica_"..lname.."_mass_storage.png", "logistica_"..lname.."_mass_storage_front.png" },
|
||||
description = description.."\n(Empty)",
|
||||
tiles = tiles,
|
||||
groups = grps,
|
||||
sounds = logistica.node_sound_metallic(),
|
||||
after_place_node = function(pos, placer, itemstack)
|
||||
@ -352,7 +350,7 @@ function logistica.register_mass_storage(simpleName, numSlots, numItemsPerSlot,
|
||||
on_timer = logistica.on_timer_powered(logistica.on_mass_storage_timer),
|
||||
paramtype2 = "facedir",
|
||||
logistica = {
|
||||
baseName = simpleName.." Mass Storage",
|
||||
baseName = description,
|
||||
maxItems = numItemsPerSlot,
|
||||
numSlots = numSlots,
|
||||
numUpgradeSlots = numUpgradeSlots,
|
||||
@ -391,4 +389,8 @@ function logistica.register_mass_storage(simpleName, numSlots, numItemsPerSlot,
|
||||
|
||||
end
|
||||
|
||||
logistica.register_mass_storage("Basic", 8, 1024, 4)
|
||||
logistica.register_mass_storage("basic", "Mass Storage", 8, 1024, 4, {
|
||||
"logistica_basic_mass_storage.png", "logistica_basic_mass_storage.png",
|
||||
"logistica_basic_mass_storage.png", "logistica_basic_mass_storage.png",
|
||||
"logistica_basic_mass_storage.png", "logistica_basic_mass_storage_front.png"
|
||||
})
|
||||
|
@ -9,12 +9,12 @@ local function get_supplier_formspec(pos)
|
||||
local isOn = logistica.is_machine_on(pos)
|
||||
|
||||
return "formspec_version[4]" ..
|
||||
"size[10.5,12]" ..
|
||||
"size[10.5,10]" ..
|
||||
logistica.ui.background..
|
||||
logistica.ui.on_off_btn(isOn, 7.0, 0.3, ON_OFF_BUTTON, "Allow Storage from Network")..
|
||||
logistica.ui.on_off_btn(isOn, 7.0, 0.5, ON_OFF_BUTTON, "Allow Storing from Network")..
|
||||
"label[0.6,1.0;Passive Supplier: Items become available to network requests.]"..
|
||||
"list["..posForm..";main;0.4,1.4;8,4;0]"..
|
||||
"list[current_player;main;0.4,7.0;8,4;0]"..
|
||||
"list["..posForm..";main;0.4,1.4;8,2;0]"..
|
||||
"list[current_player;main;0.4,4.5;8,4;0]"..
|
||||
"listring[]"
|
||||
end
|
||||
|
||||
@ -91,7 +91,7 @@ minetest.register_on_player_receive_fields(on_player_receive_fields)
|
||||
-- Public Registration API
|
||||
----------------------------------------------------------------
|
||||
-- `simpleName` is used for the description and for the name (can contain spaces)
|
||||
-- `inventorySize` should be 32 at max (aka regular chest)
|
||||
-- `inventorySize` should be 16 at max
|
||||
function logistica.register_supplier(desc, name, inventorySize, tiles)
|
||||
local lname = string.lower(name:gsub(" ", "_"))
|
||||
local supplier_name = "logistica:passive_supplier_"..lname
|
||||
|
@ -54,7 +54,8 @@ function logistica.remove_item_on_block_front(pos, optionalId)
|
||||
end
|
||||
end
|
||||
|
||||
function logistica.display_item_on_block_front(pos, item)
|
||||
-- `newParam2` is optional, will override the lookup of node.param2 for rotation
|
||||
function logistica.display_item_on_block_front(pos, item, newParam2)
|
||||
if item == nil or item == "" then return logistica.remove_item_on_block_front(pos) end
|
||||
local node = minetest.get_node(pos)
|
||||
if not node then return end
|
||||
@ -62,7 +63,7 @@ function logistica.display_item_on_block_front(pos, item)
|
||||
|
||||
logistica.remove_item_on_block_front(pos, id)
|
||||
|
||||
local adjust = logistica.get_front_face_object_info(node.param2)
|
||||
local adjust = logistica.get_front_face_object_info(newParam2 or node.param2)
|
||||
if not adjust then return end
|
||||
|
||||
pos.x = pos.x + adjust.x * ENTITY_DIST_ADJ
|
||||
|
@ -5,7 +5,7 @@ logistica.requesters = {}
|
||||
logistica.suppliers = {}
|
||||
logistica.mass_storage = {}
|
||||
logistica.item_storage = {}
|
||||
-- logistica.request_and_supplier = {}
|
||||
logistica.misc_machines = {}
|
||||
logistica.tiers = {}
|
||||
logistica.TIER_ALL = "logistica_all_tiers"
|
||||
logistica.GROUP_ALL = "group:" .. logistica.TIER_ALL
|
||||
@ -22,6 +22,7 @@ end
|
||||
function logistica.is_machine(name)
|
||||
return logistica.is_requester(name) or logistica.is_supplier(name) or logistica.is_mass_storage(name)
|
||||
or logistica.is_item_storage(name) or logistica.is_controller(name) or logistica.is_injector(name)
|
||||
or logistica.is_misc(name)
|
||||
end
|
||||
|
||||
function logistica.is_cable(name)
|
||||
@ -52,6 +53,10 @@ function logistica.is_injector(name)
|
||||
return logistica.injectors[name] ~= nil
|
||||
end
|
||||
|
||||
function logistica.is_misc(name)
|
||||
return logistica.misc_machines[name] ~= nil
|
||||
end
|
||||
|
||||
function logistica.get_item_tiers(name)
|
||||
local tiers = {}
|
||||
for tier,_ in pairs(logistica.tiers) do
|
||||
|
@ -213,14 +213,15 @@ function logistica.get_mass_storage_reserve(meta, index)
|
||||
return meta:get_int(META_RES_VAL..tostring(index))
|
||||
end
|
||||
|
||||
function logistica.update_mass_storage_front_image(origPos)
|
||||
-- `newParam2` is optional, will override the lookup of node.param2 for rotation
|
||||
function logistica.update_mass_storage_front_image(origPos, newParam2)
|
||||
local pos = vector.new(origPos)
|
||||
logistica.remove_item_on_block_front(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local slot = logistica.get_mass_storage_image_slot(meta)
|
||||
if slot > 0 then
|
||||
local item = meta:get_inventory():get_list("filter")[slot] or ItemStack("")
|
||||
logistica.display_item_on_block_front(pos, item:get_name())
|
||||
logistica.display_item_on_block_front(pos, item:get_name(), newParam2)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -63,8 +63,8 @@ function logistica.get_network_id_or_nil(pos)
|
||||
if not network then return nil else return network.controller end
|
||||
end
|
||||
|
||||
local function notify_connected(pos, node, networkId)
|
||||
local def = minetest.registered_nodes[node.name]
|
||||
local function notify_connected(pos, nodeName, networkId)
|
||||
local def = minetest.registered_nodes[nodeName]
|
||||
if def and def.logistica and def.logistica.on_connect_to_network then
|
||||
def.logistica.on_connect_to_network(pos, networkId)
|
||||
end
|
||||
@ -120,7 +120,7 @@ local function recursive_scan_for_nodes_for_controller(network, positionHashes,
|
||||
for _, offset in pairs(adjecent) do
|
||||
local otherPos = vector.add(pos, offset)
|
||||
logistica.load_position(otherPos)
|
||||
local otherNode = minetest.get_node(otherPos)
|
||||
local otherName = minetest.get_node(otherPos).name
|
||||
local otherHash = p2h(otherPos)
|
||||
if network.controller ~= otherHash
|
||||
and not has_machine(network, otherHash)
|
||||
@ -136,29 +136,32 @@ local function recursive_scan_for_nodes_for_controller(network, positionHashes,
|
||||
return CREATE_NETWORK_STATUS_FAIL_OTHER_NETWORK
|
||||
end
|
||||
local valid = false
|
||||
if logistica.is_cable(otherNode.name) then
|
||||
if logistica.is_cable(otherName) then
|
||||
network.cables[otherHash] = true
|
||||
connections[otherHash] = true
|
||||
valid = true
|
||||
elseif logistica.is_requester(otherNode.name) then
|
||||
elseif logistica.is_requester(otherName) then
|
||||
network.requesters[otherHash] = true
|
||||
valid = true
|
||||
elseif logistica.is_injector(otherNode.name) then
|
||||
elseif logistica.is_injector(otherName) then
|
||||
network.injectors[otherHash] = true
|
||||
valid = true
|
||||
elseif logistica.is_supplier(otherNode.name) then
|
||||
elseif logistica.is_supplier(otherName) then
|
||||
network.suppliers[otherHash] = true
|
||||
valid = true
|
||||
elseif logistica.is_mass_storage(otherNode.name) then
|
||||
elseif logistica.is_mass_storage(otherName) then
|
||||
network.mass_storage[otherHash] = true
|
||||
valid = true
|
||||
elseif logistica.is_item_storage(otherNode.name) then
|
||||
elseif logistica.is_item_storage(otherName) then
|
||||
network.item_storage[otherHash] = true
|
||||
valid = true
|
||||
elseif logistica.is_misc(otherName) then
|
||||
network.misc[otherHash] = true
|
||||
valid = true
|
||||
end
|
||||
if valid then
|
||||
newToScan = newToScan + 1
|
||||
notify_connected(otherPos, otherNode, network.controller)
|
||||
notify_connected(otherPos, otherName, network.controller)
|
||||
end
|
||||
end -- end if tiersMatch
|
||||
end -- end of general checks
|
||||
@ -192,6 +195,7 @@ local function create_network(controllerPosition, oldNetworkName)
|
||||
network.storage_cache = {}
|
||||
network.supplier_cache = {}
|
||||
network.requester_cache = {}
|
||||
network.misc = {}
|
||||
local startPos = {}
|
||||
startPos[controllerHash] = true
|
||||
local status = recursive_scan_for_nodes_for_controller(network, startPos)
|
||||
|
@ -34,5 +34,4 @@ function logistica.show_popup(playerName, text, time)
|
||||
playerHud[playerName] = nil
|
||||
end)
|
||||
playerHud[playerName].job = job
|
||||
|
||||
end
|
||||
end
|
||||
|
@ -1,4 +1,3 @@
|
||||
local S = logistica.TRANSLATOR
|
||||
local LANG_EN = "en"
|
||||
|
||||
--------------------------------
|
||||
|
Loading…
x
Reference in New Issue
Block a user