Rename mod
@ -1,4 +1,4 @@
|
||||
# Storagetest
|
||||
# Holostorage
|
||||
![](screenshot.png)
|
||||
A solution to your hoarding addiction. In [Minetest](http://minetest.net).
|
||||
|
||||
|
8
init.lua
@ -1,11 +1,11 @@
|
||||
-- Storagetest
|
||||
-- holostorage
|
||||
|
||||
storagetest = rawget(_G, "storagetest") or {}
|
||||
holostorage = rawget(_G, "holostorage") or {}
|
||||
|
||||
local modpath = minetest.get_modpath(minetest.get_current_modname())
|
||||
storagetest.modpath = modpath
|
||||
holostorage.modpath = modpath
|
||||
|
||||
storagetest.devices = {}
|
||||
holostorage.devices = {}
|
||||
|
||||
-- Network
|
||||
dofile(modpath.."/network.lua")
|
||||
|
@ -1,4 +1,4 @@
|
||||
-- Storagetest items
|
||||
-- holostorage items
|
||||
|
||||
-- Drives
|
||||
dofile(storagetest.modpath.."/items/storage_disk.lua")
|
||||
dofile(holostorage.modpath.."/items/storage_disk.lua")
|
||||
|
@ -1,7 +1,7 @@
|
||||
-- Storage disks
|
||||
|
||||
storagetest.disks = {}
|
||||
storagetest.disks.memcache = {}
|
||||
holostorage.disks = {}
|
||||
holostorage.disks.memcache = {}
|
||||
|
||||
local function inv_to_table(inv)
|
||||
local t = {}
|
||||
@ -25,14 +25,14 @@ local function table_to_inv(inv, t)
|
||||
end
|
||||
end
|
||||
|
||||
function storagetest.disks.register_disk(index, desc, capacity)
|
||||
function holostorage.disks.register_disk(index, desc, capacity)
|
||||
local mod = minetest.get_current_modname()
|
||||
minetest.register_craftitem(mod..":storage_disk"..index, {
|
||||
description = desc.."\nStores "..capacity.." Stacks",
|
||||
inventory_image = "storagetest_disk"..index..".png",
|
||||
groups = {storagetest_disk = 1},
|
||||
storagetest_capacity = capacity,
|
||||
storagetest_name = "disk"..index,
|
||||
inventory_image = "holostorage_disk"..index..".png",
|
||||
groups = {holostorage_disk = 1},
|
||||
holostorage_capacity = capacity,
|
||||
holostorage_name = "disk"..index,
|
||||
stack_max = 1,
|
||||
on_secondary_use = function (itemstack, user, pointed_thing)
|
||||
return stack
|
||||
@ -46,26 +46,26 @@ local function create_invref(ptr, capacity)
|
||||
return inv
|
||||
end
|
||||
|
||||
function storagetest.disks.ensure_disk_inventory(stack, pstr)
|
||||
function holostorage.disks.ensure_disk_inventory(stack, pstr)
|
||||
local meta = stack:get_meta()
|
||||
local tag = meta:get_string("storage_tag")
|
||||
local cap = minetest.registered_items[stack:get_name()].storagetest_capacity
|
||||
local cap = minetest.registered_items[stack:get_name()].holostorage_capacity
|
||||
|
||||
if not tag or tag == "" then
|
||||
local rnd = PseudoRandom(os.clock())
|
||||
local rndint = rnd.next(rnd)
|
||||
local diskid = "d"..pstr.."-"..rndint
|
||||
meta:set_string("storage_tag", diskid)
|
||||
storagetest.disks.memcache[diskid] = create_invref(diskid, cap)
|
||||
holostorage.disks.memcache[diskid] = create_invref(diskid, cap)
|
||||
end
|
||||
|
||||
return stack
|
||||
end
|
||||
|
||||
function storagetest.disks.load_disk_from_file(stack, diskptr)
|
||||
function holostorage.disks.load_disk_from_file(stack, diskptr)
|
||||
local world = minetest.get_worldpath()
|
||||
local directory = world.."/storagetest"
|
||||
local cap = minetest.registered_items[stack:get_name()].storagetest_capacity
|
||||
local directory = world.."/holostorage"
|
||||
local cap = minetest.registered_items[stack:get_name()].holostorage_capacity
|
||||
local inv = create_invref(diskptr, cap)
|
||||
minetest.mkdir(directory)
|
||||
|
||||
@ -73,7 +73,7 @@ function storagetest.disks.load_disk_from_file(stack, diskptr)
|
||||
local file = io.open(directory.."/"..filetag)
|
||||
|
||||
if not file then
|
||||
storagetest.disks.memcache[diskptr] = inv
|
||||
holostorage.disks.memcache[diskptr] = inv
|
||||
return diskptr
|
||||
end
|
||||
|
||||
@ -85,45 +85,45 @@ function storagetest.disks.load_disk_from_file(stack, diskptr)
|
||||
file:close()
|
||||
|
||||
table_to_inv(inv, minetest.deserialize(str))
|
||||
storagetest.disks.memcache[diskptr] = inv
|
||||
holostorage.disks.memcache[diskptr] = inv
|
||||
return diskptr
|
||||
end
|
||||
|
||||
function storagetest.disks.save_disk_to_file(diskptr)
|
||||
if not storagetest.disks.memcache[diskptr] then return nil end
|
||||
function holostorage.disks.save_disk_to_file(diskptr)
|
||||
if not holostorage.disks.memcache[diskptr] then return nil end
|
||||
|
||||
local world = minetest.get_worldpath()
|
||||
local directory = world.."/storagetest"
|
||||
local directory = world.."/holostorage"
|
||||
local filetag = minetest.sha1(diskptr)..".invref"
|
||||
|
||||
minetest.mkdir(directory)
|
||||
|
||||
local inv = storagetest.disks.memcache[diskptr]
|
||||
local inv = holostorage.disks.memcache[diskptr]
|
||||
local data = minetest.serialize(inv_to_table(inv))
|
||||
|
||||
minetest.safe_file_write(directory.."/"..filetag, data)
|
||||
return diskptr
|
||||
end
|
||||
|
||||
function storagetest.disks.save_disks_to_file()
|
||||
for diskptr in pairs(storagetest.disks.memcache) do
|
||||
storagetest.disks.save_disk_to_file(diskptr)
|
||||
function holostorage.disks.save_disks_to_file()
|
||||
for diskptr in pairs(holostorage.disks.memcache) do
|
||||
holostorage.disks.save_disk_to_file(diskptr)
|
||||
end
|
||||
end
|
||||
|
||||
-- Make sure stack is disk
|
||||
function storagetest.disks.is_valid_disk(stack)
|
||||
function holostorage.disks.is_valid_disk(stack)
|
||||
local stack_name = stack:get_name()
|
||||
return minetest.get_item_group(stack_name, "storagetest_disk") > 0
|
||||
return minetest.get_item_group(stack_name, "holostorage_disk") > 0
|
||||
end
|
||||
|
||||
-- Save disks on shutdown
|
||||
minetest.register_on_shutdown(function ()
|
||||
storagetest.disks.save_disks_to_file()
|
||||
holostorage.disks.save_disks_to_file()
|
||||
end)
|
||||
|
||||
local capacities = {1000, 8000, 16000, 32000, 64000}
|
||||
local descriptions = {"1K Disk", "8K Disk", "16K Disk", "32K Disk", "64K Disk"}
|
||||
for i = 1, 5 do
|
||||
storagetest.disks.register_disk(i, descriptions[i], capacities[i])
|
||||
holostorage.disks.register_disk(i, descriptions[i], capacities[i])
|
||||
end
|
||||
|
2
mod.conf
@ -1,3 +1,3 @@
|
||||
name = storagetest
|
||||
name = holostorage
|
||||
description = A solution to your hoarding addiction.
|
||||
depends = default
|
||||
|
148
network.lua
@ -1,12 +1,12 @@
|
||||
-- Storagetest Network
|
||||
-- holostorage Network
|
||||
-- Some code borrowed from Technic (https://github.com/minetest-mods/technic/blob/master/technic/machines/switching_station.lua)
|
||||
|
||||
storagetest.network = {}
|
||||
storagetest.network.networks = {}
|
||||
storagetest.network.devices = {}
|
||||
storagetest.network.redundant_warn = {}
|
||||
holostorage.network = {}
|
||||
holostorage.network.networks = {}
|
||||
holostorage.network.devices = {}
|
||||
holostorage.network.redundant_warn = {}
|
||||
|
||||
function storagetest.get_or_load_node(pos)
|
||||
function holostorage.get_or_load_node(pos)
|
||||
local node = minetest.get_node_or_nil(pos)
|
||||
if node then return node end
|
||||
local vm = VoxelManip()
|
||||
@ -18,12 +18,12 @@ local function get_item_group(name, grp)
|
||||
return minetest.get_item_group(name, grp) > 0
|
||||
end
|
||||
|
||||
function storagetest.network.is_network_conductor(name)
|
||||
return get_item_group(name, "storagetest_distributor")
|
||||
function holostorage.network.is_network_conductor(name)
|
||||
return get_item_group(name, "holostorage_distributor")
|
||||
end
|
||||
|
||||
function storagetest.network.is_network_device(name)
|
||||
return get_item_group(name, "storagetest_device")
|
||||
function holostorage.network.is_network_device(name)
|
||||
return get_item_group(name, "holostorage_device")
|
||||
end
|
||||
|
||||
-----------------------
|
||||
@ -41,7 +41,7 @@ end
|
||||
-- Add a node to the network
|
||||
local function add_network_node(nodes, pos, network_id)
|
||||
local node_id = minetest.hash_node_position(pos)
|
||||
storagetest.network.devices[node_id] = network_id
|
||||
holostorage.network.devices[node_id] = network_id
|
||||
if nodes[node_id] then
|
||||
return false
|
||||
end
|
||||
@ -56,23 +56,23 @@ local function add_cable_node(nodes, pos, network_id, queue)
|
||||
end
|
||||
|
||||
local check_node_subp = function(dv_nodes, st_nodes, controllers, all_nodes, pos, devices, c_pos, network_id, queue)
|
||||
storagetest.get_or_load_node(pos)
|
||||
holostorage.get_or_load_node(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local name = minetest.get_node(pos).name
|
||||
|
||||
if storagetest.network.is_network_conductor(name) then
|
||||
if holostorage.network.is_network_conductor(name) then
|
||||
add_cable_node(all_nodes, pos, network_id, queue)
|
||||
end
|
||||
|
||||
if devices[name] then
|
||||
meta:set_string("st_network", minetest.pos_to_string(c_pos))
|
||||
if get_item_group(name, "storagetest_controller") then
|
||||
if get_item_group(name, "holostorage_controller") then
|
||||
-- Another controller, disable it
|
||||
add_network_node(controllers, pos, network_id)
|
||||
meta:set_int("active", 0)
|
||||
elseif get_item_group(name, "storagetest_storage") then
|
||||
elseif get_item_group(name, "holostorage_storage") then
|
||||
add_network_node(st_nodes, pos, network_id)
|
||||
elseif storagetest.network.is_network_device(name) then
|
||||
elseif holostorage.network.is_network_device(name) then
|
||||
add_network_node(dv_nodes, pos, network_id)
|
||||
end
|
||||
|
||||
@ -103,7 +103,7 @@ end
|
||||
|
||||
local function get_network(c_pos, positions)
|
||||
local network_id = minetest.hash_node_position(c_pos)
|
||||
local cached = storagetest.network.networks[network_id]
|
||||
local cached = holostorage.network.networks[network_id]
|
||||
|
||||
if cached then
|
||||
touch_nodes(cached.dv_nodes)
|
||||
@ -126,9 +126,9 @@ local function get_network(c_pos, positions)
|
||||
queue = {}
|
||||
|
||||
local node = minetest.get_node(pos)
|
||||
if node and storagetest.network.is_network_conductor(node.name) and not storagetest.network.is_network_device(node.name) then
|
||||
if node and holostorage.network.is_network_conductor(node.name) and not holostorage.network.is_network_device(node.name) then
|
||||
add_cable_node(all_nodes, pos, network_id, queue)
|
||||
elseif node and storagetest.network.is_network_device(node.name) then
|
||||
elseif node and holostorage.network.is_network_device(node.name) then
|
||||
queue = {c_pos}
|
||||
end
|
||||
|
||||
@ -136,7 +136,7 @@ local function get_network(c_pos, positions)
|
||||
local to_visit = {}
|
||||
for _, posi in ipairs(queue) do
|
||||
traverse_network(dv_nodes, st_nodes, controllers, all_nodes,
|
||||
posi, storagetest.devices, c_pos, network_id, to_visit)
|
||||
posi, holostorage.devices, c_pos, network_id, to_visit)
|
||||
end
|
||||
queue = to_visit
|
||||
end
|
||||
@ -147,7 +147,7 @@ local function get_network(c_pos, positions)
|
||||
controllers = flatten(controllers)
|
||||
all_nodes = flatten(all_nodes)
|
||||
|
||||
storagetest.network.networks[network_id] = {all_nodes = all_nodes, dv_nodes = dv_nodes,
|
||||
holostorage.network.networks[network_id] = {all_nodes = all_nodes, dv_nodes = dv_nodes,
|
||||
st_nodes = st_nodes, controllers = controllers}
|
||||
return dv_nodes, st_nodes
|
||||
end
|
||||
@ -156,29 +156,29 @@ end
|
||||
-- Controller ABM --
|
||||
--------------------
|
||||
|
||||
storagetest.network.active_state = true
|
||||
holostorage.network.active_state = true
|
||||
|
||||
minetest.register_chatcommand("storagectl", {
|
||||
params = "state",
|
||||
description = "Enables or disables Storagetest's storage controller ABM",
|
||||
description = "Enables or disables holostorage's storage controller ABM",
|
||||
privs = { basic_privs = true },
|
||||
func = function(name, state)
|
||||
if state == "on" then
|
||||
storagetest.network.active_state = true
|
||||
holostorage.network.active_state = true
|
||||
else
|
||||
storagetest.network.active_state = false
|
||||
holostorage.network.active_state = false
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
function storagetest.network.register_abm_controller(name)
|
||||
function holostorage.network.register_abm_controller(name)
|
||||
minetest.register_abm({
|
||||
nodenames = {name},
|
||||
label = "Storage Controller", -- allows the mtt profiler to profile this abm individually
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
if not storagetest.network.active_state then return end
|
||||
if not holostorage.network.active_state then return end
|
||||
local meta = minetest.get_meta(pos)
|
||||
local meta1 = nil
|
||||
|
||||
@ -207,16 +207,16 @@ function storagetest.network.register_abm_controller(name)
|
||||
|
||||
local poshash = minetest.hash_node_position(pos)
|
||||
|
||||
if not storagetest.network.redundant_warn[poshash] then
|
||||
storagetest.network.redundant_warn[poshash] = true
|
||||
print("[Storagetest] Warning: redundant controller found near "..minetest.pos_to_string(pos))
|
||||
if not holostorage.network.redundant_warn[poshash] then
|
||||
holostorage.network.redundant_warn[poshash] = true
|
||||
print("[holostorage] Warning: redundant controller found near "..minetest.pos_to_string(pos))
|
||||
end
|
||||
errored = true
|
||||
return
|
||||
end
|
||||
|
||||
local name = minetest.get_node(pos1).name
|
||||
local networked = storagetest.network.is_network_conductor(name)
|
||||
local networked = holostorage.network.is_network_conductor(name)
|
||||
if networked then
|
||||
ntwks[pos1] = true
|
||||
nw_branches = nw_branches + 1
|
||||
@ -240,14 +240,14 @@ function storagetest.network.register_abm_controller(name)
|
||||
-- Run all the nodes
|
||||
local function run_nodes(list)
|
||||
for _, pos2 in ipairs(list) do
|
||||
storagetest.get_or_load_node(pos2)
|
||||
holostorage.get_or_load_node(pos2)
|
||||
local node2 = minetest.get_node(pos2)
|
||||
local nodedef
|
||||
if node2 and node2.name then
|
||||
nodedef = minetest.registered_nodes[node2.name]
|
||||
end
|
||||
if nodedef and nodedef.storagetest_run then
|
||||
nodedef.storagetest_run(pos2, node2, pos)
|
||||
if nodedef and nodedef.holostorage_run then
|
||||
nodedef.holostorage_run(pos2, node2, pos)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -266,7 +266,7 @@ end
|
||||
|
||||
local function check_connections(pos)
|
||||
local machines = {}
|
||||
for name in pairs(storagetest.devices) do
|
||||
for name in pairs(holostorage.devices) do
|
||||
machines[name] = true
|
||||
end
|
||||
local connections = {}
|
||||
@ -279,14 +279,14 @@ local function check_connections(pos)
|
||||
{x=pos.x, y=pos.y, z=pos.z-1}}
|
||||
for _,connected_pos in pairs(positions) do
|
||||
local name = minetest.get_node(connected_pos).name
|
||||
if machines[name] or storagetest.network.is_network_conductor(name) or get_item_group(name, "storagetest_controller") then
|
||||
if machines[name] or holostorage.network.is_network_conductor(name) or get_item_group(name, "holostorage_controller") then
|
||||
table.insert(connections,connected_pos)
|
||||
end
|
||||
end
|
||||
return connections
|
||||
end
|
||||
|
||||
function storagetest.network.clear_networks(pos)
|
||||
function holostorage.network.clear_networks(pos)
|
||||
local node = minetest.get_node(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local name = node.name
|
||||
@ -295,52 +295,52 @@ function storagetest.network.clear_networks(pos)
|
||||
if #positions < 1 then return end
|
||||
local dead_end = #positions == 1
|
||||
for _,connected_pos in pairs(positions) do
|
||||
local net = storagetest.network.devices[minetest.hash_node_position(connected_pos)] or minetest.hash_node_position(connected_pos)
|
||||
if net and storagetest.network.networks[net] then
|
||||
local net = holostorage.network.devices[minetest.hash_node_position(connected_pos)] or minetest.hash_node_position(connected_pos)
|
||||
if net and holostorage.network.networks[net] then
|
||||
if dead_end and placed then
|
||||
-- Dead end placed, add it to the network
|
||||
-- Get the network
|
||||
local node_at = minetest.get_node(positions[1])
|
||||
local network_id = storagetest.network.devices[minetest.hash_node_position(positions[1])] or minetest.hash_node_position(positions[1])
|
||||
local network_id = holostorage.network.devices[minetest.hash_node_position(positions[1])] or minetest.hash_node_position(positions[1])
|
||||
|
||||
if not network_id or not storagetest.network.networks[network_id] then
|
||||
if not network_id or not holostorage.network.networks[network_id] then
|
||||
-- We're evidently not on a network, nothing to add ourselves to
|
||||
return
|
||||
end
|
||||
local c_pos = minetest.get_position_from_hash(network_id)
|
||||
local network = storagetest.network.networks[network_id]
|
||||
local network = holostorage.network.networks[network_id]
|
||||
|
||||
-- Actually add it to the (cached) network
|
||||
-- This is similar to check_node_subp
|
||||
storagetest.network.devices[minetest.hash_node_position(pos)] = network_id
|
||||
holostorage.network.devices[minetest.hash_node_position(pos)] = network_id
|
||||
pos.visited = 1
|
||||
|
||||
if storagetest.network.is_network_conductor(name) then
|
||||
if holostorage.network.is_network_conductor(name) then
|
||||
table.insert(network.all_nodes, pos)
|
||||
end
|
||||
|
||||
if storagetest.devices[name] then
|
||||
if holostorage.devices[name] then
|
||||
meta:set_string("st_network", minetest.pos_to_string(c_pos))
|
||||
if get_item_group(name, "storagetest_controller") then
|
||||
if get_item_group(name, "holostorage_controller") then
|
||||
table.insert(network.controllers, pos)
|
||||
elseif get_item_group(name, "storagetest_storage") then
|
||||
elseif get_item_group(name, "holostorage_storage") then
|
||||
table.insert(network.st_nodes, pos)
|
||||
elseif storagetest.network.is_network_device(name) then
|
||||
elseif holostorage.network.is_network_device(name) then
|
||||
table.insert(network.dv_nodes, pos)
|
||||
end
|
||||
end
|
||||
elseif dead_end and not placed then
|
||||
-- Dead end removed, remove it from the network
|
||||
-- Get the network
|
||||
local network_id = storagetest.network.devices[minetest.hash_node_position(positions[1])] or minetest.hash_node_position(positions[1])
|
||||
if not network_id or not storagetest.network.networks[network_id] then
|
||||
local network_id = holostorage.network.devices[minetest.hash_node_position(positions[1])] or minetest.hash_node_position(positions[1])
|
||||
if not network_id or not holostorage.network.networks[network_id] then
|
||||
-- We're evidently not on a network, nothing to remove ourselves from
|
||||
return
|
||||
end
|
||||
local network = storagetest.network.networks[network_id]
|
||||
local network = holostorage.network.networks[network_id]
|
||||
|
||||
-- Search for and remove device
|
||||
storagetest.network.devices[minetest.hash_node_position(pos)] = nil
|
||||
holostorage.network.devices[minetest.hash_node_position(pos)] = nil
|
||||
for tblname,table in pairs(network) do
|
||||
for devicenum,device in pairs(table) do
|
||||
if device.x == pos.x
|
||||
@ -352,11 +352,11 @@ function storagetest.network.clear_networks(pos)
|
||||
end
|
||||
else
|
||||
-- Not a dead end, so the whole network needs to be recalculated
|
||||
for _,v in pairs(storagetest.network.networks[net].all_nodes) do
|
||||
for _,v in pairs(holostorage.network.networks[net].all_nodes) do
|
||||
local pos1 = minetest.hash_node_position(v)
|
||||
storagetest.network.devices[pos1] = nil
|
||||
holostorage.network.devices[pos1] = nil
|
||||
end
|
||||
storagetest.network.networks[net] = nil
|
||||
holostorage.network.networks[net] = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -376,21 +376,21 @@ local function controller_timeout_count(pos, tier)
|
||||
end
|
||||
end
|
||||
|
||||
function storagetest.network.register_abm_nodes()
|
||||
function holostorage.network.register_abm_nodes()
|
||||
minetest.register_abm({
|
||||
label = "Devices: timeout check",
|
||||
nodenames = {"group:storagetest_device"},
|
||||
nodenames = {"group:holostorage_device"},
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if storagetest.devices[node.name] and controller_timeout_count(pos) then
|
||||
if holostorage.devices[node.name] and controller_timeout_count(pos) then
|
||||
local nodedef = minetest.registered_nodes[node.name]
|
||||
if nodedef and nodedef.storagetest_disabled_name then
|
||||
node.name = nodedef.storagetest_disabled_name
|
||||
if nodedef and nodedef.holostorage_disabled_name then
|
||||
node.name = nodedef.holostorage_disabled_name
|
||||
minetest.swap_node(pos, node)
|
||||
elseif nodedef and nodedef.storagetest_on_disable then
|
||||
nodedef.storagetest_on_disable(pos, node)
|
||||
elseif nodedef and nodedef.holostorage_on_disable then
|
||||
nodedef.holostorage_on_disable(pos, node)
|
||||
end
|
||||
if nodedef then
|
||||
local meta = minetest.get_meta(pos)
|
||||
@ -405,8 +405,8 @@ end
|
||||
-- Network Functions --
|
||||
-----------------------
|
||||
|
||||
function storagetest.network.get_storage_devices(network_id)
|
||||
local network = storagetest.network.networks[network_id]
|
||||
function holostorage.network.get_storage_devices(network_id)
|
||||
local network = holostorage.network.networks[network_id]
|
||||
if not network or not network.st_nodes then return {} end
|
||||
return network.st_nodes
|
||||
end
|
||||
@ -418,23 +418,23 @@ function concat(t1,t2)
|
||||
return t1
|
||||
end
|
||||
|
||||
function storagetest.network.get_storage_inventories(network_id)
|
||||
local storage_nodes = storagetest.network.get_storage_devices(network_id)
|
||||
function holostorage.network.get_storage_inventories(network_id)
|
||||
local storage_nodes = holostorage.network.get_storage_devices(network_id)
|
||||
local items = {}
|
||||
|
||||
for _,pos in pairs(storage_nodes) do
|
||||
local stacks = storagetest.stack_list(pos)
|
||||
local stacks = holostorage.stack_list(pos)
|
||||
items = concat(items, stacks)
|
||||
end
|
||||
|
||||
return items
|
||||
end
|
||||
|
||||
function storagetest.network.insert_item(network_id, stack)
|
||||
local storage_nodes = storagetest.network.get_storage_devices(network_id)
|
||||
function holostorage.network.insert_item(network_id, stack)
|
||||
local storage_nodes = holostorage.network.get_storage_devices(network_id)
|
||||
|
||||
for _,pos in pairs(storage_nodes) do
|
||||
local success, leftover = storagetest.insert_stack(pos, stack)
|
||||
local success, leftover = holostorage.insert_stack(pos, stack)
|
||||
if success then
|
||||
return success, leftover
|
||||
end
|
||||
@ -443,17 +443,17 @@ function storagetest.network.insert_item(network_id, stack)
|
||||
return nil
|
||||
end
|
||||
|
||||
function storagetest.network.take_item(network_id, stack)
|
||||
local storage_nodes = storagetest.network.get_storage_devices(network_id)
|
||||
function holostorage.network.take_item(network_id, stack)
|
||||
local storage_nodes = holostorage.network.get_storage_devices(network_id)
|
||||
|
||||
for _,pos in pairs(storage_nodes) do
|
||||
local success, stacki = storagetest.take_stack(pos, stack)
|
||||
local success, stacki = holostorage.take_stack(pos, stack)
|
||||
if success and stacki then
|
||||
if stacki:get_count() == stack:get_count() then
|
||||
return success, stacki
|
||||
else
|
||||
stack:set_count(stack:get_count() - stacki:get_count())
|
||||
return storagetest.network.take_item(network_id, stack)
|
||||
return holostorage.network.take_item(network_id, stack)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
18
nodes.lua
@ -1,23 +1,23 @@
|
||||
-- Storagetest nodes
|
||||
-- holostorage nodes
|
||||
|
||||
-- Common registrations
|
||||
dofile(storagetest.modpath.."/nodes/common.lua")
|
||||
dofile(holostorage.modpath.."/nodes/common.lua")
|
||||
|
||||
-- Controller
|
||||
dofile(storagetest.modpath.."/nodes/controller.lua")
|
||||
dofile(holostorage.modpath.."/nodes/controller.lua")
|
||||
|
||||
-- Cabling
|
||||
dofile(storagetest.modpath.."/nodes/cable.lua")
|
||||
dofile(holostorage.modpath.."/nodes/cable.lua")
|
||||
|
||||
-- Disk drives
|
||||
dofile(storagetest.modpath.."/nodes/disk_drive.lua")
|
||||
dofile(holostorage.modpath.."/nodes/disk_drive.lua")
|
||||
|
||||
-- Grids
|
||||
dofile(storagetest.modpath.."/nodes/grid.lua")
|
||||
dofile(holostorage.modpath.."/nodes/grid.lua")
|
||||
|
||||
-- Buses
|
||||
dofile(storagetest.modpath.."/nodes/bus.lua")
|
||||
dofile(holostorage.modpath.."/nodes/bus.lua")
|
||||
|
||||
-- Start the network
|
||||
storagetest.network.register_abm_controller("storagetest:controller_active")
|
||||
storagetest.network.register_abm_nodes()
|
||||
holostorage.network.register_abm_controller("holostorage:controller_active")
|
||||
holostorage.network.register_abm_nodes()
|
||||
|
@ -1,4 +1,4 @@
|
||||
-- Storagetest cabling
|
||||
-- holostorage cabling
|
||||
|
||||
local function get_formspec(title, filter)
|
||||
local fl = "Blacklist"
|
||||
@ -65,22 +65,22 @@ local function flip_filter(pos, form, fields, player)
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_node("storagetest:import_bus", {
|
||||
minetest.register_node("holostorage:import_bus", {
|
||||
description = "Import Bus",
|
||||
tiles = {
|
||||
"storagetest_machine_block.png", "storagetest_machine_block.png", "storagetest_machine_block.png",
|
||||
"storagetest_machine_block.png", "storagetest_machine_block.png", "storagetest_import.png",
|
||||
"holostorage_machine_block.png", "holostorage_machine_block.png", "holostorage_machine_block.png",
|
||||
"holostorage_machine_block.png", "holostorage_machine_block.png", "holostorage_import.png",
|
||||
},
|
||||
paramtype2 = "facedir",
|
||||
is_ground_content = false,
|
||||
groups = {
|
||||
storagetest_distributor = 1,
|
||||
storagetest_device = 1,
|
||||
holostorage_distributor = 1,
|
||||
holostorage_device = 1,
|
||||
cracky = 2,
|
||||
oddly_breakable_by_hand = 2
|
||||
},
|
||||
on_construct = function (pos)
|
||||
storagetest.network.clear_networks(pos)
|
||||
holostorage.network.clear_networks(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("formspec", get_formspec("Import Bus", 0))
|
||||
|
||||
@ -89,14 +89,14 @@ minetest.register_node("storagetest:import_bus", {
|
||||
|
||||
meta:set_int("filter", 0)
|
||||
end,
|
||||
on_destruct = storagetest.network.clear_networks,
|
||||
on_destruct = holostorage.network.clear_networks,
|
||||
on_receive_fields = flip_filter,
|
||||
storagetest_run = function (pos, _, controller)
|
||||
holostorage_run = function (pos, _, controller)
|
||||
local network = minetest.hash_node_position(controller)
|
||||
local node = minetest.get_node(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local front = storagetest.front(pos, node.param2)
|
||||
local front = holostorage.front(pos, node.param2)
|
||||
|
||||
local front_node = minetest.get_node(front)
|
||||
if front_node.name ~= "air" then
|
||||
@ -121,7 +121,7 @@ minetest.register_node("storagetest:import_bus", {
|
||||
end
|
||||
|
||||
if can_take then
|
||||
local success, outst = storagetest.network.insert_item(network, copystack)
|
||||
local success, outst = holostorage.network.insert_item(network, copystack)
|
||||
if success then
|
||||
stack:set_count(stack:get_count() - 1)
|
||||
front_inv:set_stack("main", index, stack)
|
||||
@ -138,35 +138,35 @@ minetest.register_node("storagetest:import_bus", {
|
||||
allow_metadata_inventory_put = inventory_ghost_put
|
||||
})
|
||||
|
||||
minetest.register_node("storagetest:export_bus", {
|
||||
minetest.register_node("holostorage:export_bus", {
|
||||
description = "Export Bus",
|
||||
tiles = {
|
||||
"storagetest_machine_block.png", "storagetest_machine_block.png", "storagetest_machine_block.png",
|
||||
"storagetest_machine_block.png", "storagetest_machine_block.png", "storagetest_export.png",
|
||||
"holostorage_machine_block.png", "holostorage_machine_block.png", "holostorage_machine_block.png",
|
||||
"holostorage_machine_block.png", "holostorage_machine_block.png", "holostorage_export.png",
|
||||
},
|
||||
paramtype2 = "facedir",
|
||||
is_ground_content = false,
|
||||
groups = {
|
||||
storagetest_distributor = 1,
|
||||
storagetest_device = 1,
|
||||
holostorage_distributor = 1,
|
||||
holostorage_device = 1,
|
||||
cracky = 2,
|
||||
oddly_breakable_by_hand = 2
|
||||
},
|
||||
on_construct = function (pos)
|
||||
storagetest.network.clear_networks(pos)
|
||||
holostorage.network.clear_networks(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("formspec", get_formspec("Export Bus"))
|
||||
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("filter", 8)
|
||||
end,
|
||||
on_destruct = storagetest.network.clear_networks,
|
||||
storagetest_run = function (pos, _, controller)
|
||||
on_destruct = holostorage.network.clear_networks,
|
||||
holostorage_run = function (pos, _, controller)
|
||||
local network = minetest.hash_node_position(controller)
|
||||
local node = minetest.get_node(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local front = storagetest.front(pos, node.param2)
|
||||
local front = holostorage.front(pos, node.param2)
|
||||
|
||||
local front_node = minetest.get_node(front)
|
||||
if front_node.name ~= "air" then
|
||||
@ -174,7 +174,7 @@ minetest.register_node("storagetest:export_bus", {
|
||||
local front_inv = front_meta:get_inventory()
|
||||
local front_def = minetest.registered_nodes[front_node.name]
|
||||
if front_inv:get_list("main") then
|
||||
local items = storagetest.network.get_storage_inventories(network)
|
||||
local items = holostorage.network.get_storage_inventories(network)
|
||||
for index, stack in pairs(items) do
|
||||
if not stack:is_empty() then
|
||||
local can_take = false
|
||||
@ -189,7 +189,7 @@ minetest.register_node("storagetest:export_bus", {
|
||||
end
|
||||
|
||||
if can_take then
|
||||
local success, gotten = storagetest.network.take_item(network, stack)
|
||||
local success, gotten = holostorage.network.take_item(network, stack)
|
||||
if success then
|
||||
front_inv:add_item("main", gotten)
|
||||
break -- Don't take more than one per cycle
|
||||
@ -204,5 +204,5 @@ minetest.register_node("storagetest:export_bus", {
|
||||
allow_metadata_inventory_put = inventory_ghost_put
|
||||
})
|
||||
|
||||
storagetest.devices["storagetest:import_bus"] = true
|
||||
storagetest.devices["storagetest:export_bus"] = true
|
||||
holostorage.devices["holostorage:import_bus"] = true
|
||||
holostorage.devices["holostorage:export_bus"] = true
|
||||
|
@ -1,9 +1,9 @@
|
||||
-- Storagetest cabling
|
||||
-- holostorage cabling
|
||||
|
||||
minetest.register_node("storagetest:cable", {
|
||||
minetest.register_node("holostorage:cable", {
|
||||
description = "Storage Cable",
|
||||
drawtype = "nodebox",
|
||||
tiles = {"storagetest_cable.png"},
|
||||
tiles = {"holostorage_cable.png"},
|
||||
node_box = {
|
||||
type = "connected",
|
||||
fixed = {{-1/8, -1/8, -1/8, 1/8, 1/8, 1/8}},
|
||||
@ -30,18 +30,18 @@ minetest.register_node("storagetest:cable", {
|
||||
connect_sides = { "top", "bottom", "front", "left", "back", "right" },
|
||||
is_ground_content = false,
|
||||
connects_to = {
|
||||
"group:storagetest_controller",
|
||||
"group:storagetest_distributor",
|
||||
"group:storagetest_cable",
|
||||
"group:holostorage_controller",
|
||||
"group:holostorage_distributor",
|
||||
"group:holostorage_cable",
|
||||
},
|
||||
groups = {
|
||||
storagetest_distributor = 1,
|
||||
storagetest_cable = 1,
|
||||
holostorage_distributor = 1,
|
||||
holostorage_cable = 1,
|
||||
cracky = 2,
|
||||
oddly_breakable_by_hand = 2
|
||||
},
|
||||
on_construct = function (pos)
|
||||
storagetest.network.clear_networks(pos)
|
||||
holostorage.network.clear_networks(pos)
|
||||
end,
|
||||
on_destruct = storagetest.network.clear_networks,
|
||||
on_destruct = holostorage.network.clear_networks,
|
||||
})
|
||||
|
@ -1,8 +1,8 @@
|
||||
-- Storagetest commons
|
||||
-- holostorage commons
|
||||
|
||||
storagetest.helpers = {}
|
||||
holostorage.helpers = {}
|
||||
|
||||
function storagetest.helpers.swap_node(pos, noded)
|
||||
function holostorage.helpers.swap_node(pos, noded)
|
||||
local node = minetest.get_node(pos)
|
||||
if node.name == noded.name then
|
||||
return
|
||||
@ -10,7 +10,7 @@ function storagetest.helpers.swap_node(pos, noded)
|
||||
minetest.swap_node(pos, noded)
|
||||
end
|
||||
|
||||
function storagetest.helpers.grid_refresh(pos, n, controller)
|
||||
function holostorage.helpers.grid_refresh(pos, n, controller)
|
||||
local node = minetest.get_node(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local nodedef = minetest.registered_nodes[node.name]
|
||||
@ -23,13 +23,13 @@ function storagetest.helpers.grid_refresh(pos, n, controller)
|
||||
minetest.get_node_timer(pos):start(0.02)
|
||||
end
|
||||
|
||||
if nodedef.storagetest_enabled_name then
|
||||
node.name = nodedef.storagetest_enabled_name
|
||||
storagetest.helpers.swap_node(pos, node)
|
||||
if nodedef.holostorage_enabled_name then
|
||||
node.name = nodedef.holostorage_enabled_name
|
||||
holostorage.helpers.swap_node(pos, node)
|
||||
end
|
||||
end
|
||||
|
||||
function storagetest.front(pos, fd)
|
||||
function holostorage.front(pos, fd)
|
||||
local front = minetest.facedir_to_dir(fd)
|
||||
front.x = front.x * -1 + pos.x
|
||||
front.y = front.y * -1 + pos.y
|
||||
|
@ -1,16 +1,16 @@
|
||||
-- Storagetest controller
|
||||
-- holostorage controller
|
||||
|
||||
minetest.register_node("storagetest:controller", {
|
||||
minetest.register_node("holostorage:controller", {
|
||||
description = "Storage Controller",
|
||||
tiles = {"storagetest_controller.png"},
|
||||
tiles = {"holostorage_controller.png"},
|
||||
on_construct = function (pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("infotext", "Storage Controller")
|
||||
meta:set_string("active", 1)
|
||||
meta:set_string("channel", "controller"..minetest.pos_to_string(pos))
|
||||
minetest.swap_node(pos, {name="storagetest:controller_active"})
|
||||
minetest.swap_node(pos, {name="holostorage:controller_active"})
|
||||
local poshash = minetest.hash_node_position(pos)
|
||||
storagetest.network.redundant_warn[poshash] = nil
|
||||
holostorage.network.redundant_warn[poshash] = nil
|
||||
end,
|
||||
after_dig_node = function(pos)
|
||||
minetest.forceload_free_block(pos)
|
||||
@ -21,15 +21,15 @@ minetest.register_node("storagetest:controller", {
|
||||
end,
|
||||
groups = {
|
||||
cracky = 1,
|
||||
storagetest_controller = 1
|
||||
holostorage_controller = 1
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_node("storagetest:controller_active", {
|
||||
minetest.register_node("holostorage:controller_active", {
|
||||
description = "Storage Controller",
|
||||
tiles = {
|
||||
{
|
||||
name = "storagetest_controller_animated.png",
|
||||
name = "holostorage_controller_animated.png",
|
||||
animation = {
|
||||
type = "vertical_frames",
|
||||
aspect_w = 16,
|
||||
@ -38,10 +38,10 @@ minetest.register_node("storagetest:controller_active", {
|
||||
},
|
||||
}
|
||||
},
|
||||
drop = "storagetest:controller",
|
||||
drop = "holostorage:controller",
|
||||
groups = {
|
||||
cracky = 1,
|
||||
not_in_creative_inventory = 1,
|
||||
storagetest_controller = 1
|
||||
holostorage_controller = 1
|
||||
}
|
||||
})
|
||||
|
@ -33,7 +33,7 @@ local function timer(pos, elapsed)
|
||||
local count = count_inv(inv)
|
||||
local cnname = minetest.registered_nodes[node.name]["_basename"]
|
||||
node.name = cnname..count
|
||||
storagetest.helpers.swap_node(pos, node)
|
||||
holostorage.helpers.swap_node(pos, node)
|
||||
|
||||
return refresh
|
||||
end
|
||||
@ -43,7 +43,7 @@ local function allow_metadata_inventory_put (pos, listname, index, stack, player
|
||||
return 0
|
||||
end
|
||||
|
||||
if not storagetest.disks.is_valid_disk(stack) then
|
||||
if not holostorage.disks.is_valid_disk(stack) then
|
||||
return 0
|
||||
end
|
||||
|
||||
@ -68,13 +68,13 @@ local function sort_by_stack_name( ... )
|
||||
-- body
|
||||
end
|
||||
|
||||
function storagetest.stack_list(pos)
|
||||
local invs = storagetest.get_all_inventories(pos)
|
||||
function holostorage.stack_list(pos)
|
||||
local invs = holostorage.get_all_inventories(pos)
|
||||
if not invs then return {} end
|
||||
local tabl = {}
|
||||
|
||||
for _,diskptr in pairs(invs) do
|
||||
local invref = storagetest.disks.memcache[diskptr]
|
||||
local invref = holostorage.disks.memcache[diskptr]
|
||||
if invref then
|
||||
local stacks = invref:get_list("main")
|
||||
for _,stack in pairs(stacks) do
|
||||
@ -89,15 +89,15 @@ function storagetest.stack_list(pos)
|
||||
return tabl
|
||||
end
|
||||
|
||||
function storagetest.insert_stack(pos, stack)
|
||||
local invs = storagetest.get_all_inventories(pos)
|
||||
function holostorage.insert_stack(pos, stack)
|
||||
local invs = holostorage.get_all_inventories(pos)
|
||||
if not invs then return {} end
|
||||
local tabl = {}
|
||||
local success = false
|
||||
local leftover
|
||||
|
||||
for _,diskptr in pairs(invs) do
|
||||
local invref = storagetest.disks.memcache[diskptr]
|
||||
local invref = holostorage.disks.memcache[diskptr]
|
||||
if invref then
|
||||
if invref:room_for_item("main", stack) then
|
||||
leftover = invref:add_item("main", stack)
|
||||
@ -110,15 +110,15 @@ function storagetest.insert_stack(pos, stack)
|
||||
return success, leftover
|
||||
end
|
||||
|
||||
function storagetest.take_stack(pos, stack)
|
||||
local invs = storagetest.get_all_inventories(pos)
|
||||
function holostorage.take_stack(pos, stack)
|
||||
local invs = holostorage.get_all_inventories(pos)
|
||||
if not invs then return {} end
|
||||
local tabl = {}
|
||||
local stack_ret
|
||||
local success = false
|
||||
|
||||
for _,diskptr in pairs(invs) do
|
||||
local invref = storagetest.disks.memcache[diskptr]
|
||||
local invref = holostorage.disks.memcache[diskptr]
|
||||
if invref then
|
||||
local list = invref:get_list("main")
|
||||
for i, stacki in pairs(list) do
|
||||
@ -142,7 +142,7 @@ function storagetest.take_stack(pos, stack)
|
||||
return success, stack_ret
|
||||
end
|
||||
|
||||
function storagetest.get_all_inventories(pos)
|
||||
function holostorage.get_all_inventories(pos)
|
||||
local node = minetest.get_node(pos)
|
||||
if minetest.get_item_group(node.name, "disk_drive") == 0 then return nil end
|
||||
local meta = minetest.get_meta(pos)
|
||||
@ -166,26 +166,26 @@ end
|
||||
local function register_disk_drive(index)
|
||||
local groups = {
|
||||
cracky = 1,
|
||||
storagetest_distributor = 1,
|
||||
storagetest_device = 1,
|
||||
storagetest_storage = 1,
|
||||
holostorage_distributor = 1,
|
||||
holostorage_device = 1,
|
||||
holostorage_storage = 1,
|
||||
disk_drive = 1,
|
||||
}
|
||||
|
||||
local driveoverlay = ""
|
||||
if index ~= 0 then
|
||||
groups["not_in_creative_inventory"] = 1
|
||||
driveoverlay = "^storagetest_drive_section"..index..".png"
|
||||
driveoverlay = "^holostorage_drive_section"..index..".png"
|
||||
end
|
||||
|
||||
minetest.register_node("storagetest:disk_drive"..index, {
|
||||
minetest.register_node("holostorage:disk_drive"..index, {
|
||||
description = "Disk Drive",
|
||||
tiles = {
|
||||
"storagetest_drive_side.png", "storagetest_drive_side.png", "storagetest_drive_side.png",
|
||||
"storagetest_drive_side.png", "storagetest_drive_side.png", "storagetest_drive.png"..driveoverlay,
|
||||
"holostorage_drive_side.png", "holostorage_drive_side.png", "holostorage_drive_side.png",
|
||||
"holostorage_drive_side.png", "holostorage_drive_side.png", "holostorage_drive.png"..driveoverlay,
|
||||
},
|
||||
drop = "storagetest:disk_drive0",
|
||||
_basename = "storagetest:disk_drive",
|
||||
drop = "holostorage:disk_drive0",
|
||||
_basename = "holostorage:disk_drive",
|
||||
paramtype2 = "facedir",
|
||||
on_timer = timer,
|
||||
groups = groups,
|
||||
@ -194,9 +194,9 @@ local function register_disk_drive(index)
|
||||
meta:set_string("formspec", get_formspec())
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("main", 6)
|
||||
storagetest.network.clear_networks(pos)
|
||||
holostorage.network.clear_networks(pos)
|
||||
end,
|
||||
on_destruct = storagetest.network.clear_networks,
|
||||
on_destruct = holostorage.network.clear_networks,
|
||||
|
||||
allow_metadata_inventory_put = allow_metadata_inventory_put,
|
||||
allow_metadata_inventory_take = allow_metadata_inventory_take,
|
||||
@ -206,7 +206,7 @@ local function register_disk_drive(index)
|
||||
minetest.get_node_timer(pos):start(0.02)
|
||||
end,
|
||||
on_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||
stack = storagetest.disks.ensure_disk_inventory(stack, minetest.pos_to_string(pos))
|
||||
stack = holostorage.disks.ensure_disk_inventory(stack, minetest.pos_to_string(pos))
|
||||
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
@ -220,7 +220,7 @@ local function register_disk_drive(index)
|
||||
end,
|
||||
})
|
||||
|
||||
storagetest.devices["storagetest:disk_drive"..index] = true
|
||||
holostorage.devices["holostorage:disk_drive"..index] = true
|
||||
end
|
||||
|
||||
-- Register 6 variants of the disk drive.
|
||||
@ -232,7 +232,7 @@ end
|
||||
minetest.register_abm({
|
||||
label = "Storage Disk Synchronization",
|
||||
nodenames = {"group:disk_drive"},
|
||||
neighbors = {"group:storagetest_distributor"},
|
||||
neighbors = {"group:holostorage_distributor"},
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
@ -244,9 +244,9 @@ minetest.register_abm({
|
||||
local meta = stack:get_meta()
|
||||
local tag = meta:get_string("storage_tag")
|
||||
if tag and tag ~= "" then
|
||||
if not storagetest.disks.memcache[tag] then
|
||||
if not holostorage.disks.memcache[tag] then
|
||||
print("loading drive",tag)
|
||||
storagetest.disks.load_disk_from_file(stack, tag)
|
||||
holostorage.disks.load_disk_from_file(stack, tag)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
146
nodes/grid.lua
@ -1,8 +1,8 @@
|
||||
-- Storage Grid
|
||||
|
||||
storagetest.grid = {}
|
||||
holostorage.grid = {}
|
||||
|
||||
function storagetest.grid.sort(inlist)
|
||||
function holostorage.grid.sort(inlist)
|
||||
local typecnt = {}
|
||||
local typekeys = {}
|
||||
for _, st in ipairs(inlist) do
|
||||
@ -46,7 +46,7 @@ function storagetest.grid.sort(inlist)
|
||||
return outlist
|
||||
end
|
||||
|
||||
function storagetest.grid.get_formspec(scroll_lvl, pages, craft_inv)
|
||||
function holostorage.grid.get_formspec(scroll_lvl, pages, craft_inv)
|
||||
local craft = ""
|
||||
local title = "Grid"
|
||||
local height = 6
|
||||
@ -86,23 +86,23 @@ function storagetest.grid.get_formspec(scroll_lvl, pages, craft_inv)
|
||||
default.get_hotbar_bg(0, 8)
|
||||
end
|
||||
|
||||
function storagetest.grid.to_network(meta)
|
||||
function holostorage.grid.to_network(meta)
|
||||
local ctrl = meta:get_string("controller")
|
||||
if not ctrl or ctrl == "" then return nil end
|
||||
local network = minetest.hash_node_position(minetest.string_to_pos(ctrl))
|
||||
return network
|
||||
end
|
||||
|
||||
function storagetest.grid.handle_grid(pos, meta, network, inv)
|
||||
function holostorage.grid.handle_grid(pos, meta, network, inv)
|
||||
local refresh = false
|
||||
local limited_items = {}
|
||||
|
||||
local items = storagetest.network.get_storage_inventories(network)
|
||||
local items = holostorage.network.get_storage_inventories(network)
|
||||
local scroll = meta:get_int("scroll_len") or 0
|
||||
local grid = inv:get_size("grid")
|
||||
|
||||
-- Sort the items
|
||||
items = storagetest.grid.sort(items)
|
||||
items = holostorage.grid.sort(items)
|
||||
|
||||
-- Search
|
||||
local search = meta:get_string("search")
|
||||
@ -128,7 +128,7 @@ function storagetest.grid.handle_grid(pos, meta, network, inv)
|
||||
-- Handle inputting items
|
||||
local input = inv:get_stack("main", 1)
|
||||
if not input:is_empty() then
|
||||
local success, leftover = storagetest.network.insert_item(network, input)
|
||||
local success, leftover = holostorage.network.insert_item(network, input)
|
||||
if success then
|
||||
inv:set_stack("main", 1, leftover)
|
||||
refresh = true
|
||||
@ -139,7 +139,7 @@ function storagetest.grid.handle_grid(pos, meta, network, inv)
|
||||
local grid_craft = meta:get_int("craft") == 1
|
||||
local height = math.floor(#preserve / 8)
|
||||
meta:set_int("scroll_height", height)
|
||||
meta:set_string("formspec", storagetest.grid.get_formspec(scroll, height, grid_craft))
|
||||
meta:set_string("formspec", holostorage.grid.get_formspec(scroll, height, grid_craft))
|
||||
|
||||
return refresh
|
||||
end
|
||||
@ -164,7 +164,7 @@ local function on_receive_fields(pos, formname, fields, sender)
|
||||
minetest.get_node_timer(pos):start(0.02)
|
||||
end
|
||||
|
||||
function storagetest.grid.allow_put(pos, listname, index, stack, player)
|
||||
function holostorage.grid.allow_put(pos, listname, index, stack, player)
|
||||
if minetest.is_protected(pos, player:get_player_name()) then
|
||||
return 0
|
||||
end
|
||||
@ -176,7 +176,7 @@ function storagetest.grid.allow_put(pos, listname, index, stack, player)
|
||||
return stack:get_count()
|
||||
end
|
||||
|
||||
function storagetest.grid.allow_move_active(pos, from_list, from_index, to_list, to_index, count, player)
|
||||
function holostorage.grid.allow_move_active(pos, from_list, from_index, to_list, to_index, count, player)
|
||||
if from_list == "grid" and to_list == "main" then
|
||||
return 0
|
||||
end
|
||||
@ -185,10 +185,10 @@ function storagetest.grid.allow_move_active(pos, from_list, from_index, to_list,
|
||||
local inv = meta:get_inventory()
|
||||
local stack = inv:get_stack(from_list, from_index)
|
||||
|
||||
return storagetest.grid.allow_put(pos, to_list, to_index, stack, player)
|
||||
return holostorage.grid.allow_put(pos, to_list, to_index, stack, player)
|
||||
end
|
||||
|
||||
function storagetest.grid.on_disable(pos)
|
||||
function holostorage.grid.on_disable(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local prev = meta:get_string("controller")
|
||||
if prev and prev ~= "" then
|
||||
@ -197,27 +197,27 @@ function storagetest.grid.on_disable(pos)
|
||||
end
|
||||
end
|
||||
|
||||
function storagetest.grid.on_move(pos, from_list, from_index, to_list, to_index, count, player)
|
||||
function holostorage.grid.on_move(pos, from_list, from_index, to_list, to_index, count, player)
|
||||
if from_list == "grid" and to_list == "craft" then
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local stack = inv:get_stack(to_list, to_index)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local network = storagetest.grid.to_network(meta)
|
||||
local network = holostorage.grid.to_network(meta)
|
||||
if network then
|
||||
storagetest.network.take_item(network, stack)
|
||||
holostorage.network.take_item(network, stack)
|
||||
end
|
||||
end
|
||||
|
||||
minetest.get_node_timer(pos):start(0.02)
|
||||
end
|
||||
|
||||
function storagetest.grid.on_take(pos, listname, index, stack, player)
|
||||
function holostorage.grid.on_take(pos, listname, index, stack, player)
|
||||
if listname == "grid" then
|
||||
local meta = minetest.get_meta(pos)
|
||||
local network = storagetest.grid.to_network(meta)
|
||||
local network = holostorage.grid.to_network(meta)
|
||||
if network then
|
||||
storagetest.network.take_item(network, stack)
|
||||
holostorage.network.take_item(network, stack)
|
||||
end
|
||||
end
|
||||
|
||||
@ -229,34 +229,34 @@ local function timer(pos, elapsed)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local node = minetest.get_node(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local network = storagetest.grid.to_network(meta)
|
||||
local network = holostorage.grid.to_network(meta)
|
||||
|
||||
if not network then
|
||||
inv:set_list("grid", {})
|
||||
else
|
||||
refresh = storagetest.grid.handle_grid(pos, meta, network, inv)
|
||||
refresh = holostorage.grid.handle_grid(pos, meta, network, inv)
|
||||
end
|
||||
|
||||
return refresh
|
||||
end
|
||||
|
||||
minetest.register_node("storagetest:grid", {
|
||||
minetest.register_node("holostorage:grid", {
|
||||
description = "Grid",
|
||||
tiles = {
|
||||
"storagetest_machine_block.png", "storagetest_machine_block.png", "storagetest_machine_block.png",
|
||||
"storagetest_machine_block.png", "storagetest_machine_block.png", "storagetest_grid.png",
|
||||
"holostorage_machine_block.png", "holostorage_machine_block.png", "holostorage_machine_block.png",
|
||||
"holostorage_machine_block.png", "holostorage_machine_block.png", "holostorage_grid.png",
|
||||
},
|
||||
paramtype2 = "facedir",
|
||||
on_timer = timer,
|
||||
groups = {
|
||||
cracky = 1,
|
||||
storagetest_distributor = 1,
|
||||
storagetest_device = 1,
|
||||
holostorage_distributor = 1,
|
||||
holostorage_device = 1,
|
||||
},
|
||||
on_construct = function (pos)
|
||||
storagetest.network.clear_networks(pos)
|
||||
holostorage.network.clear_networks(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("formspec", storagetest.grid.get_formspec(0, 1))
|
||||
meta:set_string("formspec", holostorage.grid.get_formspec(0, 1))
|
||||
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("main", 1)
|
||||
@ -269,8 +269,8 @@ minetest.register_node("storagetest:grid", {
|
||||
minetest.get_node_timer(pos):start(0.02)
|
||||
return itemstack
|
||||
end,
|
||||
on_destruct = storagetest.network.clear_networks,
|
||||
storagetest_run = storagetest.helpers.grid_refresh,
|
||||
on_destruct = holostorage.network.clear_networks,
|
||||
holostorage_run = holostorage.helpers.grid_refresh,
|
||||
allow_metadata_inventory_move = function ()
|
||||
return 0
|
||||
end,
|
||||
@ -280,61 +280,61 @@ minetest.register_node("storagetest:grid", {
|
||||
allow_metadata_inventory_take = function ()
|
||||
return 0
|
||||
end,
|
||||
storagetest_enabled_name = "storagetest:grid_active",
|
||||
storagetest_on_disable = storagetest.grid.on_disable,
|
||||
holostorage_enabled_name = "holostorage:grid_active",
|
||||
holostorage_on_disable = holostorage.grid.on_disable,
|
||||
})
|
||||
|
||||
minetest.register_node("storagetest:grid_active", {
|
||||
minetest.register_node("holostorage:grid_active", {
|
||||
description = "Grid",
|
||||
tiles = {
|
||||
"storagetest_machine_block.png", "storagetest_machine_block.png", "storagetest_machine_block.png",
|
||||
"storagetest_machine_block.png", "storagetest_machine_block.png", "storagetest_grid_active.png",
|
||||
"holostorage_machine_block.png", "holostorage_machine_block.png", "holostorage_machine_block.png",
|
||||
"holostorage_machine_block.png", "holostorage_machine_block.png", "holostorage_grid_active.png",
|
||||
},
|
||||
drop = "storagetest:grid",
|
||||
drop = "holostorage:grid",
|
||||
paramtype2 = "facedir",
|
||||
on_timer = timer,
|
||||
groups = {
|
||||
cracky = 1,
|
||||
storagetest_distributor = 1,
|
||||
storagetest_device = 1,
|
||||
holostorage_distributor = 1,
|
||||
holostorage_device = 1,
|
||||
not_in_creative_inventory = 1
|
||||
},
|
||||
on_metadata_inventory_move = storagetest.grid.on_move,
|
||||
on_metadata_inventory_move = holostorage.grid.on_move,
|
||||
on_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||
minetest.get_node_timer(pos):start(0.02)
|
||||
end,
|
||||
on_metadata_inventory_take = storagetest.grid.on_take,
|
||||
on_metadata_inventory_take = holostorage.grid.on_take,
|
||||
on_rightclick = function (pos, node, clicker, itemstack, pointed_thing)
|
||||
minetest.get_node_timer(pos):start(0.05)
|
||||
return itemstack
|
||||
end,
|
||||
on_destruct = storagetest.network.clear_networks,
|
||||
storagetest_run = storagetest.helpers.grid_refresh,
|
||||
storagetest_disabled_name = "storagetest:grid",
|
||||
allow_metadata_inventory_move = storagetest.grid.allow_move_active,
|
||||
allow_metadata_inventory_put = storagetest.grid.allow_put,
|
||||
on_destruct = holostorage.network.clear_networks,
|
||||
holostorage_run = holostorage.helpers.grid_refresh,
|
||||
holostorage_disabled_name = "holostorage:grid",
|
||||
allow_metadata_inventory_move = holostorage.grid.allow_move_active,
|
||||
allow_metadata_inventory_put = holostorage.grid.allow_put,
|
||||
on_receive_fields = on_receive_fields,
|
||||
})
|
||||
|
||||
-- Crafting version
|
||||
|
||||
minetest.register_node("storagetest:crafting_grid", {
|
||||
minetest.register_node("holostorage:crafting_grid", {
|
||||
description = "Crafting Grid",
|
||||
tiles = {
|
||||
"storagetest_machine_block.png", "storagetest_machine_block.png", "storagetest_machine_block.png",
|
||||
"storagetest_machine_block.png", "storagetest_machine_block.png", "storagetest_crafting_grid.png",
|
||||
"holostorage_machine_block.png", "holostorage_machine_block.png", "holostorage_machine_block.png",
|
||||
"holostorage_machine_block.png", "holostorage_machine_block.png", "holostorage_crafting_grid.png",
|
||||
},
|
||||
paramtype2 = "facedir",
|
||||
on_timer = timer,
|
||||
groups = {
|
||||
cracky = 1,
|
||||
storagetest_distributor = 1,
|
||||
storagetest_device = 1,
|
||||
holostorage_distributor = 1,
|
||||
holostorage_device = 1,
|
||||
},
|
||||
on_construct = function (pos)
|
||||
storagetest.network.clear_networks(pos)
|
||||
holostorage.network.clear_networks(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("formspec", storagetest.grid.get_formspec(0, 1, true))
|
||||
meta:set_string("formspec", holostorage.grid.get_formspec(0, 1, true))
|
||||
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("main", 1)
|
||||
@ -349,8 +349,8 @@ minetest.register_node("storagetest:crafting_grid", {
|
||||
minetest.get_node_timer(pos):start(0.02)
|
||||
return itemstack
|
||||
end,
|
||||
on_destruct = storagetest.network.clear_networks,
|
||||
storagetest_run = storagetest.helpers.grid_refresh,
|
||||
on_destruct = holostorage.network.clear_networks,
|
||||
holostorage_run = holostorage.helpers.grid_refresh,
|
||||
allow_metadata_inventory_move = function ()
|
||||
return 0
|
||||
end,
|
||||
@ -360,44 +360,44 @@ minetest.register_node("storagetest:crafting_grid", {
|
||||
allow_metadata_inventory_take = function ()
|
||||
return 0
|
||||
end,
|
||||
storagetest_enabled_name = "storagetest:crafting_grid_active",
|
||||
storagetest_on_disable = storagetest.grid.on_disable,
|
||||
holostorage_enabled_name = "holostorage:crafting_grid_active",
|
||||
holostorage_on_disable = holostorage.grid.on_disable,
|
||||
})
|
||||
|
||||
minetest.register_node("storagetest:crafting_grid_active", {
|
||||
minetest.register_node("holostorage:crafting_grid_active", {
|
||||
description = "Crafting Grid",
|
||||
tiles = {
|
||||
"storagetest_machine_block.png", "storagetest_machine_block.png", "storagetest_machine_block.png",
|
||||
"storagetest_machine_block.png", "storagetest_machine_block.png", "storagetest_crafting_grid_active.png",
|
||||
"holostorage_machine_block.png", "holostorage_machine_block.png", "holostorage_machine_block.png",
|
||||
"holostorage_machine_block.png", "holostorage_machine_block.png", "holostorage_crafting_grid_active.png",
|
||||
},
|
||||
drop = "storagetest:crafting_grid",
|
||||
drop = "holostorage:crafting_grid",
|
||||
paramtype2 = "facedir",
|
||||
on_timer = timer,
|
||||
groups = {
|
||||
cracky = 1,
|
||||
storagetest_distributor = 1,
|
||||
storagetest_device = 1,
|
||||
holostorage_distributor = 1,
|
||||
holostorage_device = 1,
|
||||
not_in_creative_inventory = 1
|
||||
},
|
||||
on_metadata_inventory_move = storagetest.grid.on_move,
|
||||
on_metadata_inventory_move = holostorage.grid.on_move,
|
||||
on_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||
minetest.get_node_timer(pos):start(0.02)
|
||||
end,
|
||||
on_metadata_inventory_take = storagetest.grid.on_take,
|
||||
on_metadata_inventory_take = holostorage.grid.on_take,
|
||||
on_rightclick = function (pos, node, clicker, itemstack, pointed_thing)
|
||||
minetest.get_node_timer(pos):start(0.05)
|
||||
return itemstack
|
||||
end,
|
||||
on_destruct = storagetest.network.clear_networks,
|
||||
storagetest_run = storagetest.helpers.grid_refresh,
|
||||
storagetest_disabled_name = "storagetest:crafting_grid",
|
||||
allow_metadata_inventory_move = storagetest.grid.allow_move_active,
|
||||
allow_metadata_inventory_put = storagetest.grid.allow_put,
|
||||
on_destruct = holostorage.network.clear_networks,
|
||||
holostorage_run = holostorage.helpers.grid_refresh,
|
||||
holostorage_disabled_name = "holostorage:crafting_grid",
|
||||
allow_metadata_inventory_move = holostorage.grid.allow_move_active,
|
||||
allow_metadata_inventory_put = holostorage.grid.allow_put,
|
||||
on_receive_fields = on_receive_fields,
|
||||
})
|
||||
|
||||
storagetest.devices["storagetest:grid"] = true
|
||||
storagetest.devices["storagetest:grid_active"] = true
|
||||
holostorage.devices["holostorage:grid"] = true
|
||||
holostorage.devices["holostorage:grid_active"] = true
|
||||
|
||||
storagetest.devices["storagetest:crafting_grid"] = true
|
||||
storagetest.devices["storagetest:crafting_grid_active"] = true
|
||||
holostorage.devices["holostorage:crafting_grid"] = true
|
||||
holostorage.devices["holostorage:crafting_grid_active"] = true
|
||||
|
BIN
textures/holostorage_cable.png
Normal file
After Width: | Height: | Size: 452 B |
Before Width: | Height: | Size: 526 B After Width: | Height: | Size: 526 B |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 488 B After Width: | Height: | Size: 488 B |
Before Width: | Height: | Size: 451 B After Width: | Height: | Size: 451 B |
Before Width: | Height: | Size: 513 B After Width: | Height: | Size: 513 B |
Before Width: | Height: | Size: 546 B After Width: | Height: | Size: 546 B |
Before Width: | Height: | Size: 535 B After Width: | Height: | Size: 535 B |
Before Width: | Height: | Size: 543 B After Width: | Height: | Size: 543 B |
Before Width: | Height: | Size: 518 B After Width: | Height: | Size: 518 B |
Before Width: | Height: | Size: 393 B After Width: | Height: | Size: 393 B |
Before Width: | Height: | Size: 179 B After Width: | Height: | Size: 179 B |
Before Width: | Height: | Size: 180 B After Width: | Height: | Size: 180 B |
Before Width: | Height: | Size: 188 B After Width: | Height: | Size: 188 B |
Before Width: | Height: | Size: 181 B After Width: | Height: | Size: 181 B |
Before Width: | Height: | Size: 188 B After Width: | Height: | Size: 188 B |
Before Width: | Height: | Size: 182 B After Width: | Height: | Size: 182 B |
Before Width: | Height: | Size: 355 B After Width: | Height: | Size: 355 B |
BIN
textures/holostorage_export.png
Normal file
After Width: | Height: | Size: 468 B |
Before Width: | Height: | Size: 458 B After Width: | Height: | Size: 458 B |
Before Width: | Height: | Size: 446 B After Width: | Height: | Size: 446 B |
BIN
textures/holostorage_import.png
Normal file
After Width: | Height: | Size: 483 B |
Before Width: | Height: | Size: 647 B After Width: | Height: | Size: 647 B |
Before Width: | Height: | Size: 199 B |