Rename mod

This commit is contained in:
Evert Prants 2018-04-08 17:11:39 +03:00
parent aeee127113
commit 04e1032202
Signed by: evert
GPG Key ID: 1688DA83D222D0B5
37 changed files with 270 additions and 270 deletions

View File

@ -1,4 +1,4 @@
# Storagetest # Holostorage
![](screenshot.png) ![](screenshot.png)
A solution to your hoarding addiction. In [Minetest](http://minetest.net). A solution to your hoarding addiction. In [Minetest](http://minetest.net).

View File

@ -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()) local modpath = minetest.get_modpath(minetest.get_current_modname())
storagetest.modpath = modpath holostorage.modpath = modpath
storagetest.devices = {} holostorage.devices = {}
-- Network -- Network
dofile(modpath.."/network.lua") dofile(modpath.."/network.lua")

View File

@ -1,4 +1,4 @@
-- Storagetest items -- holostorage items
-- Drives -- Drives
dofile(storagetest.modpath.."/items/storage_disk.lua") dofile(holostorage.modpath.."/items/storage_disk.lua")

View File

@ -1,7 +1,7 @@
-- Storage disks -- Storage disks
storagetest.disks = {} holostorage.disks = {}
storagetest.disks.memcache = {} holostorage.disks.memcache = {}
local function inv_to_table(inv) local function inv_to_table(inv)
local t = {} local t = {}
@ -25,14 +25,14 @@ local function table_to_inv(inv, t)
end end
end end
function storagetest.disks.register_disk(index, desc, capacity) function holostorage.disks.register_disk(index, desc, capacity)
local mod = minetest.get_current_modname() local mod = minetest.get_current_modname()
minetest.register_craftitem(mod..":storage_disk"..index, { minetest.register_craftitem(mod..":storage_disk"..index, {
description = desc.."\nStores "..capacity.." Stacks", description = desc.."\nStores "..capacity.." Stacks",
inventory_image = "storagetest_disk"..index..".png", inventory_image = "holostorage_disk"..index..".png",
groups = {storagetest_disk = 1}, groups = {holostorage_disk = 1},
storagetest_capacity = capacity, holostorage_capacity = capacity,
storagetest_name = "disk"..index, holostorage_name = "disk"..index,
stack_max = 1, stack_max = 1,
on_secondary_use = function (itemstack, user, pointed_thing) on_secondary_use = function (itemstack, user, pointed_thing)
return stack return stack
@ -46,26 +46,26 @@ local function create_invref(ptr, capacity)
return inv return inv
end end
function storagetest.disks.ensure_disk_inventory(stack, pstr) function holostorage.disks.ensure_disk_inventory(stack, pstr)
local meta = stack:get_meta() local meta = stack:get_meta()
local tag = meta:get_string("storage_tag") 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 if not tag or tag == "" then
local rnd = PseudoRandom(os.clock()) local rnd = PseudoRandom(os.clock())
local rndint = rnd.next(rnd) local rndint = rnd.next(rnd)
local diskid = "d"..pstr.."-"..rndint local diskid = "d"..pstr.."-"..rndint
meta:set_string("storage_tag", diskid) meta:set_string("storage_tag", diskid)
storagetest.disks.memcache[diskid] = create_invref(diskid, cap) holostorage.disks.memcache[diskid] = create_invref(diskid, cap)
end end
return stack return stack
end 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 world = minetest.get_worldpath()
local directory = world.."/storagetest" local directory = world.."/holostorage"
local cap = minetest.registered_items[stack:get_name()].storagetest_capacity local cap = minetest.registered_items[stack:get_name()].holostorage_capacity
local inv = create_invref(diskptr, cap) local inv = create_invref(diskptr, cap)
minetest.mkdir(directory) minetest.mkdir(directory)
@ -73,7 +73,7 @@ function storagetest.disks.load_disk_from_file(stack, diskptr)
local file = io.open(directory.."/"..filetag) local file = io.open(directory.."/"..filetag)
if not file then if not file then
storagetest.disks.memcache[diskptr] = inv holostorage.disks.memcache[diskptr] = inv
return diskptr return diskptr
end end
@ -85,45 +85,45 @@ function storagetest.disks.load_disk_from_file(stack, diskptr)
file:close() file:close()
table_to_inv(inv, minetest.deserialize(str)) table_to_inv(inv, minetest.deserialize(str))
storagetest.disks.memcache[diskptr] = inv holostorage.disks.memcache[diskptr] = inv
return diskptr return diskptr
end end
function storagetest.disks.save_disk_to_file(diskptr) function holostorage.disks.save_disk_to_file(diskptr)
if not storagetest.disks.memcache[diskptr] then return nil end if not holostorage.disks.memcache[diskptr] then return nil end
local world = minetest.get_worldpath() local world = minetest.get_worldpath()
local directory = world.."/storagetest" local directory = world.."/holostorage"
local filetag = minetest.sha1(diskptr)..".invref" local filetag = minetest.sha1(diskptr)..".invref"
minetest.mkdir(directory) minetest.mkdir(directory)
local inv = storagetest.disks.memcache[diskptr] local inv = holostorage.disks.memcache[diskptr]
local data = minetest.serialize(inv_to_table(inv)) local data = minetest.serialize(inv_to_table(inv))
minetest.safe_file_write(directory.."/"..filetag, data) minetest.safe_file_write(directory.."/"..filetag, data)
return diskptr return diskptr
end end
function storagetest.disks.save_disks_to_file() function holostorage.disks.save_disks_to_file()
for diskptr in pairs(storagetest.disks.memcache) do for diskptr in pairs(holostorage.disks.memcache) do
storagetest.disks.save_disk_to_file(diskptr) holostorage.disks.save_disk_to_file(diskptr)
end end
end end
-- Make sure stack is disk -- 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() 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 end
-- Save disks on shutdown -- Save disks on shutdown
minetest.register_on_shutdown(function () minetest.register_on_shutdown(function ()
storagetest.disks.save_disks_to_file() holostorage.disks.save_disks_to_file()
end) end)
local capacities = {1000, 8000, 16000, 32000, 64000} local capacities = {1000, 8000, 16000, 32000, 64000}
local descriptions = {"1K Disk", "8K Disk", "16K Disk", "32K Disk", "64K Disk"} local descriptions = {"1K Disk", "8K Disk", "16K Disk", "32K Disk", "64K Disk"}
for i = 1, 5 do for i = 1, 5 do
storagetest.disks.register_disk(i, descriptions[i], capacities[i]) holostorage.disks.register_disk(i, descriptions[i], capacities[i])
end end

View File

@ -1,3 +1,3 @@
name = storagetest name = holostorage
description = A solution to your hoarding addiction. description = A solution to your hoarding addiction.
depends = default depends = default

View File

@ -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) -- Some code borrowed from Technic (https://github.com/minetest-mods/technic/blob/master/technic/machines/switching_station.lua)
storagetest.network = {} holostorage.network = {}
storagetest.network.networks = {} holostorage.network.networks = {}
storagetest.network.devices = {} holostorage.network.devices = {}
storagetest.network.redundant_warn = {} 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) local node = minetest.get_node_or_nil(pos)
if node then return node end if node then return node end
local vm = VoxelManip() local vm = VoxelManip()
@ -18,12 +18,12 @@ local function get_item_group(name, grp)
return minetest.get_item_group(name, grp) > 0 return minetest.get_item_group(name, grp) > 0
end end
function storagetest.network.is_network_conductor(name) function holostorage.network.is_network_conductor(name)
return get_item_group(name, "storagetest_distributor") return get_item_group(name, "holostorage_distributor")
end end
function storagetest.network.is_network_device(name) function holostorage.network.is_network_device(name)
return get_item_group(name, "storagetest_device") return get_item_group(name, "holostorage_device")
end end
----------------------- -----------------------
@ -41,7 +41,7 @@ end
-- Add a node to the network -- Add a node to the network
local function add_network_node(nodes, pos, network_id) local function add_network_node(nodes, pos, network_id)
local node_id = minetest.hash_node_position(pos) 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 if nodes[node_id] then
return false return false
end end
@ -56,23 +56,23 @@ local function add_cable_node(nodes, pos, network_id, queue)
end end
local check_node_subp = function(dv_nodes, st_nodes, controllers, all_nodes, pos, devices, c_pos, network_id, queue) 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 meta = minetest.get_meta(pos)
local name = minetest.get_node(pos).name 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) add_cable_node(all_nodes, pos, network_id, queue)
end end
if devices[name] then if devices[name] then
meta:set_string("st_network", minetest.pos_to_string(c_pos)) 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 -- Another controller, disable it
add_network_node(controllers, pos, network_id) add_network_node(controllers, pos, network_id)
meta:set_int("active", 0) 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) 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) add_network_node(dv_nodes, pos, network_id)
end end
@ -103,7 +103,7 @@ end
local function get_network(c_pos, positions) local function get_network(c_pos, positions)
local network_id = minetest.hash_node_position(c_pos) 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 if cached then
touch_nodes(cached.dv_nodes) touch_nodes(cached.dv_nodes)
@ -126,9 +126,9 @@ local function get_network(c_pos, positions)
queue = {} queue = {}
local node = minetest.get_node(pos) 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) 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} queue = {c_pos}
end end
@ -136,7 +136,7 @@ local function get_network(c_pos, positions)
local to_visit = {} local to_visit = {}
for _, posi in ipairs(queue) do for _, posi in ipairs(queue) do
traverse_network(dv_nodes, st_nodes, controllers, all_nodes, 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 end
queue = to_visit queue = to_visit
end end
@ -147,7 +147,7 @@ local function get_network(c_pos, positions)
controllers = flatten(controllers) controllers = flatten(controllers)
all_nodes = flatten(all_nodes) 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} st_nodes = st_nodes, controllers = controllers}
return dv_nodes, st_nodes return dv_nodes, st_nodes
end end
@ -156,29 +156,29 @@ end
-- Controller ABM -- -- Controller ABM --
-------------------- --------------------
storagetest.network.active_state = true holostorage.network.active_state = true
minetest.register_chatcommand("storagectl", { minetest.register_chatcommand("storagectl", {
params = "state", params = "state",
description = "Enables or disables Storagetest's storage controller ABM", description = "Enables or disables holostorage's storage controller ABM",
privs = { basic_privs = true }, privs = { basic_privs = true },
func = function(name, state) func = function(name, state)
if state == "on" then if state == "on" then
storagetest.network.active_state = true holostorage.network.active_state = true
else else
storagetest.network.active_state = false holostorage.network.active_state = false
end end
end end
}) })
function storagetest.network.register_abm_controller(name) function holostorage.network.register_abm_controller(name)
minetest.register_abm({ minetest.register_abm({
nodenames = {name}, nodenames = {name},
label = "Storage Controller", -- allows the mtt profiler to profile this abm individually label = "Storage Controller", -- allows the mtt profiler to profile this abm individually
interval = 1, interval = 1,
chance = 1, chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider) 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 meta = minetest.get_meta(pos)
local meta1 = nil local meta1 = nil
@ -207,16 +207,16 @@ function storagetest.network.register_abm_controller(name)
local poshash = minetest.hash_node_position(pos) local poshash = minetest.hash_node_position(pos)
if not storagetest.network.redundant_warn[poshash] then if not holostorage.network.redundant_warn[poshash] then
storagetest.network.redundant_warn[poshash] = true holostorage.network.redundant_warn[poshash] = true
print("[Storagetest] Warning: redundant controller found near "..minetest.pos_to_string(pos)) print("[holostorage] Warning: redundant controller found near "..minetest.pos_to_string(pos))
end end
errored = true errored = true
return return
end end
local name = minetest.get_node(pos1).name 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 if networked then
ntwks[pos1] = true ntwks[pos1] = true
nw_branches = nw_branches + 1 nw_branches = nw_branches + 1
@ -240,14 +240,14 @@ function storagetest.network.register_abm_controller(name)
-- Run all the nodes -- Run all the nodes
local function run_nodes(list) local function run_nodes(list)
for _, pos2 in ipairs(list) do 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 node2 = minetest.get_node(pos2)
local nodedef local nodedef
if node2 and node2.name then if node2 and node2.name then
nodedef = minetest.registered_nodes[node2.name] nodedef = minetest.registered_nodes[node2.name]
end end
if nodedef and nodedef.storagetest_run then if nodedef and nodedef.holostorage_run then
nodedef.storagetest_run(pos2, node2, pos) nodedef.holostorage_run(pos2, node2, pos)
end end
end end
end end
@ -266,7 +266,7 @@ end
local function check_connections(pos) local function check_connections(pos)
local machines = {} local machines = {}
for name in pairs(storagetest.devices) do for name in pairs(holostorage.devices) do
machines[name] = true machines[name] = true
end end
local connections = {} local connections = {}
@ -279,14 +279,14 @@ local function check_connections(pos)
{x=pos.x, y=pos.y, z=pos.z-1}} {x=pos.x, y=pos.y, z=pos.z-1}}
for _,connected_pos in pairs(positions) do for _,connected_pos in pairs(positions) do
local name = minetest.get_node(connected_pos).name 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) table.insert(connections,connected_pos)
end end
end end
return connections return connections
end end
function storagetest.network.clear_networks(pos) function holostorage.network.clear_networks(pos)
local node = minetest.get_node(pos) local node = minetest.get_node(pos)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local name = node.name local name = node.name
@ -295,52 +295,52 @@ function storagetest.network.clear_networks(pos)
if #positions < 1 then return end if #positions < 1 then return end
local dead_end = #positions == 1 local dead_end = #positions == 1
for _,connected_pos in pairs(positions) do 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) local net = holostorage.network.devices[minetest.hash_node_position(connected_pos)] or minetest.hash_node_position(connected_pos)
if net and storagetest.network.networks[net] then if net and holostorage.network.networks[net] then
if dead_end and placed then if dead_end and placed then
-- Dead end placed, add it to the network -- Dead end placed, add it to the network
-- Get the network -- Get the network
local node_at = minetest.get_node(positions[1]) 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 -- We're evidently not on a network, nothing to add ourselves to
return return
end end
local c_pos = minetest.get_position_from_hash(network_id) 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 -- Actually add it to the (cached) network
-- This is similar to check_node_subp -- 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 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) table.insert(network.all_nodes, pos)
end end
if storagetest.devices[name] then if holostorage.devices[name] then
meta:set_string("st_network", minetest.pos_to_string(c_pos)) 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) 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) 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) table.insert(network.dv_nodes, pos)
end end
end end
elseif dead_end and not placed then elseif dead_end and not placed then
-- Dead end removed, remove it from the network -- Dead end removed, remove it from the network
-- Get the network -- Get the network
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 remove ourselves from -- We're evidently not on a network, nothing to remove ourselves from
return return
end end
local network = storagetest.network.networks[network_id] local network = holostorage.network.networks[network_id]
-- Search for and remove device -- 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 tblname,table in pairs(network) do
for devicenum,device in pairs(table) do for devicenum,device in pairs(table) do
if device.x == pos.x if device.x == pos.x
@ -352,11 +352,11 @@ function storagetest.network.clear_networks(pos)
end end
else else
-- Not a dead end, so the whole network needs to be recalculated -- 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) local pos1 = minetest.hash_node_position(v)
storagetest.network.devices[pos1] = nil holostorage.network.devices[pos1] = nil
end end
storagetest.network.networks[net] = nil holostorage.network.networks[net] = nil
end end
end end
end end
@ -376,21 +376,21 @@ local function controller_timeout_count(pos, tier)
end end
end end
function storagetest.network.register_abm_nodes() function holostorage.network.register_abm_nodes()
minetest.register_abm({ minetest.register_abm({
label = "Devices: timeout check", label = "Devices: timeout check",
nodenames = {"group:storagetest_device"}, nodenames = {"group:holostorage_device"},
interval = 1, interval = 1,
chance = 1, chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider) action = function(pos, node, active_object_count, active_object_count_wider)
local meta = minetest.get_meta(pos) 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] local nodedef = minetest.registered_nodes[node.name]
if nodedef and nodedef.storagetest_disabled_name then if nodedef and nodedef.holostorage_disabled_name then
node.name = nodedef.storagetest_disabled_name node.name = nodedef.holostorage_disabled_name
minetest.swap_node(pos, node) minetest.swap_node(pos, node)
elseif nodedef and nodedef.storagetest_on_disable then elseif nodedef and nodedef.holostorage_on_disable then
nodedef.storagetest_on_disable(pos, node) nodedef.holostorage_on_disable(pos, node)
end end
if nodedef then if nodedef then
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
@ -405,8 +405,8 @@ end
-- Network Functions -- -- Network Functions --
----------------------- -----------------------
function storagetest.network.get_storage_devices(network_id) function holostorage.network.get_storage_devices(network_id)
local network = storagetest.network.networks[network_id] local network = holostorage.network.networks[network_id]
if not network or not network.st_nodes then return {} end if not network or not network.st_nodes then return {} end
return network.st_nodes return network.st_nodes
end end
@ -418,23 +418,23 @@ function concat(t1,t2)
return t1 return t1
end end
function storagetest.network.get_storage_inventories(network_id) function holostorage.network.get_storage_inventories(network_id)
local storage_nodes = storagetest.network.get_storage_devices(network_id) local storage_nodes = holostorage.network.get_storage_devices(network_id)
local items = {} local items = {}
for _,pos in pairs(storage_nodes) do for _,pos in pairs(storage_nodes) do
local stacks = storagetest.stack_list(pos) local stacks = holostorage.stack_list(pos)
items = concat(items, stacks) items = concat(items, stacks)
end end
return items return items
end end
function storagetest.network.insert_item(network_id, stack) function holostorage.network.insert_item(network_id, stack)
local storage_nodes = storagetest.network.get_storage_devices(network_id) local storage_nodes = holostorage.network.get_storage_devices(network_id)
for _,pos in pairs(storage_nodes) do 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 if success then
return success, leftover return success, leftover
end end
@ -443,17 +443,17 @@ function storagetest.network.insert_item(network_id, stack)
return nil return nil
end end
function storagetest.network.take_item(network_id, stack) function holostorage.network.take_item(network_id, stack)
local storage_nodes = storagetest.network.get_storage_devices(network_id) local storage_nodes = holostorage.network.get_storage_devices(network_id)
for _,pos in pairs(storage_nodes) do 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 success and stacki then
if stacki:get_count() == stack:get_count() then if stacki:get_count() == stack:get_count() then
return success, stacki return success, stacki
else else
stack:set_count(stack:get_count() - stacki:get_count()) 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 end
end end

View File

@ -1,23 +1,23 @@
-- Storagetest nodes -- holostorage nodes
-- Common registrations -- Common registrations
dofile(storagetest.modpath.."/nodes/common.lua") dofile(holostorage.modpath.."/nodes/common.lua")
-- Controller -- Controller
dofile(storagetest.modpath.."/nodes/controller.lua") dofile(holostorage.modpath.."/nodes/controller.lua")
-- Cabling -- Cabling
dofile(storagetest.modpath.."/nodes/cable.lua") dofile(holostorage.modpath.."/nodes/cable.lua")
-- Disk drives -- Disk drives
dofile(storagetest.modpath.."/nodes/disk_drive.lua") dofile(holostorage.modpath.."/nodes/disk_drive.lua")
-- Grids -- Grids
dofile(storagetest.modpath.."/nodes/grid.lua") dofile(holostorage.modpath.."/nodes/grid.lua")
-- Buses -- Buses
dofile(storagetest.modpath.."/nodes/bus.lua") dofile(holostorage.modpath.."/nodes/bus.lua")
-- Start the network -- Start the network
storagetest.network.register_abm_controller("storagetest:controller_active") holostorage.network.register_abm_controller("holostorage:controller_active")
storagetest.network.register_abm_nodes() holostorage.network.register_abm_nodes()

View File

@ -1,4 +1,4 @@
-- Storagetest cabling -- holostorage cabling
local function get_formspec(title, filter) local function get_formspec(title, filter)
local fl = "Blacklist" local fl = "Blacklist"
@ -65,22 +65,22 @@ local function flip_filter(pos, form, fields, player)
end end
end end
minetest.register_node("storagetest:import_bus", { minetest.register_node("holostorage:import_bus", {
description = "Import Bus", description = "Import Bus",
tiles = { tiles = {
"storagetest_machine_block.png", "storagetest_machine_block.png", "storagetest_machine_block.png", "holostorage_machine_block.png", "holostorage_machine_block.png", "holostorage_machine_block.png",
"storagetest_machine_block.png", "storagetest_machine_block.png", "storagetest_import.png", "holostorage_machine_block.png", "holostorage_machine_block.png", "holostorage_import.png",
}, },
paramtype2 = "facedir", paramtype2 = "facedir",
is_ground_content = false, is_ground_content = false,
groups = { groups = {
storagetest_distributor = 1, holostorage_distributor = 1,
storagetest_device = 1, holostorage_device = 1,
cracky = 2, cracky = 2,
oddly_breakable_by_hand = 2 oddly_breakable_by_hand = 2
}, },
on_construct = function (pos) on_construct = function (pos)
storagetest.network.clear_networks(pos) holostorage.network.clear_networks(pos)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_string("formspec", get_formspec("Import Bus", 0)) meta:set_string("formspec", get_formspec("Import Bus", 0))
@ -89,14 +89,14 @@ minetest.register_node("storagetest:import_bus", {
meta:set_int("filter", 0) meta:set_int("filter", 0)
end, end,
on_destruct = storagetest.network.clear_networks, on_destruct = holostorage.network.clear_networks,
on_receive_fields = flip_filter, on_receive_fields = flip_filter,
storagetest_run = function (pos, _, controller) holostorage_run = function (pos, _, controller)
local network = minetest.hash_node_position(controller) local network = minetest.hash_node_position(controller)
local node = minetest.get_node(pos) local node = minetest.get_node(pos)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local inv = meta:get_inventory() 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) local front_node = minetest.get_node(front)
if front_node.name ~= "air" then if front_node.name ~= "air" then
@ -121,7 +121,7 @@ minetest.register_node("storagetest:import_bus", {
end end
if can_take then 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 if success then
stack:set_count(stack:get_count() - 1) stack:set_count(stack:get_count() - 1)
front_inv:set_stack("main", index, stack) front_inv:set_stack("main", index, stack)
@ -138,35 +138,35 @@ minetest.register_node("storagetest:import_bus", {
allow_metadata_inventory_put = inventory_ghost_put allow_metadata_inventory_put = inventory_ghost_put
}) })
minetest.register_node("storagetest:export_bus", { minetest.register_node("holostorage:export_bus", {
description = "Export Bus", description = "Export Bus",
tiles = { tiles = {
"storagetest_machine_block.png", "storagetest_machine_block.png", "storagetest_machine_block.png", "holostorage_machine_block.png", "holostorage_machine_block.png", "holostorage_machine_block.png",
"storagetest_machine_block.png", "storagetest_machine_block.png", "storagetest_export.png", "holostorage_machine_block.png", "holostorage_machine_block.png", "holostorage_export.png",
}, },
paramtype2 = "facedir", paramtype2 = "facedir",
is_ground_content = false, is_ground_content = false,
groups = { groups = {
storagetest_distributor = 1, holostorage_distributor = 1,
storagetest_device = 1, holostorage_device = 1,
cracky = 2, cracky = 2,
oddly_breakable_by_hand = 2 oddly_breakable_by_hand = 2
}, },
on_construct = function (pos) on_construct = function (pos)
storagetest.network.clear_networks(pos) holostorage.network.clear_networks(pos)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_string("formspec", get_formspec("Export Bus")) meta:set_string("formspec", get_formspec("Export Bus"))
local inv = meta:get_inventory() local inv = meta:get_inventory()
inv:set_size("filter", 8) inv:set_size("filter", 8)
end, end,
on_destruct = storagetest.network.clear_networks, on_destruct = holostorage.network.clear_networks,
storagetest_run = function (pos, _, controller) holostorage_run = function (pos, _, controller)
local network = minetest.hash_node_position(controller) local network = minetest.hash_node_position(controller)
local node = minetest.get_node(pos) local node = minetest.get_node(pos)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local inv = meta:get_inventory() 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) local front_node = minetest.get_node(front)
if front_node.name ~= "air" then 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_inv = front_meta:get_inventory()
local front_def = minetest.registered_nodes[front_node.name] local front_def = minetest.registered_nodes[front_node.name]
if front_inv:get_list("main") then 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 for index, stack in pairs(items) do
if not stack:is_empty() then if not stack:is_empty() then
local can_take = false local can_take = false
@ -189,7 +189,7 @@ minetest.register_node("storagetest:export_bus", {
end end
if can_take then 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 if success then
front_inv:add_item("main", gotten) front_inv:add_item("main", gotten)
break -- Don't take more than one per cycle 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 allow_metadata_inventory_put = inventory_ghost_put
}) })
storagetest.devices["storagetest:import_bus"] = true holostorage.devices["holostorage:import_bus"] = true
storagetest.devices["storagetest:export_bus"] = true holostorage.devices["holostorage:export_bus"] = true

View File

@ -1,9 +1,9 @@
-- Storagetest cabling -- holostorage cabling
minetest.register_node("storagetest:cable", { minetest.register_node("holostorage:cable", {
description = "Storage Cable", description = "Storage Cable",
drawtype = "nodebox", drawtype = "nodebox",
tiles = {"storagetest_cable.png"}, tiles = {"holostorage_cable.png"},
node_box = { node_box = {
type = "connected", type = "connected",
fixed = {{-1/8, -1/8, -1/8, 1/8, 1/8, 1/8}}, 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" }, connect_sides = { "top", "bottom", "front", "left", "back", "right" },
is_ground_content = false, is_ground_content = false,
connects_to = { connects_to = {
"group:storagetest_controller", "group:holostorage_controller",
"group:storagetest_distributor", "group:holostorage_distributor",
"group:storagetest_cable", "group:holostorage_cable",
}, },
groups = { groups = {
storagetest_distributor = 1, holostorage_distributor = 1,
storagetest_cable = 1, holostorage_cable = 1,
cracky = 2, cracky = 2,
oddly_breakable_by_hand = 2 oddly_breakable_by_hand = 2
}, },
on_construct = function (pos) on_construct = function (pos)
storagetest.network.clear_networks(pos) holostorage.network.clear_networks(pos)
end, end,
on_destruct = storagetest.network.clear_networks, on_destruct = holostorage.network.clear_networks,
}) })

View File

@ -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) local node = minetest.get_node(pos)
if node.name == noded.name then if node.name == noded.name then
return return
@ -10,7 +10,7 @@ function storagetest.helpers.swap_node(pos, noded)
minetest.swap_node(pos, noded) minetest.swap_node(pos, noded)
end end
function storagetest.helpers.grid_refresh(pos, n, controller) function holostorage.helpers.grid_refresh(pos, n, controller)
local node = minetest.get_node(pos) local node = minetest.get_node(pos)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local nodedef = minetest.registered_nodes[node.name] 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) minetest.get_node_timer(pos):start(0.02)
end end
if nodedef.storagetest_enabled_name then if nodedef.holostorage_enabled_name then
node.name = nodedef.storagetest_enabled_name node.name = nodedef.holostorage_enabled_name
storagetest.helpers.swap_node(pos, node) holostorage.helpers.swap_node(pos, node)
end end
end end
function storagetest.front(pos, fd) function holostorage.front(pos, fd)
local front = minetest.facedir_to_dir(fd) local front = minetest.facedir_to_dir(fd)
front.x = front.x * -1 + pos.x front.x = front.x * -1 + pos.x
front.y = front.y * -1 + pos.y front.y = front.y * -1 + pos.y

View File

@ -1,16 +1,16 @@
-- Storagetest controller -- holostorage controller
minetest.register_node("storagetest:controller", { minetest.register_node("holostorage:controller", {
description = "Storage Controller", description = "Storage Controller",
tiles = {"storagetest_controller.png"}, tiles = {"holostorage_controller.png"},
on_construct = function (pos) on_construct = function (pos)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_string("infotext", "Storage Controller") meta:set_string("infotext", "Storage Controller")
meta:set_string("active", 1) meta:set_string("active", 1)
meta:set_string("channel", "controller"..minetest.pos_to_string(pos)) 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) local poshash = minetest.hash_node_position(pos)
storagetest.network.redundant_warn[poshash] = nil holostorage.network.redundant_warn[poshash] = nil
end, end,
after_dig_node = function(pos) after_dig_node = function(pos)
minetest.forceload_free_block(pos) minetest.forceload_free_block(pos)
@ -21,15 +21,15 @@ minetest.register_node("storagetest:controller", {
end, end,
groups = { groups = {
cracky = 1, cracky = 1,
storagetest_controller = 1 holostorage_controller = 1
} }
}) })
minetest.register_node("storagetest:controller_active", { minetest.register_node("holostorage:controller_active", {
description = "Storage Controller", description = "Storage Controller",
tiles = { tiles = {
{ {
name = "storagetest_controller_animated.png", name = "holostorage_controller_animated.png",
animation = { animation = {
type = "vertical_frames", type = "vertical_frames",
aspect_w = 16, aspect_w = 16,
@ -38,10 +38,10 @@ minetest.register_node("storagetest:controller_active", {
}, },
} }
}, },
drop = "storagetest:controller", drop = "holostorage:controller",
groups = { groups = {
cracky = 1, cracky = 1,
not_in_creative_inventory = 1, not_in_creative_inventory = 1,
storagetest_controller = 1 holostorage_controller = 1
} }
}) })

View File

@ -33,7 +33,7 @@ local function timer(pos, elapsed)
local count = count_inv(inv) local count = count_inv(inv)
local cnname = minetest.registered_nodes[node.name]["_basename"] local cnname = minetest.registered_nodes[node.name]["_basename"]
node.name = cnname..count node.name = cnname..count
storagetest.helpers.swap_node(pos, node) holostorage.helpers.swap_node(pos, node)
return refresh return refresh
end end
@ -43,7 +43,7 @@ local function allow_metadata_inventory_put (pos, listname, index, stack, player
return 0 return 0
end end
if not storagetest.disks.is_valid_disk(stack) then if not holostorage.disks.is_valid_disk(stack) then
return 0 return 0
end end
@ -68,13 +68,13 @@ local function sort_by_stack_name( ... )
-- body -- body
end end
function storagetest.stack_list(pos) function holostorage.stack_list(pos)
local invs = storagetest.get_all_inventories(pos) local invs = holostorage.get_all_inventories(pos)
if not invs then return {} end if not invs then return {} end
local tabl = {} local tabl = {}
for _,diskptr in pairs(invs) do for _,diskptr in pairs(invs) do
local invref = storagetest.disks.memcache[diskptr] local invref = holostorage.disks.memcache[diskptr]
if invref then if invref then
local stacks = invref:get_list("main") local stacks = invref:get_list("main")
for _,stack in pairs(stacks) do for _,stack in pairs(stacks) do
@ -89,15 +89,15 @@ function storagetest.stack_list(pos)
return tabl return tabl
end end
function storagetest.insert_stack(pos, stack) function holostorage.insert_stack(pos, stack)
local invs = storagetest.get_all_inventories(pos) local invs = holostorage.get_all_inventories(pos)
if not invs then return {} end if not invs then return {} end
local tabl = {} local tabl = {}
local success = false local success = false
local leftover local leftover
for _,diskptr in pairs(invs) do for _,diskptr in pairs(invs) do
local invref = storagetest.disks.memcache[diskptr] local invref = holostorage.disks.memcache[diskptr]
if invref then if invref then
if invref:room_for_item("main", stack) then if invref:room_for_item("main", stack) then
leftover = invref:add_item("main", stack) leftover = invref:add_item("main", stack)
@ -110,15 +110,15 @@ function storagetest.insert_stack(pos, stack)
return success, leftover return success, leftover
end end
function storagetest.take_stack(pos, stack) function holostorage.take_stack(pos, stack)
local invs = storagetest.get_all_inventories(pos) local invs = holostorage.get_all_inventories(pos)
if not invs then return {} end if not invs then return {} end
local tabl = {} local tabl = {}
local stack_ret local stack_ret
local success = false local success = false
for _,diskptr in pairs(invs) do for _,diskptr in pairs(invs) do
local invref = storagetest.disks.memcache[diskptr] local invref = holostorage.disks.memcache[diskptr]
if invref then if invref then
local list = invref:get_list("main") local list = invref:get_list("main")
for i, stacki in pairs(list) do for i, stacki in pairs(list) do
@ -142,7 +142,7 @@ function storagetest.take_stack(pos, stack)
return success, stack_ret return success, stack_ret
end end
function storagetest.get_all_inventories(pos) function holostorage.get_all_inventories(pos)
local node = minetest.get_node(pos) local node = minetest.get_node(pos)
if minetest.get_item_group(node.name, "disk_drive") == 0 then return nil end if minetest.get_item_group(node.name, "disk_drive") == 0 then return nil end
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
@ -166,26 +166,26 @@ end
local function register_disk_drive(index) local function register_disk_drive(index)
local groups = { local groups = {
cracky = 1, cracky = 1,
storagetest_distributor = 1, holostorage_distributor = 1,
storagetest_device = 1, holostorage_device = 1,
storagetest_storage = 1, holostorage_storage = 1,
disk_drive = 1, disk_drive = 1,
} }
local driveoverlay = "" local driveoverlay = ""
if index ~= 0 then if index ~= 0 then
groups["not_in_creative_inventory"] = 1 groups["not_in_creative_inventory"] = 1
driveoverlay = "^storagetest_drive_section"..index..".png" driveoverlay = "^holostorage_drive_section"..index..".png"
end end
minetest.register_node("storagetest:disk_drive"..index, { minetest.register_node("holostorage:disk_drive"..index, {
description = "Disk Drive", description = "Disk Drive",
tiles = { tiles = {
"storagetest_drive_side.png", "storagetest_drive_side.png", "storagetest_drive_side.png", "holostorage_drive_side.png", "holostorage_drive_side.png", "holostorage_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.png"..driveoverlay,
}, },
drop = "storagetest:disk_drive0", drop = "holostorage:disk_drive0",
_basename = "storagetest:disk_drive", _basename = "holostorage:disk_drive",
paramtype2 = "facedir", paramtype2 = "facedir",
on_timer = timer, on_timer = timer,
groups = groups, groups = groups,
@ -194,9 +194,9 @@ local function register_disk_drive(index)
meta:set_string("formspec", get_formspec()) meta:set_string("formspec", get_formspec())
local inv = meta:get_inventory() local inv = meta:get_inventory()
inv:set_size("main", 6) inv:set_size("main", 6)
storagetest.network.clear_networks(pos) holostorage.network.clear_networks(pos)
end, end,
on_destruct = storagetest.network.clear_networks, on_destruct = holostorage.network.clear_networks,
allow_metadata_inventory_put = allow_metadata_inventory_put, allow_metadata_inventory_put = allow_metadata_inventory_put,
allow_metadata_inventory_take = allow_metadata_inventory_take, 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) minetest.get_node_timer(pos):start(0.02)
end, end,
on_metadata_inventory_put = function(pos, listname, index, stack, player) 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 meta = minetest.get_meta(pos)
local inv = meta:get_inventory() local inv = meta:get_inventory()
@ -220,7 +220,7 @@ local function register_disk_drive(index)
end, end,
}) })
storagetest.devices["storagetest:disk_drive"..index] = true holostorage.devices["holostorage:disk_drive"..index] = true
end end
-- Register 6 variants of the disk drive. -- Register 6 variants of the disk drive.
@ -232,7 +232,7 @@ end
minetest.register_abm({ minetest.register_abm({
label = "Storage Disk Synchronization", label = "Storage Disk Synchronization",
nodenames = {"group:disk_drive"}, nodenames = {"group:disk_drive"},
neighbors = {"group:storagetest_distributor"}, neighbors = {"group:holostorage_distributor"},
interval = 1, interval = 1,
chance = 1, chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider) action = function(pos, node, active_object_count, active_object_count_wider)
@ -244,9 +244,9 @@ minetest.register_abm({
local meta = stack:get_meta() local meta = stack:get_meta()
local tag = meta:get_string("storage_tag") local tag = meta:get_string("storage_tag")
if tag and tag ~= "" then if tag and tag ~= "" then
if not storagetest.disks.memcache[tag] then if not holostorage.disks.memcache[tag] then
print("loading drive",tag) print("loading drive",tag)
storagetest.disks.load_disk_from_file(stack, tag) holostorage.disks.load_disk_from_file(stack, tag)
end end
end end
end end

View File

@ -1,8 +1,8 @@
-- Storage Grid -- Storage Grid
storagetest.grid = {} holostorage.grid = {}
function storagetest.grid.sort(inlist) function holostorage.grid.sort(inlist)
local typecnt = {} local typecnt = {}
local typekeys = {} local typekeys = {}
for _, st in ipairs(inlist) do for _, st in ipairs(inlist) do
@ -46,7 +46,7 @@ function storagetest.grid.sort(inlist)
return outlist return outlist
end end
function storagetest.grid.get_formspec(scroll_lvl, pages, craft_inv) function holostorage.grid.get_formspec(scroll_lvl, pages, craft_inv)
local craft = "" local craft = ""
local title = "Grid" local title = "Grid"
local height = 6 local height = 6
@ -86,23 +86,23 @@ function storagetest.grid.get_formspec(scroll_lvl, pages, craft_inv)
default.get_hotbar_bg(0, 8) default.get_hotbar_bg(0, 8)
end end
function storagetest.grid.to_network(meta) function holostorage.grid.to_network(meta)
local ctrl = meta:get_string("controller") local ctrl = meta:get_string("controller")
if not ctrl or ctrl == "" then return nil end if not ctrl or ctrl == "" then return nil end
local network = minetest.hash_node_position(minetest.string_to_pos(ctrl)) local network = minetest.hash_node_position(minetest.string_to_pos(ctrl))
return network return network
end end
function storagetest.grid.handle_grid(pos, meta, network, inv) function holostorage.grid.handle_grid(pos, meta, network, inv)
local refresh = false local refresh = false
local limited_items = {} 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 scroll = meta:get_int("scroll_len") or 0
local grid = inv:get_size("grid") local grid = inv:get_size("grid")
-- Sort the items -- Sort the items
items = storagetest.grid.sort(items) items = holostorage.grid.sort(items)
-- Search -- Search
local search = meta:get_string("search") local search = meta:get_string("search")
@ -128,7 +128,7 @@ function storagetest.grid.handle_grid(pos, meta, network, inv)
-- Handle inputting items -- Handle inputting items
local input = inv:get_stack("main", 1) local input = inv:get_stack("main", 1)
if not input:is_empty() then 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 if success then
inv:set_stack("main", 1, leftover) inv:set_stack("main", 1, leftover)
refresh = true refresh = true
@ -139,7 +139,7 @@ function storagetest.grid.handle_grid(pos, meta, network, inv)
local grid_craft = meta:get_int("craft") == 1 local grid_craft = meta:get_int("craft") == 1
local height = math.floor(#preserve / 8) local height = math.floor(#preserve / 8)
meta:set_int("scroll_height", height) 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 return refresh
end end
@ -164,7 +164,7 @@ local function on_receive_fields(pos, formname, fields, sender)
minetest.get_node_timer(pos):start(0.02) minetest.get_node_timer(pos):start(0.02)
end 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 if minetest.is_protected(pos, player:get_player_name()) then
return 0 return 0
end end
@ -176,7 +176,7 @@ function storagetest.grid.allow_put(pos, listname, index, stack, player)
return stack:get_count() return stack:get_count()
end 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 if from_list == "grid" and to_list == "main" then
return 0 return 0
end end
@ -185,10 +185,10 @@ function storagetest.grid.allow_move_active(pos, from_list, from_index, to_list,
local inv = meta:get_inventory() local inv = meta:get_inventory()
local stack = inv:get_stack(from_list, from_index) 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 end
function storagetest.grid.on_disable(pos) function holostorage.grid.on_disable(pos)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local prev = meta:get_string("controller") local prev = meta:get_string("controller")
if prev and prev ~= "" then if prev and prev ~= "" then
@ -197,27 +197,27 @@ function storagetest.grid.on_disable(pos)
end end
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 if from_list == "grid" and to_list == "craft" then
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local inv = meta:get_inventory() local inv = meta:get_inventory()
local stack = inv:get_stack(to_list, to_index) local stack = inv:get_stack(to_list, to_index)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local network = storagetest.grid.to_network(meta) local network = holostorage.grid.to_network(meta)
if network then if network then
storagetest.network.take_item(network, stack) holostorage.network.take_item(network, stack)
end end
end end
minetest.get_node_timer(pos):start(0.02) minetest.get_node_timer(pos):start(0.02)
end 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 if listname == "grid" then
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local network = storagetest.grid.to_network(meta) local network = holostorage.grid.to_network(meta)
if network then if network then
storagetest.network.take_item(network, stack) holostorage.network.take_item(network, stack)
end end
end end
@ -229,34 +229,34 @@ local function timer(pos, elapsed)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local node = minetest.get_node(pos) local node = minetest.get_node(pos)
local inv = meta:get_inventory() local inv = meta:get_inventory()
local network = storagetest.grid.to_network(meta) local network = holostorage.grid.to_network(meta)
if not network then if not network then
inv:set_list("grid", {}) inv:set_list("grid", {})
else else
refresh = storagetest.grid.handle_grid(pos, meta, network, inv) refresh = holostorage.grid.handle_grid(pos, meta, network, inv)
end end
return refresh return refresh
end end
minetest.register_node("storagetest:grid", { minetest.register_node("holostorage:grid", {
description = "Grid", description = "Grid",
tiles = { tiles = {
"storagetest_machine_block.png", "storagetest_machine_block.png", "storagetest_machine_block.png", "holostorage_machine_block.png", "holostorage_machine_block.png", "holostorage_machine_block.png",
"storagetest_machine_block.png", "storagetest_machine_block.png", "storagetest_grid.png", "holostorage_machine_block.png", "holostorage_machine_block.png", "holostorage_grid.png",
}, },
paramtype2 = "facedir", paramtype2 = "facedir",
on_timer = timer, on_timer = timer,
groups = { groups = {
cracky = 1, cracky = 1,
storagetest_distributor = 1, holostorage_distributor = 1,
storagetest_device = 1, holostorage_device = 1,
}, },
on_construct = function (pos) on_construct = function (pos)
storagetest.network.clear_networks(pos) holostorage.network.clear_networks(pos)
local meta = minetest.get_meta(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() local inv = meta:get_inventory()
inv:set_size("main", 1) inv:set_size("main", 1)
@ -269,8 +269,8 @@ minetest.register_node("storagetest:grid", {
minetest.get_node_timer(pos):start(0.02) minetest.get_node_timer(pos):start(0.02)
return itemstack return itemstack
end, end,
on_destruct = storagetest.network.clear_networks, on_destruct = holostorage.network.clear_networks,
storagetest_run = storagetest.helpers.grid_refresh, holostorage_run = holostorage.helpers.grid_refresh,
allow_metadata_inventory_move = function () allow_metadata_inventory_move = function ()
return 0 return 0
end, end,
@ -280,61 +280,61 @@ minetest.register_node("storagetest:grid", {
allow_metadata_inventory_take = function () allow_metadata_inventory_take = function ()
return 0 return 0
end, end,
storagetest_enabled_name = "storagetest:grid_active", holostorage_enabled_name = "holostorage:grid_active",
storagetest_on_disable = storagetest.grid.on_disable, holostorage_on_disable = holostorage.grid.on_disable,
}) })
minetest.register_node("storagetest:grid_active", { minetest.register_node("holostorage:grid_active", {
description = "Grid", description = "Grid",
tiles = { tiles = {
"storagetest_machine_block.png", "storagetest_machine_block.png", "storagetest_machine_block.png", "holostorage_machine_block.png", "holostorage_machine_block.png", "holostorage_machine_block.png",
"storagetest_machine_block.png", "storagetest_machine_block.png", "storagetest_grid_active.png", "holostorage_machine_block.png", "holostorage_machine_block.png", "holostorage_grid_active.png",
}, },
drop = "storagetest:grid", drop = "holostorage:grid",
paramtype2 = "facedir", paramtype2 = "facedir",
on_timer = timer, on_timer = timer,
groups = { groups = {
cracky = 1, cracky = 1,
storagetest_distributor = 1, holostorage_distributor = 1,
storagetest_device = 1, holostorage_device = 1,
not_in_creative_inventory = 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) on_metadata_inventory_put = function(pos, listname, index, stack, player)
minetest.get_node_timer(pos):start(0.02) minetest.get_node_timer(pos):start(0.02)
end, 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) on_rightclick = function (pos, node, clicker, itemstack, pointed_thing)
minetest.get_node_timer(pos):start(0.05) minetest.get_node_timer(pos):start(0.05)
return itemstack return itemstack
end, end,
on_destruct = storagetest.network.clear_networks, on_destruct = holostorage.network.clear_networks,
storagetest_run = storagetest.helpers.grid_refresh, holostorage_run = holostorage.helpers.grid_refresh,
storagetest_disabled_name = "storagetest:grid", holostorage_disabled_name = "holostorage:grid",
allow_metadata_inventory_move = storagetest.grid.allow_move_active, allow_metadata_inventory_move = holostorage.grid.allow_move_active,
allow_metadata_inventory_put = storagetest.grid.allow_put, allow_metadata_inventory_put = holostorage.grid.allow_put,
on_receive_fields = on_receive_fields, on_receive_fields = on_receive_fields,
}) })
-- Crafting version -- Crafting version
minetest.register_node("storagetest:crafting_grid", { minetest.register_node("holostorage:crafting_grid", {
description = "Crafting Grid", description = "Crafting Grid",
tiles = { tiles = {
"storagetest_machine_block.png", "storagetest_machine_block.png", "storagetest_machine_block.png", "holostorage_machine_block.png", "holostorage_machine_block.png", "holostorage_machine_block.png",
"storagetest_machine_block.png", "storagetest_machine_block.png", "storagetest_crafting_grid.png", "holostorage_machine_block.png", "holostorage_machine_block.png", "holostorage_crafting_grid.png",
}, },
paramtype2 = "facedir", paramtype2 = "facedir",
on_timer = timer, on_timer = timer,
groups = { groups = {
cracky = 1, cracky = 1,
storagetest_distributor = 1, holostorage_distributor = 1,
storagetest_device = 1, holostorage_device = 1,
}, },
on_construct = function (pos) on_construct = function (pos)
storagetest.network.clear_networks(pos) holostorage.network.clear_networks(pos)
local meta = minetest.get_meta(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() local inv = meta:get_inventory()
inv:set_size("main", 1) inv:set_size("main", 1)
@ -349,8 +349,8 @@ minetest.register_node("storagetest:crafting_grid", {
minetest.get_node_timer(pos):start(0.02) minetest.get_node_timer(pos):start(0.02)
return itemstack return itemstack
end, end,
on_destruct = storagetest.network.clear_networks, on_destruct = holostorage.network.clear_networks,
storagetest_run = storagetest.helpers.grid_refresh, holostorage_run = holostorage.helpers.grid_refresh,
allow_metadata_inventory_move = function () allow_metadata_inventory_move = function ()
return 0 return 0
end, end,
@ -360,44 +360,44 @@ minetest.register_node("storagetest:crafting_grid", {
allow_metadata_inventory_take = function () allow_metadata_inventory_take = function ()
return 0 return 0
end, end,
storagetest_enabled_name = "storagetest:crafting_grid_active", holostorage_enabled_name = "holostorage:crafting_grid_active",
storagetest_on_disable = storagetest.grid.on_disable, holostorage_on_disable = holostorage.grid.on_disable,
}) })
minetest.register_node("storagetest:crafting_grid_active", { minetest.register_node("holostorage:crafting_grid_active", {
description = "Crafting Grid", description = "Crafting Grid",
tiles = { tiles = {
"storagetest_machine_block.png", "storagetest_machine_block.png", "storagetest_machine_block.png", "holostorage_machine_block.png", "holostorage_machine_block.png", "holostorage_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_crafting_grid_active.png",
}, },
drop = "storagetest:crafting_grid", drop = "holostorage:crafting_grid",
paramtype2 = "facedir", paramtype2 = "facedir",
on_timer = timer, on_timer = timer,
groups = { groups = {
cracky = 1, cracky = 1,
storagetest_distributor = 1, holostorage_distributor = 1,
storagetest_device = 1, holostorage_device = 1,
not_in_creative_inventory = 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) on_metadata_inventory_put = function(pos, listname, index, stack, player)
minetest.get_node_timer(pos):start(0.02) minetest.get_node_timer(pos):start(0.02)
end, 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) on_rightclick = function (pos, node, clicker, itemstack, pointed_thing)
minetest.get_node_timer(pos):start(0.05) minetest.get_node_timer(pos):start(0.05)
return itemstack return itemstack
end, end,
on_destruct = storagetest.network.clear_networks, on_destruct = holostorage.network.clear_networks,
storagetest_run = storagetest.helpers.grid_refresh, holostorage_run = holostorage.helpers.grid_refresh,
storagetest_disabled_name = "storagetest:crafting_grid", holostorage_disabled_name = "holostorage:crafting_grid",
allow_metadata_inventory_move = storagetest.grid.allow_move_active, allow_metadata_inventory_move = holostorage.grid.allow_move_active,
allow_metadata_inventory_put = storagetest.grid.allow_put, allow_metadata_inventory_put = holostorage.grid.allow_put,
on_receive_fields = on_receive_fields, on_receive_fields = on_receive_fields,
}) })
storagetest.devices["storagetest:grid"] = true holostorage.devices["holostorage:grid"] = true
storagetest.devices["storagetest:grid_active"] = true holostorage.devices["holostorage:grid_active"] = true
storagetest.devices["storagetest:crafting_grid"] = true holostorage.devices["holostorage:crafting_grid"] = true
storagetest.devices["storagetest:crafting_grid_active"] = true holostorage.devices["holostorage:crafting_grid_active"] = true

Binary file not shown.

After

Width:  |  Height:  |  Size: 452 B

View File

Before

Width:  |  Height:  |  Size: 526 B

After

Width:  |  Height:  |  Size: 526 B

View File

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

Before

Width:  |  Height:  |  Size: 488 B

After

Width:  |  Height:  |  Size: 488 B

View File

Before

Width:  |  Height:  |  Size: 451 B

After

Width:  |  Height:  |  Size: 451 B

View File

Before

Width:  |  Height:  |  Size: 513 B

After

Width:  |  Height:  |  Size: 513 B

View File

Before

Width:  |  Height:  |  Size: 546 B

After

Width:  |  Height:  |  Size: 546 B

View File

Before

Width:  |  Height:  |  Size: 535 B

After

Width:  |  Height:  |  Size: 535 B

View File

Before

Width:  |  Height:  |  Size: 543 B

After

Width:  |  Height:  |  Size: 543 B

View File

Before

Width:  |  Height:  |  Size: 518 B

After

Width:  |  Height:  |  Size: 518 B

View File

Before

Width:  |  Height:  |  Size: 393 B

After

Width:  |  Height:  |  Size: 393 B

View File

Before

Width:  |  Height:  |  Size: 179 B

After

Width:  |  Height:  |  Size: 179 B

View File

Before

Width:  |  Height:  |  Size: 180 B

After

Width:  |  Height:  |  Size: 180 B

View File

Before

Width:  |  Height:  |  Size: 188 B

After

Width:  |  Height:  |  Size: 188 B

View File

Before

Width:  |  Height:  |  Size: 181 B

After

Width:  |  Height:  |  Size: 181 B

View File

Before

Width:  |  Height:  |  Size: 188 B

After

Width:  |  Height:  |  Size: 188 B

View File

Before

Width:  |  Height:  |  Size: 182 B

After

Width:  |  Height:  |  Size: 182 B

View File

Before

Width:  |  Height:  |  Size: 355 B

After

Width:  |  Height:  |  Size: 355 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 468 B

View File

Before

Width:  |  Height:  |  Size: 458 B

After

Width:  |  Height:  |  Size: 458 B

View File

Before

Width:  |  Height:  |  Size: 446 B

After

Width:  |  Height:  |  Size: 446 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 483 B

View File

Before

Width:  |  Height:  |  Size: 647 B

After

Width:  |  Height:  |  Size: 647 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 199 B