Revert "Mod rewrite and new models (#21)"
This reverts commit 74b3c5a25d
.
102
README.md
|
@ -1,85 +1,47 @@
|
||||||
<style>
|
more_chests
|
||||||
th { display: none; }
|
===========
|
||||||
td { text-align: center; }
|
|
||||||
</style>
|
|
||||||
|
|
||||||
# more_chests
|
More Chests
|
||||||
Originally a fork of 0gb.us's chests_0gb_us (https://forum.minetest.net/viewtopic.php?f=11&t=4366).
|
|
||||||
Megaf's more_chests fixes several bugs, uses new textures and adds compatibility with [VanessaE's Pipeworks] (https://github.com/VanessaE/pipeworks) mod.
|
|
||||||
nxet's rework introduces a new backend which allows for easier extension of the available models, including two new models showcasing the feature.
|
|
||||||
|
|
||||||
|
This mod is a fork of 0gb.us's chests_0gb_us https://forum.minetest.net/viewtopic.php?f=11&t=4366
|
||||||
|
|
||||||
### Available models
|
Megaf's more_chests fixes several bugs, uses new textures and adds compatibility with [VanessaE's Pipeworks] (https://github.com/VanessaE/pipeworks) mod.
|
||||||
> NOTE: descriptions of the original models come from 0gb.us initial effort
|
|
||||||
|
|
||||||
#### Cobble Chest
|
The following text was writen by 0gb.us
|
||||||
This locked chest looks like cobblestone, and has no info text. Great for hiding things in. However, unlike real cobblestone, this chest is breakable by hand. If you suspect there is one hiding, hold the left mouse button and run your hand along the walls. When cracks appear, you've found the chest.
|
```
|
||||||
1 | 2 | 3
|
Cobble Chest:
|
||||||
---|---|---
|
{'default:wood','default:cobble','default:wood'},
|
||||||
default:wood | default:cobble | default:wood
|
{'default:cobble','default:steel_ingot','default:cobble'},
|
||||||
default:cobble | default:steel_ingot | default:cobble
|
{'default:wood','default:cobble','default:wood'}
|
||||||
default:wood | default:cobble | default:wood
|
|
||||||
|
|
||||||
|
This locked chest looks like cobblestone, and has no info text. Great for hiding things in. However, unlike real cobblestone, this chest is breakable by hand. If you suspect there is one hiding, Hold the left mouse button, ant run your hand along the walls. When cracks appear, you've found the chest.
|
||||||
|
|
||||||
|
Drop Box:
|
||||||
|
{'default:wood','','default:wood'},
|
||||||
|
{'default:wood','default:steel_ingot','default:wood'},
|
||||||
|
{'default:wood','default:wood','default:wood'}
|
||||||
|
|
||||||
#### Drop Box
|
|
||||||
Anyone can put things in, but only the chest's placer can remove items.
|
Anyone can put things in, but only the chest's placer can remove items.
|
||||||
1 | 2 | 3
|
|
||||||
---|---|---
|
|
||||||
default:wood | _empty_ | default:wood
|
|
||||||
default:wood | default:steel_ingot | default:wood
|
|
||||||
default:wood | default:wood | default:wood
|
|
||||||
|
|
||||||
|
Secret Chest:
|
||||||
|
{'default:wood','default:cobble','default:wood'},
|
||||||
|
{'default:wood','default:steel_ingot','default:wood'},
|
||||||
|
{'default:wood','default:wood','default:wood'}
|
||||||
|
|
||||||
#### Secret Chest
|
As long as you remember to click “close” before you leave the chest, no one can see what the chest contains. Only the chest's owner can click “open” and “close” on the chest's formspec, revealing and hiding the chest's contents.
|
||||||
As long as you remember to click "close" before you leave the chest, no one can see what the chest contains. Only the chest's owner can click "open" and "close" on the chest's formspec, revealing and hiding the chest's contents.
|
|
||||||
1 | 2 | 3
|
|
||||||
---|---|---
|
|
||||||
default:wood | default:cobble | default:wood
|
|
||||||
default:wood | default:steel_ingot | default:wood
|
|
||||||
default:wood | default:wood | default:wood
|
|
||||||
|
|
||||||
|
Shared Chest:
|
||||||
|
{'default:wood','default:leaves','default:wood'},
|
||||||
|
{'default:wood','default:steel_ingot','default:wood'},
|
||||||
|
{'default:wood','default:wood','default:wood'}
|
||||||
|
|
||||||
#### Shared Chest
|
|
||||||
Exactly what it sounds like. The chest's placer can add people to the chest's shared list using the chest's formspec. Warning: anyone you add may empty the chest. When the chest is empty, it can be mined by anyone, just like a regular locked chest.
|
Exactly what it sounds like. The chest's placer can add people to the chest's shared list using the chest's formspec. Warning: anyone you add may empty the chest. When the chest is empty, it can be mined by anyone, just like a regular locked chest.
|
||||||
1 | 2 | 3
|
|
||||||
---|---|---
|
|
||||||
default:wood | default:leaves | default:wood
|
|
||||||
default:wood | default:steel_ingot | default:wood
|
|
||||||
default:wood | default:wood | default:wood
|
|
||||||
|
|
||||||
|
Wifi Chest
|
||||||
|
|
||||||
|
{'default:wood','default:mese','default:wood'},
|
||||||
|
{'default:wood','default:steel_ingot','default:wood'},
|
||||||
|
{'default:wood','default:wood','default:wood'}
|
||||||
|
|
||||||
#### Wifi Chest
|
|
||||||
A wacky chest that doesn't store it's items in the usual way, but instead, stores them remotely. For that reason, all wifi chests appear to have the same inventory. Due to not actually having an inventory, wifi chests can also be mined, even when they appear to have stuff in them. Lastly, as everyone gets their own wifi account, the items you see in the wifi chest are not the same items anyone else sees. This chest's properties make it nice for keeping secrets, as well as essentially almost doubling your inventory space, if you choose to carry one with you.
|
A wacky chest that doesn't store it's items in the usual way, but instead, stores them remotely. For that reason, all wifi chests appear to have the same inventory. Due to not actually having an inventory, wifi chests can also be mined, even when they appear to have stuff in them. Lastly, as everyone gets their own wifi account, the items you see in the wifi chest are not the same items anyone else sees. This chest's properties make it nice for keeping secrets, as well as essentially almost doubling your inventory space, if you choose to carry one with you.
|
||||||
1 | 2 | 3
|
```
|
||||||
---|---|---
|
|
||||||
default:wood | default:mese | default:wood
|
|
||||||
default:wood | default:steel_ingot | default:wood
|
|
||||||
default:wood | default:wood | default:wood
|
|
||||||
|
|
||||||
|
|
||||||
#### Fridge
|
|
||||||
A new model which comes in two forms, 1- and 2-block tall, which indeed have different sizes inventories. No fancy functionality here, I just wanted to know at a glance which one is the chest I'm storing food into.
|
|
||||||
|
|
||||||
###### Fridge Recipe
|
|
||||||
1 | 2 | 3
|
|
||||||
---|---|---
|
|
||||||
_empty_ | default:steel_ingot | _empty_
|
|
||||||
default:steel_ingot | default:ice | default:steel_ingot
|
|
||||||
_empty_ | default:steel_ingot | _empty_
|
|
||||||
|
|
||||||
###### Big Fridge Recipe
|
|
||||||
1 | 2 | 3
|
|
||||||
---|---|---
|
|
||||||
default:steel_ingot | default:steel_ingot | default:steel_ingot
|
|
||||||
default:steel_ingot | default:ice | default:steel_ingot
|
|
||||||
default:steel_ingot | default:steel_ingot | default:steel_ingot
|
|
||||||
|
|
||||||
|
|
||||||
#### Toolbox
|
|
||||||
This model has no particular functionality to offer other than giving your tools' chest a new look. As a bonus you can also craft the chest with different types of wood, which will give you different results. For the fanciest garage workshop you ever built on Minetest.
|
|
||||||
1 | 2 | 3
|
|
||||||
---|---|---
|
|
||||||
default:wood | default:wood | default:wood
|
|
||||||
default:wood | default:pickaxe | default:wood
|
|
||||||
default:wood | default:wood | default:wood
|
|
||||||
> Note: crafting also accepts Aspen, Acacia, Junglewood, Pine and Steel instead of wood
|
|
||||||
|
|
115
cobble.lua
Normal file
|
@ -0,0 +1,115 @@
|
||||||
|
-- Load support for translation.
|
||||||
|
local S = minetest.get_translator("more_chests")
|
||||||
|
|
||||||
|
local function has_locked_chest_privilege(meta, player)
|
||||||
|
if player:get_player_name() ~= meta:get_string("owner") then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.register_node("more_chests:cobble", {
|
||||||
|
description = S("Cobble Chest"),
|
||||||
|
tiles = {"default_cobble.png", "default_cobble.png", "default_cobble.png",
|
||||||
|
"default_cobble.png", "default_cobble.png", "cobblechest_front.png"},
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, tubedevice = 1, tubedevice_receiver = 1},
|
||||||
|
-- First attempt to add a way to connect to pipeworks.
|
||||||
|
tube = {
|
||||||
|
insert_object = function(pos, node, stack, direction)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
return inv:add_item("main", stack)
|
||||||
|
end,
|
||||||
|
can_insert = function(pos, node, stack, direction)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
return inv:room_for_item("main", stack)
|
||||||
|
end,
|
||||||
|
input_inventory = "main",
|
||||||
|
connect_sides = {left = 1, right = 1, back = 1, front = 1, bottom = 1, top = 1}
|
||||||
|
},
|
||||||
|
legacy_facedir_simple = true,
|
||||||
|
sounds = default.node_sound_wood_defaults(),
|
||||||
|
after_place_node = function(pos, placer)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
meta:set_string("owner", placer:get_player_name() or "")
|
||||||
|
|
||||||
|
end,
|
||||||
|
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_name;main;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_name;main]"..
|
||||||
|
"listring[current_player;main]" ..
|
||||||
|
default.get_hotbar_bg(0,4.85))
|
||||||
|
meta:set_string("owner", "")
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
inv:set_size("main", 8*4)
|
||||||
|
end,
|
||||||
|
can_dig = function(pos,player)
|
||||||
|
local meta = minetest.get_meta(pos);
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
return inv:is_empty("main")
|
||||||
|
end,
|
||||||
|
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
if not has_locked_chest_privilege(meta, player) then
|
||||||
|
minetest.log("action", player:get_player_name()..
|
||||||
|
" tried to access a locked chest belonging to "..
|
||||||
|
meta:get_string("owner").." at "..
|
||||||
|
minetest.pos_to_string(pos))
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
return count
|
||||||
|
end,
|
||||||
|
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
if not has_locked_chest_privilege(meta, player) then
|
||||||
|
minetest.log("action", player:get_player_name()..
|
||||||
|
" tried to access a locked chest belonging to "..
|
||||||
|
meta:get_string("owner").." at "..
|
||||||
|
minetest.pos_to_string(pos))
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
return stack:get_count()
|
||||||
|
end,
|
||||||
|
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
if not has_locked_chest_privilege(meta, player) then
|
||||||
|
minetest.log("action", player:get_player_name()..
|
||||||
|
" tried to access a locked chest belonging to "..
|
||||||
|
meta:get_string("owner").." at "..
|
||||||
|
minetest.pos_to_string(pos))
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
return stack:get_count()
|
||||||
|
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 locked 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 locked 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 locked chest at "..minetest.pos_to_string(pos))
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_craft({
|
||||||
|
output = 'more_chests:cobble',
|
||||||
|
recipe = {
|
||||||
|
{'default:wood','default:cobble','default:wood'},
|
||||||
|
{'default:cobble','default:steel_ingot','default:cobble'},
|
||||||
|
{'default:wood','default:cobble','default:wood'}
|
||||||
|
}
|
||||||
|
})
|
113
dropbox.lua
Normal file
|
@ -0,0 +1,113 @@
|
||||||
|
-- Load support for translation.
|
||||||
|
local S = minetest.get_translator("more_chests")
|
||||||
|
local DS = minetest.get_translator("default")
|
||||||
|
|
||||||
|
local function has_locked_chest_privilege(meta, player)
|
||||||
|
if player:get_player_name() ~= meta:get_string("owner") then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.register_node("more_chests:dropbox", {
|
||||||
|
description = S("Dropbox"),
|
||||||
|
tiles = {"dropbox_top.png", "dropbox_top.png", "dropbox_side.png",
|
||||||
|
"dropbox_side.png", "dropbox_side.png", "dropbox_front.png"},
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, tubedevice = 1, tubedevice_receiver = 1},
|
||||||
|
-- Pipeworks
|
||||||
|
tube = {
|
||||||
|
insert_object = function(pos, node, stack, direction)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
return inv:add_item("main", stack)
|
||||||
|
end,
|
||||||
|
can_insert = function(pos, node, stack, direction)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
return inv:room_for_item("main", stack)
|
||||||
|
end,
|
||||||
|
input_inventory = "main",
|
||||||
|
connect_sides = {left = 1, right = 1, back = 1, front = 1, bottom = 1, top = 1}
|
||||||
|
},
|
||||||
|
legacy_facedir_simple = true,
|
||||||
|
sounds = default.node_sound_wood_defaults(),
|
||||||
|
after_place_node = function(pos, placer)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
meta:set_string("owner", placer:get_player_name() or "")
|
||||||
|
meta:set_string("infotext", S("@1 (owned by @2)",
|
||||||
|
S("Dropbox"),
|
||||||
|
meta:get_string("owner")))
|
||||||
|
end,
|
||||||
|
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_name;main;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_name;main]" ..
|
||||||
|
"listring[current_player;main]" ..
|
||||||
|
default.get_hotbar_bg(0,4.85))
|
||||||
|
meta:set_string("infotext", DS("Chest"))
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
inv:set_size("main", 8*4)
|
||||||
|
end,
|
||||||
|
can_dig = function(pos,player)
|
||||||
|
local meta = minetest.get_meta(pos);
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
return inv:is_empty("main")
|
||||||
|
end,
|
||||||
|
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
if not has_locked_chest_privilege(meta, player) then
|
||||||
|
minetest.log("action", player:get_player_name()..
|
||||||
|
" tried to access a dropbox belonging to "..
|
||||||
|
meta:get_string("owner").." at "..
|
||||||
|
minetest.pos_to_string(pos))
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
return stack:get_count()
|
||||||
|
end,
|
||||||
|
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
if has_locked_chest_privilege(meta, player) then
|
||||||
|
return stack:get_count()
|
||||||
|
end
|
||||||
|
local target = meta:get_inventory():get_list(listname)[index]
|
||||||
|
local target_name = target:get_name()
|
||||||
|
local stack_count = stack:get_count()
|
||||||
|
if target_name == stack:get_name()
|
||||||
|
and target:get_count() < stack_count then
|
||||||
|
return stack_count
|
||||||
|
end
|
||||||
|
if target_name ~= "" then
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
return stack_count
|
||||||
|
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 dropbox 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 dropbox 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 dropbox at "..minetest.pos_to_string(pos))
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_craft({
|
||||||
|
output = 'more_chests:dropbox',
|
||||||
|
recipe = {
|
||||||
|
{'default:wood','','default:wood'},
|
||||||
|
{'default:wood','default:steel_ingot','default:wood'},
|
||||||
|
{'default:wood','default:wood','default:wood'}
|
||||||
|
}
|
||||||
|
})
|
16
init.lua
|
@ -1,11 +1,7 @@
|
||||||
dofile(minetest.get_modpath("more_chests").."/models/cobble.lua")
|
dofile(minetest.get_modpath("more_chests").."/cobble.lua")
|
||||||
dofile(minetest.get_modpath("more_chests").."/models/dropbox.lua")
|
dofile(minetest.get_modpath("more_chests").."/dropbox.lua")
|
||||||
dofile(minetest.get_modpath("more_chests").."/models/fridge.lua")
|
dofile(minetest.get_modpath("more_chests").."/secret.lua")
|
||||||
dofile(minetest.get_modpath("more_chests").."/models/secret.lua")
|
dofile(minetest.get_modpath("more_chests").."/shared.lua")
|
||||||
dofile(minetest.get_modpath("more_chests").."/models/shared.lua")
|
dofile(minetest.get_modpath("more_chests").."/wifi.lua")
|
||||||
dofile(minetest.get_modpath("more_chests").."/models/toolbox.lua")
|
dofile(minetest.get_modpath("more_chests").."/aliases.lua")
|
||||||
dofile(minetest.get_modpath("more_chests").."/models/wifi.lua")
|
|
||||||
|
|
||||||
dofile(minetest.get_modpath("more_chests").."/utils/aliases.lua")
|
|
||||||
|
|
||||||
print ("[MOD] more_chests loaded")
|
|
||||||
|
|
|
@ -1,17 +1,11 @@
|
||||||
# textdomain: more_chests
|
# textdomain: more_chests
|
||||||
Cobble Chest=Coffre en pierre taillée
|
Cobble Chest=Coffre en pierre taillée
|
||||||
Dropbox=Boîte de dépôt
|
Dropbox=Boîte de dépôt
|
||||||
Fridge=Réfrigérateur
|
|
||||||
Big Fridge=Grand réfrigérateur
|
|
||||||
Secret Chest=Coffre secret
|
Secret Chest=Coffre secret
|
||||||
Shared Chest=Coffre partagé
|
Shared Chest=Coffre partagé
|
||||||
Wifi Chest=Coffre wifi
|
Wifi Chest=Coffre wifi
|
||||||
Wooden Toolbox=Boîte à outils en bois
|
|
||||||
Aspen Wood Toolbox=Boîte à outils en bois de tremble
|
|
||||||
Acacia Wood Toolbox=Boîte à outils en bois d’acacia
|
|
||||||
Junglewood Toolbox=Boîte à outils en bois de la jungle
|
|
||||||
Pine Wood Toolbox=Boîte à outils en bois de pin
|
|
||||||
Steel Toolbox=Boîte à outils en acier
|
|
||||||
@1 (owned by @2)=@1 (appartient à @2)
|
@1 (owned by @2)=@1 (appartient à @2)
|
||||||
Shared with (separate names with spaces)=Partagé avec (séparez les noms avec des espaces)
|
Shared with (separate names with spaces)=Partagé avec (séparez les noms avec des espaces)
|
||||||
submit=valider
|
submit=valider
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
# textdomain: more_chests
|
|
||||||
Cobble Chest=Baule in ciottoli
|
|
||||||
Dropbox=Baule Donazioni
|
|
||||||
Fridge=Frigorifero
|
|
||||||
Big Fridge=Frigorifero Grande
|
|
||||||
Secret Chest=Baule Segreto
|
|
||||||
Shared Chest=Baule Condiviso
|
|
||||||
Wifi Chest=Baule WiFi
|
|
||||||
Wooden Toolbox=Scatola degli attrezzi in legno
|
|
||||||
Aspen Wood Toolbox=Scatola degli attrezzi in legno di pioppo
|
|
||||||
Acacia Wood Toolbox=Scatola degli attrezzi in legno di acacia
|
|
||||||
Junglewood Toolbox=Scatola degli attrezzi in legno di jungla
|
|
||||||
Pine Wood Toolbox=Scatola degli attrezzi in legno di pino
|
|
||||||
Steel Toolbox=Scatola degli attrezzi in acciaio
|
|
||||||
@1 (owned by @2)=@1 (di proprietà di @2)
|
|
||||||
Shared with (separate names with spaces)=Condiviso con (separa i nomi con degli spazi)
|
|
||||||
submit=invia
|
|
|
@ -1,17 +1,6 @@
|
||||||
# textdomain: more_chests
|
# textdomain: more_chests
|
||||||
Cobble Chest=
|
|
||||||
Dropbox=
|
|
||||||
Fridge=
|
|
||||||
Big Fridge=
|
|
||||||
Secret Chest=
|
Secret Chest=
|
||||||
Shared Chest=
|
|
||||||
Wifi Chest=
|
Wifi Chest=
|
||||||
Wooden Toolbox=
|
Cobble Chest=
|
||||||
Aspen Wood Toolbox=
|
Shared Chest=
|
||||||
Acacia Wood Toolbox=
|
Dropbox=
|
||||||
Junglewood Toolbox=
|
|
||||||
Pine Wood Toolbox=
|
|
||||||
Steel Toolbox=
|
|
||||||
@1 (owned by @2)=
|
|
||||||
Shared with (separate names with spaces)=
|
|
||||||
submit=
|
|
||||||
|
|
|
@ -1,26 +0,0 @@
|
||||||
local gen_def = dofile(minetest.get_modpath("more_chests") .. "/utils/base.lua")
|
|
||||||
local S = minetest.get_translator("more_chests")
|
|
||||||
|
|
||||||
local cobble = gen_def({
|
|
||||||
description = S("Cobble Chest"),
|
|
||||||
type = "chest",
|
|
||||||
size = "small",
|
|
||||||
tiles = {
|
|
||||||
top = "default_cobble.png",
|
|
||||||
side = "default_cobble.png",
|
|
||||||
front = "cobblechest_front.png"
|
|
||||||
},
|
|
||||||
pipeworks_enabled = true,
|
|
||||||
recipe = {
|
|
||||||
{"group:wood", "default:cobble", "group:wood"},
|
|
||||||
{"default:cobble", "default:steel_ingot", "default:cobble"},
|
|
||||||
{"group:wood", "default:cobble", "group:wood"}
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
minetest.register_node("more_chests:cobble", cobble)
|
|
||||||
minetest.register_craft({
|
|
||||||
output = "more_chests:cobble",
|
|
||||||
recipe = cobble.recipe,
|
|
||||||
})
|
|
|
@ -1,45 +0,0 @@
|
||||||
local gen_def = dofile(minetest.get_modpath("more_chests") .. "/utils/base.lua")
|
|
||||||
local actions = dofile(minetest.get_modpath("more_chests") .. "/utils/actions.lua")
|
|
||||||
local S = minetest.get_translator("more_chests")
|
|
||||||
|
|
||||||
local dropbox = gen_def({
|
|
||||||
description = S("Dropbox"),
|
|
||||||
type = "dropbox",
|
|
||||||
size = "small",
|
|
||||||
tiles = {
|
|
||||||
top = "dropbox_top.png",
|
|
||||||
side = "dropbox_side.png",
|
|
||||||
front = "dropbox_front.png"
|
|
||||||
},
|
|
||||||
pipeworks_enabled = true,
|
|
||||||
recipe = {
|
|
||||||
{"group:wood", "", "group:wood"},
|
|
||||||
{"group:wood", "default:steel_ingot", "group:wood"},
|
|
||||||
{"group:wood", "group:wood", "group:wood"}
|
|
||||||
},
|
|
||||||
allow_metadata_inventory_move = false,
|
|
||||||
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
|
||||||
local meta = minetest.get_meta(pos)
|
|
||||||
if actions.has_locked_chest_privilege(meta, player) then
|
|
||||||
return stack:get_count()
|
|
||||||
end
|
|
||||||
local target = meta:get_inventory():get_list(listname)[index]
|
|
||||||
local target_name = target:get_name()
|
|
||||||
local stack_count = stack:get_count()
|
|
||||||
if target_name == stack:get_name()
|
|
||||||
and target:get_count() < stack_count then
|
|
||||||
return stack_count
|
|
||||||
end
|
|
||||||
if target_name ~= "" then
|
|
||||||
return 0
|
|
||||||
end
|
|
||||||
return stack_count
|
|
||||||
end
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
minetest.register_node("more_chests:dropbox", dropbox)
|
|
||||||
minetest.register_craft({
|
|
||||||
output = "more_chests:dropbox",
|
|
||||||
recipe = dropbox.recipe,
|
|
||||||
})
|
|
|
@ -1,50 +0,0 @@
|
||||||
local gen_def = dofile(minetest.get_modpath("more_chests") .. "/utils/base.lua")
|
|
||||||
local S = minetest.get_translator("more_chests")
|
|
||||||
|
|
||||||
-- TODO model open
|
|
||||||
|
|
||||||
local fridge = gen_def({
|
|
||||||
description = S("Fridge"),
|
|
||||||
type = "fridge",
|
|
||||||
size = "small",
|
|
||||||
tiles = {
|
|
||||||
side = "fridge_side.png",
|
|
||||||
front = "fridge_front.png",
|
|
||||||
},
|
|
||||||
recipe = {
|
|
||||||
{"", "default:steel_ingot", ""},
|
|
||||||
{"default:steel_ingot", "default:ice", "default:steel_ingot"},
|
|
||||||
{"", "default:steel_ingot", ""}
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_node("more_chests:fridge", fridge)
|
|
||||||
minetest.register_craft({
|
|
||||||
output = "more_chests:fridge",
|
|
||||||
recipe = fridge.recipe,
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
local big_fridge = gen_def({
|
|
||||||
description = S("Big Fridge"),
|
|
||||||
type = "fridge",
|
|
||||||
size = "big",
|
|
||||||
node_box = {
|
|
||||||
{-0.5, -0.5, -0.5, 0.5, 1.5, 0.5},
|
|
||||||
},
|
|
||||||
tiles = {
|
|
||||||
side = "fridge_side.png",
|
|
||||||
front = "fridge_front.png",
|
|
||||||
},
|
|
||||||
recipe = {
|
|
||||||
{"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"},
|
|
||||||
{"default:steel_ingot", "default:ice", "default:steel_ingot"},
|
|
||||||
{"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"}
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_node("more_chests:big_fridge", big_fridge)
|
|
||||||
minetest.register_craft({
|
|
||||||
output = "more_chests:big_fridge",
|
|
||||||
recipe = big_fridge.recipe,
|
|
||||||
})
|
|
|
@ -1,54 +0,0 @@
|
||||||
local gen_def = dofile(minetest.get_modpath("more_chests") .. "/utils/base.lua")
|
|
||||||
local actions = dofile(minetest.get_modpath("more_chests") .. "/utils/actions.lua")
|
|
||||||
local S = minetest.get_translator("more_chests")
|
|
||||||
|
|
||||||
local open = "size[8,10]"..
|
|
||||||
default.gui_bg ..
|
|
||||||
default.gui_bg_img ..
|
|
||||||
default.gui_slots ..
|
|
||||||
"list[current_name;main;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_name;main]" ..
|
|
||||||
"listring[current_player;main]" ..
|
|
||||||
"button[3,9;2,1;open;close]" ..
|
|
||||||
default.get_hotbar_bg(0,4.85)
|
|
||||||
|
|
||||||
local closed = "size[2,1]" ..
|
|
||||||
"button[0,0;2,1;open;open]"
|
|
||||||
|
|
||||||
local secret = gen_def({
|
|
||||||
description = S("Secret Chest"),
|
|
||||||
type = "secret chest",
|
|
||||||
size = "small",
|
|
||||||
tiles = {
|
|
||||||
top = "secret_top.png",
|
|
||||||
side = "secret_side.png",
|
|
||||||
front = "secret_front.png"
|
|
||||||
},
|
|
||||||
formspec = open,
|
|
||||||
pipeworks_enabled = true,
|
|
||||||
recipe = {
|
|
||||||
{"group:wood", "default:cobble", "group:wood"},
|
|
||||||
{"group:wood", "default:steel_ingot", "group:wood"},
|
|
||||||
{"group:wood", "group:wood", "group:wood"}
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
secret.on_receive_fields = function(pos, formname, fields, sender)
|
|
||||||
local meta = minetest.get_meta(pos)
|
|
||||||
if actions.has_locked_chest_privilege(meta, sender) then
|
|
||||||
if fields.open == "open" then
|
|
||||||
meta:set_string("formspec", open)
|
|
||||||
else
|
|
||||||
meta:set_string("formspec", closed)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
minetest.register_node("more_chests:secret", secret)
|
|
||||||
minetest.register_craft({
|
|
||||||
output = "more_chests:secret",
|
|
||||||
recipe = secret.recipe,
|
|
||||||
})
|
|
|
@ -1,72 +0,0 @@
|
||||||
local gen_def = dofile(minetest.get_modpath("more_chests") .. "/utils/base.lua")
|
|
||||||
local actions = dofile(minetest.get_modpath("more_chests") .. "/utils/actions.lua")
|
|
||||||
local S = minetest.get_translator("more_chests")
|
|
||||||
|
|
||||||
local function get_formspec(string)
|
|
||||||
return "size[8,10]" ..
|
|
||||||
default.gui_bg ..
|
|
||||||
default.gui_bg_img ..
|
|
||||||
default.gui_slots ..
|
|
||||||
"list[current_name;main;0,0.3;8,4;]" ..
|
|
||||||
"list[current_player;main;0,4.85;8,1;]" ..
|
|
||||||
"list[current_player;main;0,6;8,3;8]" ..
|
|
||||||
"field[.25,9.5;8,1;shared;" ..
|
|
||||||
S("Shared with (separate names with spaces)") ..
|
|
||||||
":;" .. string .. "]" ..
|
|
||||||
"button[6,9.2;2,1;submit;" ..
|
|
||||||
S("submit") .. "]" ..
|
|
||||||
"listring[current_name;main]" ..
|
|
||||||
"listring[current_player;main]" ..
|
|
||||||
default.get_hotbar_bg(0,4.85)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function check_privs(meta, player)
|
|
||||||
local name = player:get_player_name()
|
|
||||||
local shared = " " .. meta:get_string("shared") .. " "
|
|
||||||
if name == meta:get_string("owner") then
|
|
||||||
return true
|
|
||||||
elseif shared:find(" " .. name .. " ") then
|
|
||||||
return true
|
|
||||||
else
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local shared = gen_def({
|
|
||||||
description = S("Shared Chest"),
|
|
||||||
type = "shared chest",
|
|
||||||
size = "small",
|
|
||||||
tiles = {
|
|
||||||
top = "shared_top.png",
|
|
||||||
side = "shared_side.png",
|
|
||||||
front = "shared_front.png"
|
|
||||||
},
|
|
||||||
formspec = get_formspec(""),
|
|
||||||
pipeworks_enabled = true,
|
|
||||||
sounds = default.node_sound_wood_defaults(),
|
|
||||||
recipe = {
|
|
||||||
{"group:wood", "default:leaves", "group:wood"},
|
|
||||||
{"group:wood", "default:steel_ingot", "group:wood"},
|
|
||||||
{"group:wood", "group:wood", "group:wood"}
|
|
||||||
},
|
|
||||||
allow_metadata_inventory_move = actions.get_allow_metadata_inventory_move{"shared chest", check_privs=check_privs},
|
|
||||||
allow_metadata_inventory_put = actions.get_allow_metadata_inventory_put{"shared chest", check_privs=check_privs},
|
|
||||||
allow_metadata_inventory_take = actions.get_allow_metadata_inventory_take{"shared chest", check_privs=check_privs},
|
|
||||||
})
|
|
||||||
|
|
||||||
shared.on_receive_fields = function(pos, formspec, fields, sender)
|
|
||||||
local meta = minetest.get_meta(pos);
|
|
||||||
if fields.shared then
|
|
||||||
if meta:get_string("owner") == sender:get_player_name() then
|
|
||||||
meta:set_string("shared", fields.shared)
|
|
||||||
meta:set_string("formspec", get_formspec(fields.shared))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
minetest.register_node("more_chests:shared", shared)
|
|
||||||
minetest.register_craft({
|
|
||||||
output = "more_chests:shared",
|
|
||||||
recipe = shared.recipe,
|
|
||||||
})
|
|
|
@ -1,34 +0,0 @@
|
||||||
local gen_def = dofile(minetest.get_modpath("more_chests") .. "/utils/base.lua")
|
|
||||||
local S = minetest.get_translator("more_chests")
|
|
||||||
|
|
||||||
local function register_toolbox(description, type, side_tile, recipe)
|
|
||||||
local def = gen_def({
|
|
||||||
description = description,
|
|
||||||
type = "toolbox",
|
|
||||||
size = "big",
|
|
||||||
-- node_box = {-0.5, -0.5, -0.5, 1.5, 0.5, 0.5}, -- makes it two blocks wide
|
|
||||||
tiles = {
|
|
||||||
side = side_tile,
|
|
||||||
front = "toolbox_" .. type .. "_front.png",
|
|
||||||
top = "toolbox_" .. type .. "_top.png",
|
|
||||||
},
|
|
||||||
recipe = recipe,
|
|
||||||
})
|
|
||||||
minetest.register_node("more_chests:toolbox_" .. type, def)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function gen_recipe(craft_item)
|
|
||||||
return {
|
|
||||||
{craft_item, craft_item, craft_item},
|
|
||||||
{craft_item, "group:pickaxe", craft_item},
|
|
||||||
{craft_item, craft_item, craft_item}
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
register_toolbox(S("Wooden Toolbox"), "wood", "default_wood.png", gen_recipe("default:wood"))
|
|
||||||
register_toolbox(S("Aspen Wood Toolbox"), "aspen", "default_aspen_wood.png", gen_recipe("default:aspen_wood"))
|
|
||||||
register_toolbox(S("Acacia Wood Toolbox"), "acacia", "default_acacia_wood.png", gen_recipe("default:acacia_wood"))
|
|
||||||
register_toolbox(S("Junglewood Toolbox"), "jungle", "default_junglewood.png", gen_recipe("default:junglewood"))
|
|
||||||
register_toolbox(S("Pine Wood Toolbox"), "pine", "default_pine_wood.png", gen_recipe("default:pine_wood"))
|
|
||||||
|
|
||||||
register_toolbox(S("Steel Toolbox"), "steel", "default_steel_block.png", gen_recipe("default:steel_ingot"))
|
|
|
@ -1,34 +0,0 @@
|
||||||
local gen_def = dofile(minetest.get_modpath("more_chests") .. "/utils/base.lua")
|
|
||||||
local S = minetest.get_translator("more_chests")
|
|
||||||
|
|
||||||
local wifi = gen_def({
|
|
||||||
description = S("Wifi Chest"),
|
|
||||||
type = "wifi chest",
|
|
||||||
size = "small",
|
|
||||||
tiles = {
|
|
||||||
top = "wifi_top.png",
|
|
||||||
side = "wifi_side.png",
|
|
||||||
front = "wifi_front.png"
|
|
||||||
},
|
|
||||||
recipe = {
|
|
||||||
{"group:wood", "default:mese", "group:wood"},
|
|
||||||
{"group:wood", "default:steel_ingot", "group:wood"},
|
|
||||||
{"group:wood", "group:wood", "group:wood"}
|
|
||||||
},
|
|
||||||
allow_metadata_inventory_move = false,
|
|
||||||
allow_metadata_inventory_put = false,
|
|
||||||
allow_metadata_inventory_take = false,
|
|
||||||
})
|
|
||||||
|
|
||||||
wifi.can_dig = function(pos, player) return true end
|
|
||||||
|
|
||||||
minetest.register_node("more_chests:wifi", wifi)
|
|
||||||
minetest.register_craft({
|
|
||||||
output = "more_chests:wifi",
|
|
||||||
recipe = wifi.recipe,
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_on_joinplayer(function(player)
|
|
||||||
local inv = player:get_inventory()
|
|
||||||
inv:set_size("more_chests:wifi", 8*4)
|
|
||||||
end)
|
|
132
secret.lua
Normal file
|
@ -0,0 +1,132 @@
|
||||||
|
-- Load support for translation.
|
||||||
|
local S = minetest.get_translator("more_chests")
|
||||||
|
|
||||||
|
local function has_locked_chest_privilege(meta, player)
|
||||||
|
if player:get_player_name() ~= meta:get_string("owner") then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
local open = "size[8,10]"..
|
||||||
|
default.gui_bg ..
|
||||||
|
default.gui_bg_img ..
|
||||||
|
default.gui_slots ..
|
||||||
|
"list[current_name;main;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_name;main]" ..
|
||||||
|
"listring[current_player;main]" ..
|
||||||
|
"button[3,9;2,1;open;close]" ..
|
||||||
|
default.get_hotbar_bg(0,4.85)
|
||||||
|
local closed = "size[2,1]"..
|
||||||
|
"button[0,0;2,1;open;open]"
|
||||||
|
|
||||||
|
minetest.register_node("more_chests:secret", {
|
||||||
|
description = S("Secret Chest"),
|
||||||
|
tiles = {"secret_top.png", "secret_top.png", "secret_side.png",
|
||||||
|
"secret_side.png", "secret_side.png", "secret_front.png"},
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, tubedevice = 1, tubedevice_receiver = 1},
|
||||||
|
-- Pipeworks
|
||||||
|
tube = {
|
||||||
|
insert_object = function(pos, node, stack, direction)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
return inv:add_item("main", stack)
|
||||||
|
end,
|
||||||
|
can_insert = function(pos, node, stack, direction)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
return inv:room_for_item("main", stack)
|
||||||
|
end,
|
||||||
|
input_inventory = "main",
|
||||||
|
connect_sides = {left = 1, right = 1, back = 1, front = 1, bottom = 1, top = 1}
|
||||||
|
},
|
||||||
|
legacy_facedir_simple = true,
|
||||||
|
sounds = default.node_sound_wood_defaults(),
|
||||||
|
after_place_node = function(pos, placer)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
meta:set_string("owner", placer:get_player_name() or "")
|
||||||
|
meta:set_string("infotext", S("@1 (owned by @2)",
|
||||||
|
S("Secret Chest"),
|
||||||
|
meta:get_string("owner")))
|
||||||
|
end,
|
||||||
|
on_construct = function(pos)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
meta:set_string("formspec", open)
|
||||||
|
meta:set_string("infotext", S("Secret Chest"))
|
||||||
|
meta:set_string("owner", "")
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
inv:set_size("main", 8*4)
|
||||||
|
end,
|
||||||
|
can_dig = function(pos,player)
|
||||||
|
local meta = minetest.get_meta(pos);
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
return inv:is_empty("main")
|
||||||
|
end,
|
||||||
|
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
if not has_locked_chest_privilege(meta, player) then
|
||||||
|
minetest.log("action", player:get_player_name()..
|
||||||
|
" tried to access a secret chest belonging to "..
|
||||||
|
meta:get_string("owner").." at "..
|
||||||
|
minetest.pos_to_string(pos))
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
return count
|
||||||
|
end,
|
||||||
|
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
if not has_locked_chest_privilege(meta, player) then
|
||||||
|
minetest.log("action", player:get_player_name()..
|
||||||
|
" tried to access a secret chest belonging to "..
|
||||||
|
meta:get_string("owner").." at "..
|
||||||
|
minetest.pos_to_string(pos))
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
return stack:get_count()
|
||||||
|
end,
|
||||||
|
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
if not has_locked_chest_privilege(meta, player) then
|
||||||
|
minetest.log("action", player:get_player_name()..
|
||||||
|
" tried to access a secret chest belonging to "..
|
||||||
|
meta:get_string("owner").." at "..
|
||||||
|
minetest.pos_to_string(pos))
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
return stack:get_count()
|
||||||
|
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 secret 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 secret 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 secret chest at "..minetest.pos_to_string(pos))
|
||||||
|
end,
|
||||||
|
on_receive_fields = function(pos, formname, fields, sender)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
if has_locked_chest_privilege(meta, sender) then
|
||||||
|
if fields.open == "open" then
|
||||||
|
meta:set_string("formspec", open)
|
||||||
|
else
|
||||||
|
meta:set_string("formspec", closed)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_craft({
|
||||||
|
output = 'more_chests:secret',
|
||||||
|
recipe = {
|
||||||
|
{'default:wood','default:cobble','default:wood'},
|
||||||
|
{'default:wood','default:steel_ingot','default:wood'},
|
||||||
|
{'default:wood','default:wood','default:wood'}
|
||||||
|
}
|
||||||
|
})
|
138
shared.lua
Normal file
|
@ -0,0 +1,138 @@
|
||||||
|
-- Load support for translation.
|
||||||
|
local S = minetest.get_translator("more_chests")
|
||||||
|
|
||||||
|
local function has_locked_chest_privilege(meta, player)
|
||||||
|
local name = player:get_player_name()
|
||||||
|
local shared = " "..meta:get_string("shared").." "
|
||||||
|
if name == meta:get_string("owner") then
|
||||||
|
return true
|
||||||
|
elseif shared:find(" "..name.." ") then
|
||||||
|
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function get_formspec(string)
|
||||||
|
return "size[8,10]"..
|
||||||
|
default.gui_bg ..
|
||||||
|
default.gui_bg_img ..
|
||||||
|
default.gui_slots ..
|
||||||
|
"list[current_name;main;0,0.3;8,4;]"..
|
||||||
|
"list[current_player;main;0,4.85;8,1;]" ..
|
||||||
|
"list[current_player;main;0,6;8,3;8]" ..
|
||||||
|
"field[.25,9.5;8,1;shared;"..S("Shared with (separate names with spaces)")..":;"..string.."]"..
|
||||||
|
"button[6,9.2;2,1;submit;"..S("submit").."]" ..
|
||||||
|
"listring[current_name;main]" ..
|
||||||
|
"listring[current_player;main]" ..
|
||||||
|
default.get_hotbar_bg(0,4.85)
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.register_node("more_chests:shared", {
|
||||||
|
description = S("Shared Chest"),
|
||||||
|
tiles = {"shared_top.png", "shared_top.png", "shared_side.png",
|
||||||
|
"shared_side.png", "shared_side.png", "shared_front.png"},
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, tubedevice = 1, tubedevice_receiver = 1},
|
||||||
|
-- Pipeworks
|
||||||
|
tube = {
|
||||||
|
insert_object = function(pos, node, stack, direction)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
return inv:add_item("main", stack)
|
||||||
|
end,
|
||||||
|
can_insert = function(pos, node, stack, direction)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
return inv:room_for_item("main", stack)
|
||||||
|
end,
|
||||||
|
input_inventory = "main",
|
||||||
|
connect_sides = {left = 1, right = 1, back = 1, front = 1, bottom = 1, top = 1}
|
||||||
|
},
|
||||||
|
legacy_facedir_simple = true,
|
||||||
|
sounds = default.node_sound_wood_defaults(),
|
||||||
|
after_place_node = function(pos, placer)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
meta:set_string("owner", placer:get_player_name() or "")
|
||||||
|
meta:set_string("infotext", S("@1 (owned by @2)",
|
||||||
|
S("Shared Chest"),
|
||||||
|
meta:get_string("owner")))
|
||||||
|
end,
|
||||||
|
on_construct = function(pos)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
meta:set_string("formspec", get_formspec(""))
|
||||||
|
meta:set_string("infotext", S("Shared Chest"))
|
||||||
|
meta:set_string("owner", "")
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
inv:set_size("main", 8*4)
|
||||||
|
end,
|
||||||
|
can_dig = function(pos,player)
|
||||||
|
local meta = minetest.get_meta(pos);
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
return inv:is_empty("main")
|
||||||
|
end,
|
||||||
|
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
if not has_locked_chest_privilege(meta, player) then
|
||||||
|
minetest.log("action", player:get_player_name()..
|
||||||
|
" tried to access a shared chest belonging to "..
|
||||||
|
meta:get_string("owner").." at "..
|
||||||
|
minetest.pos_to_string(pos))
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
return count
|
||||||
|
end,
|
||||||
|
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
if not has_locked_chest_privilege(meta, player) then
|
||||||
|
minetest.log("action", player:get_player_name()..
|
||||||
|
" tried to access a shared chest belonging to "..
|
||||||
|
meta:get_string("owner").." at "..
|
||||||
|
minetest.pos_to_string(pos))
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
return stack:get_count()
|
||||||
|
end,
|
||||||
|
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
if not has_locked_chest_privilege(meta, player) then
|
||||||
|
minetest.log("action", player:get_player_name()..
|
||||||
|
" tried to access a shared chest belonging to "..
|
||||||
|
meta:get_string("owner").." at "..
|
||||||
|
minetest.pos_to_string(pos))
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
return stack:get_count()
|
||||||
|
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 shared 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 shared 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 shared chest at "..minetest.pos_to_string(pos))
|
||||||
|
end,
|
||||||
|
on_receive_fields = function(pos, formspec, fields, sender)
|
||||||
|
local meta = minetest.get_meta(pos);
|
||||||
|
if fields.shared then
|
||||||
|
if meta:get_string("owner") == sender:get_player_name() then
|
||||||
|
meta:set_string("shared", fields.shared);
|
||||||
|
meta:set_string("formspec", get_formspec(fields.shared))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_craft({
|
||||||
|
output = 'more_chests:shared',
|
||||||
|
recipe = {
|
||||||
|
{'default:wood','default:leaves','default:wood'},
|
||||||
|
{'default:wood','default:steel_ingot','default:wood'},
|
||||||
|
{'default:wood','default:wood','default:wood'}
|
||||||
|
}
|
||||||
|
})
|
Before Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 2.0 KiB |
Before Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 2.3 KiB |
Before Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 2.4 KiB |
Before Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 2.4 KiB |
Before Width: | Height: | Size: 3.0 KiB |
|
@ -1,90 +0,0 @@
|
||||||
local function get_inventory_auth_string(player, meta, pos, label)
|
|
||||||
return player:get_player_name() .. " tried to access a locked " .. label .. " belonging to " .. meta:get_string("owner") .. " at " .. minetest.pos_to_string(pos)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
function has_locked_chest_privilege(meta, player)
|
|
||||||
if player:get_player_name() ~= meta:get_string("owner") then
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
function get_allow_metadata_inventory_move(t)
|
|
||||||
setmetatable(t, {__index={check_privs=has_locked_chest_privilege}})
|
|
||||||
local label, check_privs = t[1], t.check_privs
|
|
||||||
return function(pos, from_list, from_index, to_list, to_index, count, player)
|
|
||||||
local meta = minetest.get_meta(pos)
|
|
||||||
if not check_privs(meta, player) then
|
|
||||||
minetest.log("action", get_inventory_auth_string(player, meta, pos, label))
|
|
||||||
return 0
|
|
||||||
end
|
|
||||||
return count
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function get_allow_metadata_inventory_put(t)
|
|
||||||
setmetatable(t, {__index={check_privs=has_locked_chest_privilege}})
|
|
||||||
local label, check_privs = t[1], t.check_privs
|
|
||||||
return function(pos, listname, index, stack, player)
|
|
||||||
local meta = minetest.get_meta(pos)
|
|
||||||
if not check_privs(meta, player) then
|
|
||||||
minetest.log("action", get_inventory_auth_string(player, meta, pos, label))
|
|
||||||
return 0
|
|
||||||
end
|
|
||||||
return stack:get_count()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function get_allow_metadata_inventory_take(t)
|
|
||||||
setmetatable(t, {__index={check_privs=has_locked_chest_privilege}})
|
|
||||||
local label, check_privs = t[1], t.check_privs
|
|
||||||
return function(pos, listname, index, stack, player)
|
|
||||||
local meta = minetest.get_meta(pos)
|
|
||||||
if not check_privs(meta, player) then
|
|
||||||
minetest.log("action", get_inventory_auth_string(player, meta, pos, label))
|
|
||||||
return 0
|
|
||||||
end
|
|
||||||
return stack:get_count()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
local function get_inventory_action_string(player, pos, action, label)
|
|
||||||
return player:get_player_name() .. " moves stuff " .. action .. " locked " .. label .. " at " .. minetest.pos_to_string(pos)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
function get_on_metadata_inventory_move(label)
|
|
||||||
return function(pos, from_list, from_index, to_list, to_index, count, player)
|
|
||||||
minetest.log("action", get_inventory_action_string(player, pos, "in", label)
|
|
||||||
)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function get_on_metadata_inventory_put(label)
|
|
||||||
return function(pos, listname, index, stack, player)
|
|
||||||
minetest.log("action", get_inventory_action_string(player, pos, "to", label))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function get_on_metadata_inventory_take(label)
|
|
||||||
return function(pos, listname, index, stack, player)
|
|
||||||
minetest.log("action", get_inventory_action_string(player, pos, "from", label))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
actions = {
|
|
||||||
has_locked_chest_privilege = has_locked_chest_privilege,
|
|
||||||
get_allow_metadata_inventory_move = get_allow_metadata_inventory_move,
|
|
||||||
get_allow_metadata_inventory_put = get_allow_metadata_inventory_put,
|
|
||||||
get_allow_metadata_inventory_take = get_allow_metadata_inventory_take,
|
|
||||||
get_on_metadata_inventory_move = get_on_metadata_inventory_move,
|
|
||||||
get_on_metadata_inventory_put = get_on_metadata_inventory_put,
|
|
||||||
get_on_metadata_inventory_take = get_on_metadata_inventory_take,
|
|
||||||
}
|
|
||||||
return actions
|
|
|
@ -1,97 +0,0 @@
|
||||||
-- NOTE: `require` is not allowed with mod security on
|
|
||||||
-- `dofile` with a return on the module is used instead
|
|
||||||
generate_formspec_string = dofile(minetest.get_modpath("more_chests").."/utils/formspec.lua")
|
|
||||||
local actions = dofile(minetest.get_modpath("more_chests").."/utils/actions.lua")
|
|
||||||
local S = minetest.get_translator("more_chests")
|
|
||||||
|
|
||||||
local function parse_action(value, default_getter)
|
|
||||||
if value == false then -- model disabled this attribute
|
|
||||||
return nil
|
|
||||||
elseif value == nil then -- model wants the default attribute
|
|
||||||
return default_getter()
|
|
||||||
else -- model provided its own attribute
|
|
||||||
return value
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function generate_chest_def(def)
|
|
||||||
-- TODO assert def.size in ("big", "small")
|
|
||||||
local out = {
|
|
||||||
description = def.description,
|
|
||||||
tiles = {
|
|
||||||
def.tiles.top or def.tiles.side,
|
|
||||||
def.tiles.top or def.tiles.side,
|
|
||||||
def.tiles.side,
|
|
||||||
def.tiles.side,
|
|
||||||
def.tiles.side,
|
|
||||||
def.tiles.front
|
|
||||||
},
|
|
||||||
paramtype2 = "facedir",
|
|
||||||
legacy_facedir_simple = true,
|
|
||||||
groups = {
|
|
||||||
snappy=2,
|
|
||||||
choppy=2,
|
|
||||||
oddly_breakable_by_hand=2
|
|
||||||
},
|
|
||||||
sounds = def.sounds or default.node_sound_wood_defaults(),
|
|
||||||
recipe = def.recipe, -- TODO this is buggy, reason why all models except from toolbox have their own extra call to minetest.register_craft - TODO possibily other similar bugs?
|
|
||||||
after_place_node = function(pos, placer)
|
|
||||||
local meta = minetest.get_meta(pos)
|
|
||||||
meta:set_string("owner", placer:get_player_name() or "")
|
|
||||||
meta:set_string("infotext", S("@1 (owned by @2)", def.description, meta:get_string("owner")))
|
|
||||||
end,
|
|
||||||
on_construct = function(pos)
|
|
||||||
local meta = minetest.get_meta(pos)
|
|
||||||
local formspec_str = def.formspec or generate_formspec_string(def.size)
|
|
||||||
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)
|
|
||||||
end,
|
|
||||||
can_dig = function(pos,player)
|
|
||||||
local meta = minetest.get_meta(pos)
|
|
||||||
local inv = meta:get_inventory()
|
|
||||||
return inv:is_empty("main")
|
|
||||||
end,
|
|
||||||
}
|
|
||||||
-- register log actions, NOTE passing an anonymous function to avoid getting the default if not necessary
|
|
||||||
out.allow_metadata_inventory_move = parse_action(def.allow_metadata_inventory_move, function() actions.get_allow_metadata_inventory_move{def.type} end)
|
|
||||||
out.allow_metadata_inventory_put = parse_action(def.allow_metadata_inventory_put, function() actions.get_allow_metadata_inventory_put{def.type} end)
|
|
||||||
out.allow_metadata_inventory_take = parse_action(def.allow_metadata_inventory_take, function() actions.get_allow_metadata_inventory_take{def.type} end)
|
|
||||||
out.on_metadata_inventory_move = parse_action(def.on_metadata_inventory_move, function() actions.get_on_metadata_inventory_move(def.type) end)
|
|
||||||
out.on_metadata_inventory_put = parse_action(def.on_metadata_inventory_put, function() actions.get_on_metadata_inventory_put(def.type) end)
|
|
||||||
out.on_metadata_inventory_take = parse_action(def.on_metadata_inventory_take, function() actions.get_on_metadata_inventory_take(def.type) end)
|
|
||||||
-- if model is not a simple block handle node_box attribute
|
|
||||||
if def.node_box then
|
|
||||||
out.drawtype = "nodebox"
|
|
||||||
out.node_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = def.node_box,
|
|
||||||
}
|
|
||||||
end
|
|
||||||
-- add pipeworks compatibility, TODO needs proper testing
|
|
||||||
if def.pipeworks_enabled == true then
|
|
||||||
out.groups.tubedevice = 1
|
|
||||||
out.groups.tubedevice_receiver = 1
|
|
||||||
out.tube = {
|
|
||||||
insert_object = function(pos, node, stack, direction)
|
|
||||||
local meta = minetest.get_meta(pos)
|
|
||||||
local inv = meta:get_inventory()
|
|
||||||
return inv:add_item("main", stack)
|
|
||||||
end,
|
|
||||||
can_insert = function(pos, node, stack, direction)
|
|
||||||
local meta = minetest.get_meta(pos)
|
|
||||||
local inv = meta:get_inventory()
|
|
||||||
return inv:room_for_item("main", stack)
|
|
||||||
end,
|
|
||||||
input_inventory = "main",
|
|
||||||
connect_sides = {left = 1, right = 1, back = 1, front = 1, bottom = 1, top = 1}
|
|
||||||
}
|
|
||||||
end
|
|
||||||
return out
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
return generate_chest_def
|
|
|
@ -1,38 +0,0 @@
|
||||||
function generate(size)
|
|
||||||
if size == "small" then
|
|
||||||
cfg = {
|
|
||||||
window_width = 8,
|
|
||||||
window_height = 9,
|
|
||||||
chest_width = 8,
|
|
||||||
chest_height = 4,
|
|
||||||
}
|
|
||||||
elseif size == "big" then
|
|
||||||
cfg = {
|
|
||||||
window_width = 14,
|
|
||||||
window_height = 10,
|
|
||||||
chest_width = 14,
|
|
||||||
chest_height = 5,
|
|
||||||
}
|
|
||||||
end
|
|
||||||
-- calc padding to vertically align center the chest and the player's inventory
|
|
||||||
local player_inv_y_orig = cfg.chest_height + 0.85
|
|
||||||
local player_inv_x_orig = (cfg.window_width - 8) / 2 -- 8=player_inv_width
|
|
||||||
return "size[" ..
|
|
||||||
cfg.window_width .. "," .. cfg.window_height .. "]" ..
|
|
||||||
default.gui_bg ..
|
|
||||||
default.gui_bg_img ..
|
|
||||||
default.gui_slots ..
|
|
||||||
"list[current_name;main;0,0.3;" ..
|
|
||||||
cfg.chest_width .. "," .. cfg.chest_height .. ";]" ..
|
|
||||||
"list[current_player;main;" ..
|
|
||||||
player_inv_x_orig .. "," .. player_inv_y_orig ..
|
|
||||||
";8,1;]" ..
|
|
||||||
"list[current_player;main;" ..
|
|
||||||
player_inv_x_orig .. "," .. (player_inv_y_orig + 1.15) ..
|
|
||||||
";8,3;8]" ..
|
|
||||||
"listring[current_name;main]" ..
|
|
||||||
"listring[current_player;main]" ..
|
|
||||||
default.get_hotbar_bg(player_inv_x_orig, player_inv_y_orig)
|
|
||||||
end
|
|
||||||
|
|
||||||
return generate
|
|
54
wifi.lua
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
-- Load support for translation.
|
||||||
|
local S = minetest.get_translator("more_chests")
|
||||||
|
|
||||||
|
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", "wifi_front.png"},
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2,},
|
||||||
|
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)
|