2019-01-05 18:04:56 +01:00
|
|
|
--[[
|
|
|
|
|
|
|
|
TechPack Warehouse
|
|
|
|
==================
|
|
|
|
|
2020-11-20 14:45:28 +01:00
|
|
|
Copyright (C) 2017-2020 Joachim Stolberg
|
2019-01-05 18:04:56 +01:00
|
|
|
|
2020-11-20 14:45:28 +01:00
|
|
|
AGPL v3
|
2019-01-05 18:04:56 +01:00
|
|
|
See LICENSE.txt for more information
|
2022-06-09 23:49:50 +02:00
|
|
|
|
2019-01-05 18:04:56 +01:00
|
|
|
box_gold.lua
|
|
|
|
|
|
|
|
]]--
|
|
|
|
|
2020-11-03 20:19:38 +01:00
|
|
|
-- Load support for I18n
|
|
|
|
local S = techpack_warehouse.S
|
|
|
|
|
2019-01-05 18:04:56 +01:00
|
|
|
--- for lazy programmers
|
|
|
|
local P = minetest.string_to_pos
|
|
|
|
local M = minetest.get_meta
|
|
|
|
local wh = techpack_warehouse
|
|
|
|
|
|
|
|
local NODE_NAME = "techpack_warehouse:box_gold"
|
2020-11-03 20:19:38 +01:00
|
|
|
local DESCRIPTION = S("Warehouse Box Gold")
|
2019-01-05 18:04:56 +01:00
|
|
|
local INV_SIZE = 3600
|
2022-06-09 23:49:50 +02:00
|
|
|
local BACKGROUND_IMG = "default_gold_block.png"
|
2019-01-05 18:04:56 +01:00
|
|
|
|
|
|
|
|
|
|
|
local Box = wh.Box:new({
|
2022-06-09 23:49:50 +02:00
|
|
|
node_name = NODE_NAME,
|
|
|
|
description = DESCRIPTION,
|
|
|
|
inv_size = INV_SIZE,
|
2019-01-05 18:04:56 +01:00
|
|
|
background_img = BACKGROUND_IMG,
|
2022-06-09 23:49:50 +02:00
|
|
|
})
|
2019-01-05 18:04:56 +01:00
|
|
|
|
|
|
|
minetest.register_node(NODE_NAME, {
|
|
|
|
description = DESCRIPTION.." (8 x "..INV_SIZE.." items)",
|
|
|
|
tiles = wh.tiles(BACKGROUND_IMG),
|
2022-06-09 23:49:50 +02:00
|
|
|
|
2019-01-05 18:04:56 +01:00
|
|
|
after_place_node = function(pos, placer, itemstack)
|
|
|
|
return wh.after_place_node(Box, pos, placer, itemstack)
|
|
|
|
end,
|
|
|
|
on_receive_fields = function(pos, formname, fields, player)
|
|
|
|
wh.on_receive_fields(Box, pos, formname, fields, player)
|
|
|
|
end,
|
|
|
|
on_timer = function(pos,elapsed)
|
|
|
|
return wh.on_timer(Box, pos,elapsed)
|
|
|
|
end,
|
2019-01-06 15:03:22 +01:00
|
|
|
can_dig = function(pos)
|
|
|
|
return wh.can_dig(Box, pos)
|
|
|
|
end,
|
2020-08-12 20:15:26 +02:00
|
|
|
on_dig = function(pos, node, player)
|
|
|
|
wh.on_dig_node(Box, pos, node, player)
|
2019-01-05 18:04:56 +01:00
|
|
|
end,
|
|
|
|
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
|
|
|
return wh.allow_metadata_inventory_put(Box, pos, listname, index, stack, player)
|
|
|
|
end,
|
|
|
|
on_metadata_inventory_put = wh.on_metadata_inventory_put,
|
|
|
|
allow_metadata_inventory_take = wh.allow_metadata_inventory_take,
|
|
|
|
allow_metadata_inventory_move = wh.allow_metadata_inventory_move,
|
2022-06-09 23:49:50 +02:00
|
|
|
|
2019-01-05 18:04:56 +01:00
|
|
|
on_rotate = screwdriver.disallow,
|
|
|
|
paramtype = "light",
|
|
|
|
sunlight_propagates = true,
|
|
|
|
paramtype2 = "facedir",
|
|
|
|
groups = {choppy=2, cracky=2, crumbly=2},
|
|
|
|
is_ground_content = false,
|
|
|
|
sounds = default.node_sound_metal_defaults(),
|
2022-06-09 23:49:50 +02:00
|
|
|
on_blast = function() end,
|
2019-01-05 18:04:56 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_node(NODE_NAME.."_active", {
|
|
|
|
description = DESCRIPTION.." (8 x "..INV_SIZE.." items)",
|
|
|
|
tiles = wh.tiles_active(BACKGROUND_IMG),
|
2022-06-09 23:49:50 +02:00
|
|
|
|
2019-01-05 18:04:56 +01:00
|
|
|
after_place_node = function(pos, placer, itemstack)
|
|
|
|
return wh.after_place_node(Box, pos, placer, itemstack)
|
|
|
|
end,
|
|
|
|
on_receive_fields = function(pos, formname, fields, player)
|
|
|
|
wh.on_receive_fields(Box, pos, formname, fields, player)
|
|
|
|
end,
|
|
|
|
on_timer = function(pos,elapsed)
|
|
|
|
return wh.on_timer(Box, pos,elapsed)
|
|
|
|
end,
|
|
|
|
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
|
|
|
return wh.allow_metadata_inventory_put(Box, pos, listname, index, stack, player)
|
|
|
|
end,
|
|
|
|
on_metadata_inventory_put = wh.on_metadata_inventory_put,
|
|
|
|
allow_metadata_inventory_take = wh.allow_metadata_inventory_take,
|
|
|
|
allow_metadata_inventory_move = wh.allow_metadata_inventory_move,
|
2022-06-09 23:49:50 +02:00
|
|
|
|
2021-01-17 22:47:23 +01:00
|
|
|
diggable = false,
|
|
|
|
can_dig = function() return false end,
|
2022-06-09 23:49:50 +02:00
|
|
|
|
2019-01-05 18:04:56 +01:00
|
|
|
on_rotate = screwdriver.disallow,
|
|
|
|
paramtype = "light",
|
|
|
|
sunlight_propagates = true,
|
|
|
|
paramtype2 = "facedir",
|
|
|
|
groups = {crumbly=0, not_in_creative_inventory=1},
|
|
|
|
is_ground_content = false,
|
|
|
|
sounds = default.node_sound_metal_defaults(),
|
2022-06-09 23:49:50 +02:00
|
|
|
on_blast = function() end,
|
2019-01-05 18:04:56 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_node(NODE_NAME.."_defect", {
|
|
|
|
description = DESCRIPTION.." (8 x "..INV_SIZE.." items)",
|
|
|
|
tiles = wh.tiles_defect(BACKGROUND_IMG),
|
2022-06-09 23:49:50 +02:00
|
|
|
|
2019-01-05 18:04:56 +01:00
|
|
|
after_place_node = function(pos, placer, itemstack)
|
|
|
|
wh.after_place_node(Box, pos, placer, itemstack)
|
|
|
|
Box.State:defect(pos, M(pos))
|
|
|
|
end,
|
2019-01-06 15:03:22 +01:00
|
|
|
can_dig = function(pos)
|
|
|
|
return wh.can_dig(Box, pos)
|
|
|
|
end,
|
2021-07-06 06:55:03 +02:00
|
|
|
on_dig = function(pos, node, player)
|
|
|
|
wh.on_dig_node(Box, pos, node, player)
|
2019-01-05 18:04:56 +01:00
|
|
|
end,
|
|
|
|
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
|
|
|
return wh.allow_metadata_inventory_put(Box, pos, listname, index, stack, player)
|
|
|
|
end,
|
|
|
|
on_metadata_inventory_put = wh.on_metadata_inventory_put,
|
|
|
|
allow_metadata_inventory_take = wh.allow_metadata_inventory_take,
|
|
|
|
allow_metadata_inventory_move = wh.allow_metadata_inventory_move,
|
2022-06-09 23:49:50 +02:00
|
|
|
|
2019-01-05 18:04:56 +01:00
|
|
|
on_rotate = screwdriver.disallow,
|
|
|
|
paramtype = "light",
|
|
|
|
sunlight_propagates = true,
|
|
|
|
paramtype2 = "facedir",
|
|
|
|
groups = {choppy=2, cracky=2, crumbly=2, not_in_creative_inventory=1},
|
|
|
|
is_ground_content = false,
|
|
|
|
sounds = default.node_sound_metal_defaults(),
|
2022-06-09 23:49:50 +02:00
|
|
|
on_blast = function() end,
|
2019-01-05 18:04:56 +01:00
|
|
|
})
|
|
|
|
|
2022-06-09 23:49:50 +02:00
|
|
|
tubelib.register_node(NODE_NAME,
|
2019-01-05 18:04:56 +01:00
|
|
|
{NODE_NAME.."_active", NODE_NAME.."_defect"}, {
|
|
|
|
on_push_item = function(pos, side, item)
|
|
|
|
local meta = M(pos)
|
2019-03-23 19:30:59 +01:00
|
|
|
meta:set_string("push_dir", wh.Turn180[side])
|
2020-12-18 03:51:31 +01:00
|
|
|
local num = wh.inv_add_item(Box, meta, item)
|
2019-01-06 15:03:22 +01:00
|
|
|
if num > 0 then
|
2019-01-05 18:04:56 +01:00
|
|
|
item:set_count(num)
|
|
|
|
return tubelib.put_item(meta, "shift", item)
|
|
|
|
end
|
2019-01-06 15:03:22 +01:00
|
|
|
return true
|
2019-01-05 18:04:56 +01:00
|
|
|
end,
|
|
|
|
on_pull_stack = function(pos, side)
|
|
|
|
return tubelib.get_stack(M(pos), "main")
|
|
|
|
end,
|
2019-01-12 19:03:26 +01:00
|
|
|
on_pull_item = function(pos, side)
|
|
|
|
return tubelib.get_item(M(pos), "main")
|
|
|
|
end,
|
2019-01-05 18:04:56 +01:00
|
|
|
on_unpull_item = function(pos, side, item)
|
2020-12-17 01:56:05 +01:00
|
|
|
local meta = M(pos)
|
2020-12-18 03:51:31 +01:00
|
|
|
local num = wh.inv_add_item(Box, meta, item)
|
2020-12-17 01:56:05 +01:00
|
|
|
if num > 0 then
|
|
|
|
-- this should never happen, but better safe than sorry
|
|
|
|
item:set_count(num)
|
|
|
|
return tubelib.put_item(meta, "shift", item)
|
|
|
|
end
|
|
|
|
return true
|
2019-01-05 18:04:56 +01:00
|
|
|
end,
|
|
|
|
|
|
|
|
on_recv_message = function(pos, topic, payload)
|
|
|
|
local resp = Box.State:on_receive_message(pos, topic, payload)
|
|
|
|
if resp then
|
|
|
|
return resp
|
2019-01-15 22:06:08 +01:00
|
|
|
elseif topic == "num_items" then
|
|
|
|
return wh.get_num_items(M(pos), payload)
|
2019-01-05 18:04:56 +01:00
|
|
|
else
|
|
|
|
return "unsupported"
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
on_node_load = function(pos)
|
|
|
|
Box.State:on_node_load(pos)
|
|
|
|
end,
|
|
|
|
on_node_repair = function(pos)
|
|
|
|
return Box.State:on_node_repair(pos)
|
|
|
|
end,
|
2022-06-09 23:49:50 +02:00
|
|
|
})
|
2019-01-05 18:04:56 +01:00
|
|
|
|
|
|
|
minetest.register_craft({
|
|
|
|
output = NODE_NAME,
|
|
|
|
recipe = {
|
|
|
|
{"default:gold_ingot", "tubelib:pusher", "default:gold_ingot"},
|
|
|
|
{"default:gold_ingot", "tubelib_addons1:chest", "default:gold_ingot"},
|
|
|
|
{"default:gold_ingot", "default:gold_ingot", "default:gold_ingot"},
|
|
|
|
}
|
|
|
|
})
|