2018-04-07 15:27:34 +00:00
|
|
|
-- Storagetest commons
|
|
|
|
|
|
|
|
storagetest.helpers = {}
|
|
|
|
|
|
|
|
function storagetest.helpers.swap_node(pos, noded)
|
|
|
|
local node = minetest.get_node(pos)
|
|
|
|
if node.name == noded.name then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
minetest.swap_node(pos, noded)
|
|
|
|
end
|
|
|
|
|
2018-04-08 09:39:06 +00:00
|
|
|
function storagetest.helpers.grid_refresh(pos, n, controller)
|
2018-04-07 15:27:34 +00:00
|
|
|
local node = minetest.get_node(pos)
|
2018-04-08 09:39:06 +00:00
|
|
|
local meta = minetest.get_meta(pos)
|
2018-04-07 15:27:34 +00:00
|
|
|
local nodedef = minetest.registered_nodes[node.name]
|
2018-04-08 09:39:06 +00:00
|
|
|
local prev = meta:get_string("controller")
|
|
|
|
|
|
|
|
meta:set_string("infotext", ("%s Active"):format(nodedef.description))
|
|
|
|
meta:set_string("controller", minetest.pos_to_string(controller))
|
|
|
|
|
|
|
|
if not prev or prev == "" then
|
|
|
|
minetest.get_node_timer(pos):start(0.02)
|
|
|
|
end
|
2018-04-07 15:27:34 +00:00
|
|
|
|
|
|
|
if nodedef.storagetest_enabled_name then
|
|
|
|
node.name = nodedef.storagetest_enabled_name
|
|
|
|
storagetest.helpers.swap_node(pos, node)
|
|
|
|
end
|
|
|
|
end
|
2018-04-08 12:06:49 +00:00
|
|
|
|
|
|
|
function storagetest.front(pos, fd)
|
|
|
|
local front = minetest.facedir_to_dir(fd)
|
|
|
|
front.x = front.x * -1 + pos.x
|
|
|
|
front.y = front.y * -1 + pos.y
|
|
|
|
front.z = front.z * -1 + pos.z
|
|
|
|
return front
|
|
|
|
end
|