forked from minetest-mods/more_chests
parent
9526aec1cd
commit
109e6b1fdc
|
@ -15,7 +15,7 @@ local function register_toolbox(description, material, side_tile, craft_item)
|
|||
})
|
||||
minetest.register_node("more_chests:toolbox_" .. material, def)
|
||||
minetest.register_craft({
|
||||
output = "morechests:toolbox_" .. material,
|
||||
output = "more_chests:toolbox_" .. material,
|
||||
recipe = {
|
||||
{craft_item, craft_item, craft_item},
|
||||
{craft_item, "group:pickaxe", craft_item},
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
local gen_def = dofile(minetest.get_modpath("more_chests") .. "/utils/base.lua")
|
||||
local S = minetest.get_translator("more_chests")
|
||||
local pipeworks_enabled = minetest.global_exists("pipeworks")
|
||||
|
||||
local wifi = gen_def({
|
||||
description = S("Wifi Chest"),
|
||||
|
@ -11,13 +12,51 @@ local wifi = gen_def({
|
|||
front = {name="wifi_front_animated.png", animation={type="vertical_frames",
|
||||
aspect_w=16, aspect_h=16, length=2.0}}
|
||||
},
|
||||
allow_metadata_inventory_move = false,
|
||||
allow_metadata_inventory_put = false,
|
||||
allow_metadata_inventory_take = false,
|
||||
inventory_name = "more_chests:wifi",
|
||||
pipeworks_enabled = pipeworks_enabled, -- this adds groups
|
||||
})
|
||||
|
||||
-- wifi chests can always be removed because content is detached
|
||||
wifi.can_dig = function(pos, player) return true end
|
||||
|
||||
-- pipeworks support (we need to override what is created by gen_def because too generic)
|
||||
wifi.tube = pipeworks_enabled and {
|
||||
insert_object = function(pos, node, stack, direction, owner)
|
||||
if not owner then
|
||||
return stack
|
||||
end
|
||||
local player = minetest.get_player_by_name(owner)
|
||||
if not player then
|
||||
return stack
|
||||
end
|
||||
local inv = player:get_inventory()
|
||||
return inv:add_item("more_chests:wifi", stack)
|
||||
end,
|
||||
can_insert = function(pos, node, stack, direction, owner)
|
||||
if not owner then
|
||||
return false
|
||||
end
|
||||
local player = minetest.get_player_by_name(owner)
|
||||
if not player then
|
||||
return false
|
||||
end
|
||||
local inv = player:get_inventory()
|
||||
return inv:room_for_item("more_chests:wifi", stack)
|
||||
end,
|
||||
input_inventory = "more_chests:wifi",
|
||||
return_input_invref = function(pos, node, direction, player_name)
|
||||
if not player_name then
|
||||
return false
|
||||
end
|
||||
local player = minetest.get_player_by_name(player_name)
|
||||
if not player then
|
||||
return false
|
||||
end
|
||||
return player:get_inventory()
|
||||
end,
|
||||
connect_sides = {left = 1, right = 1, back = 1, front = 1, bottom = 1, top = 1}
|
||||
} or nil
|
||||
|
||||
minetest.register_node("more_chests:wifi", wifi)
|
||||
minetest.register_craft({
|
||||
output = "more_chests:wifi",
|
||||
|
|
|
@ -41,13 +41,15 @@ function generate_chest_def(def)
|
|||
end,
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local formspec_str = def.formspec or generate_formspec_string(def.size)
|
||||
local formspec_str = def.formspec or generate_formspec_string(def.size, def.inventory_name or nil)
|
||||
meta:set_string("formspec", formspec_str)
|
||||
meta:set_string("infotext", def.description)
|
||||
meta:set_string("owner", "")
|
||||
local inv = meta:get_inventory()
|
||||
local chest_size = def.size == "big" and 14*5 or 8*4
|
||||
inv:set_size("main", chest_size)
|
||||
if def.inventory_name == nil or def.inventory_name == "main" then
|
||||
local inv = meta:get_inventory()
|
||||
local chest_size = def.size == "big" and 14*5 or 8*4
|
||||
inv:set_size("main", chest_size)
|
||||
end
|
||||
end,
|
||||
can_dig = function(pos,player)
|
||||
local meta = minetest.get_meta(pos)
|
||||
|
|
|
@ -1,5 +1,12 @@
|
|||
function generate(size)
|
||||
function generate(size, inventory_name)
|
||||
local cfg
|
||||
|
||||
-- chest inventory name
|
||||
local inv_name = inventory_name
|
||||
if inv_name == nil then
|
||||
inv_name = "main"
|
||||
end
|
||||
|
||||
if size == "small" then
|
||||
cfg = {
|
||||
window_width = 8,
|
||||
|
@ -23,7 +30,7 @@ function generate(size)
|
|||
default.gui_bg ..
|
||||
default.gui_bg_img ..
|
||||
default.gui_slots ..
|
||||
"list[current_name;main;0,0.3;" ..
|
||||
"list["..((inv_name == "main") and "current_name" or "current_player")..";"..inv_name..";0,0.3;" ..
|
||||
cfg.chest_width .. "," .. cfg.chest_height .. ";]" ..
|
||||
"list[current_player;main;" ..
|
||||
player_inv_x_orig .. "," .. player_inv_y_orig ..
|
||||
|
@ -31,7 +38,7 @@ function generate(size)
|
|||
"list[current_player;main;" ..
|
||||
player_inv_x_orig .. "," .. (player_inv_y_orig + 1.15) ..
|
||||
";8,3;8]" ..
|
||||
"listring[current_name;main]" ..
|
||||
"listring["..(inv_name == "main" and "current_name" or "current_player")..";"..inv_name.."]" ..
|
||||
"listring[current_player;main]" ..
|
||||
default.get_hotbar_bg(player_inv_x_orig, player_inv_y_orig)
|
||||
end
|
||||
|
|
97
wifi.lua
97
wifi.lua
|
@ -1,97 +0,0 @@
|
|||
-- Load support for translation.
|
||||
local S = minetest.get_translator("more_chests")
|
||||
|
||||
local pipeworks_enabled = minetest.global_exists("pipeworks")
|
||||
|
||||
minetest.register_node("more_chests:wifi", {
|
||||
description = S("Wifi Chest"),
|
||||
tiles = {"wifi_top.png", "wifi_top.png", "wifi_side.png",
|
||||
"wifi_side.png", "wifi_side.png",
|
||||
{name="wifi_front_animated.png", animation={type="vertical_frames",
|
||||
aspect_w=16, aspect_h=16, length=2.0}}},
|
||||
paramtype2 = "facedir",
|
||||
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, tubedevice = 1, tubedevice_receiver = 1},
|
||||
-- Pipeworks
|
||||
tube = pipeworks_enabled and {
|
||||
insert_object = function(pos, node, stack, direction, owner)
|
||||
if not owner then
|
||||
return stack
|
||||
end
|
||||
local player = minetest.get_player_by_name(owner)
|
||||
if not player then
|
||||
return stack
|
||||
end
|
||||
local inv = player:get_inventory()
|
||||
return inv:add_item("more_chests:wifi", stack)
|
||||
end,
|
||||
can_insert = function(pos, node, stack, direction, owner)
|
||||
if not owner then
|
||||
return false
|
||||
end
|
||||
local player = minetest.get_player_by_name(owner)
|
||||
if not player then
|
||||
return false
|
||||
end
|
||||
local inv = player:get_inventory()
|
||||
return inv:room_for_item("more_chests:wifi", stack)
|
||||
end,
|
||||
input_inventory = "more_chests:wifi",
|
||||
return_input_invref = function(pos, node, direction, player_name)
|
||||
if not player_name then
|
||||
return false
|
||||
end
|
||||
local player = minetest.get_player_by_name(player_name)
|
||||
if not player then
|
||||
return false
|
||||
end
|
||||
return player:get_inventory()
|
||||
end,
|
||||
connect_sides = {left = 1, right = 1, back = 1, front = 1, bottom = 1, top = 1}
|
||||
} or nil,
|
||||
after_place_node = pipeworks_enabled and pipeworks.after_place or nil,
|
||||
after_dig_node = pipeworks_enabled and pipeworks.after_dig or nil,
|
||||
legacy_facedir_simple = true,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("formspec",
|
||||
"size[8,9]"..
|
||||
default.gui_bg ..
|
||||
default.gui_bg_img ..
|
||||
default.gui_slots ..
|
||||
"list[current_player;more_chests:wifi;0,0.3;8,4;]"..
|
||||
"list[current_player;main;0,4.85;8,1;]" ..
|
||||
"list[current_player;main;0,6.08;8,3;8]" ..
|
||||
"listring[current_player;more_chests:wifi]" ..
|
||||
"listring[current_player;main]" ..
|
||||
default.get_hotbar_bg(0,4.85))
|
||||
|
||||
meta:set_string("infotext", S("Wifi Chest"))
|
||||
end,
|
||||
on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
|
||||
minetest.log("action", player:get_player_name()..
|
||||
" moves stuff in wifi chest at "..minetest.pos_to_string(pos))
|
||||
end,
|
||||
on_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||
minetest.log("action", player:get_player_name()..
|
||||
" moves stuff to wifi chest at "..minetest.pos_to_string(pos))
|
||||
end,
|
||||
on_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||
minetest.log("action", player:get_player_name()..
|
||||
" takes stuff from wifi chest at "..minetest.pos_to_string(pos))
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'more_chests:wifi',
|
||||
recipe = {
|
||||
{'default:wood','default:mese','default:wood'},
|
||||
{'default:wood','default:steel_ingot','default:wood'},
|
||||
{'default:wood','default:wood','default:wood'}
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
local inv = player:get_inventory()
|
||||
inv:set_size("more_chests:wifi", 8*4)
|
||||
end)
|
Loading…
Reference in New Issue
Block a user