initial draft
commit
7ebb2141a6
|
@ -0,0 +1,17 @@
|
||||||
|
name: luacheck
|
||||||
|
|
||||||
|
on: [push]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v1
|
||||||
|
- name: apt
|
||||||
|
run: sudo apt-get install -y luarocks
|
||||||
|
- name: luacheck install
|
||||||
|
run: luarocks install --local luacheck
|
||||||
|
- name: luacheck run
|
||||||
|
run: $HOME/.luarocks/bin/luacheck ./
|
|
@ -0,0 +1,18 @@
|
||||||
|
|
||||||
|
globals = {
|
||||||
|
"detached_chest"
|
||||||
|
}
|
||||||
|
|
||||||
|
read_globals = {
|
||||||
|
-- Stdlib
|
||||||
|
string = {fields = {"split"}},
|
||||||
|
table = {fields = {"copy", "getn"}},
|
||||||
|
|
||||||
|
-- Minetest
|
||||||
|
"vector", "ItemStack",
|
||||||
|
"dump",
|
||||||
|
|
||||||
|
-- deps
|
||||||
|
"default",
|
||||||
|
"minetest"
|
||||||
|
}
|
|
@ -0,0 +1,53 @@
|
||||||
|
|
||||||
|
minetest.register_node("detached_chest:detached_chest", {
|
||||||
|
description = "Detached 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
|
||||||
|
},
|
||||||
|
|
||||||
|
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())
|
||||||
|
meta:set_string("infotext", "Detached Chest (unconfigured)")
|
||||||
|
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_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))
|
||||||
|
|
||||||
|
end,
|
||||||
|
|
||||||
|
on_rightclick = function(pos, _, player)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
if meta:get_string("channel") == "" then
|
||||||
|
detached_chest.show_form_configure(pos, player)
|
||||||
|
else
|
||||||
|
detached_chest.show_form_inventory(pos, player)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
})
|
|
@ -0,0 +1,36 @@
|
||||||
|
|
||||||
|
local FORMNAME = "detached_chest_configure"
|
||||||
|
|
||||||
|
function detached_chest.show_form_configure(pos, player)
|
||||||
|
|
||||||
|
local playername = player:get_player_name()
|
||||||
|
local formspec = "field[channel;Channel;${channel}"
|
||||||
|
|
||||||
|
minetest.show_formspec(playername,
|
||||||
|
FORMNAME .. ";" .. minetest.pos_to_string(pos),
|
||||||
|
formspec
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
|
local parts = formname:split(";")
|
||||||
|
local name = parts[1]
|
||||||
|
if name ~= FORMNAME then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local pos = minetest.string_to_pos(parts[2])
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local playername = player:get_player_name()
|
||||||
|
|
||||||
|
if minetest.is_protected(pos, playername) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if fields.save and fields.channel then
|
||||||
|
meta:set_string("channel", fields.channel)
|
||||||
|
meta:set_string("infotext", "Detached Chest (channel: " .. fields.channel .. ")")
|
||||||
|
end
|
||||||
|
|
||||||
|
end)
|
|
@ -0,0 +1,28 @@
|
||||||
|
|
||||||
|
local FORMNAME = "detached_chest_inventory"
|
||||||
|
|
||||||
|
function detached_chest.show_form_inventory(pos, player)
|
||||||
|
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local channel = meta:get_string("channel")
|
||||||
|
detached_chest.setup_inventory(player, channel)
|
||||||
|
|
||||||
|
local inv_name = detached_chest.get_inventory_name(player, channel)
|
||||||
|
|
||||||
|
local playername = player:get_player_name()
|
||||||
|
local formspec = "size[8,9]"..
|
||||||
|
default.gui_bg ..
|
||||||
|
default.gui_bg_img ..
|
||||||
|
default.gui_slots ..
|
||||||
|
"list[current_player;detached:" .. inv_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_player;detached:" .. inv_name .. ";main]" ..
|
||||||
|
"listring[current_player;main]" ..
|
||||||
|
default.get_hotbar_bg(0,4.85)
|
||||||
|
|
||||||
|
minetest.show_formspec(playername,
|
||||||
|
FORMNAME .. ";" .. minetest.pos_to_string(pos),
|
||||||
|
formspec
|
||||||
|
)
|
||||||
|
end
|
|
@ -0,0 +1,9 @@
|
||||||
|
|
||||||
|
detached_chest = {}
|
||||||
|
|
||||||
|
local MP = minetest.get_modpath("detached_chest")
|
||||||
|
|
||||||
|
dofile(MP.."/form_cofigure.lua")
|
||||||
|
dofile(MP.."/form_inventory.lua")
|
||||||
|
dofile(MP.."/inventory.lua")
|
||||||
|
dofile(MP.."/chest_node.lua")
|
|
@ -0,0 +1,43 @@
|
||||||
|
|
||||||
|
-- playername -> { inv_name = <inv>, inv_name2 = <inv> }
|
||||||
|
local player_inventories = {}
|
||||||
|
|
||||||
|
function detached_chest.get_inventory_name(player, channel)
|
||||||
|
return player:get_player_name() .. ":" .. channel
|
||||||
|
end
|
||||||
|
|
||||||
|
-- create / get
|
||||||
|
function detached_chest.setup_inventory(player, channel)
|
||||||
|
local inv_name = detached_chest.get_inventory_name(player, channel)
|
||||||
|
local playername = player:get_player_name()
|
||||||
|
|
||||||
|
local inv_map = player_inventories[playername]
|
||||||
|
if not inv_map then
|
||||||
|
inv_map = {}
|
||||||
|
player_inventories[playername] = inv_map
|
||||||
|
end
|
||||||
|
|
||||||
|
local inv = inv_map[inv_name]
|
||||||
|
if not inv then
|
||||||
|
inv = minetest.create_detached_inventory(inv_name, {}) -- TODO: on_* checks
|
||||||
|
inv:set_size("main", 8*4)
|
||||||
|
-- TODO: restore
|
||||||
|
inv_map[inv_name] = inv
|
||||||
|
end
|
||||||
|
|
||||||
|
return inv
|
||||||
|
end
|
||||||
|
|
||||||
|
-- cleanup
|
||||||
|
minetest.register_on_leaveplayer(function(player)
|
||||||
|
local playername = player:get_player_name()
|
||||||
|
|
||||||
|
if not player_inventories[playername] then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
for inv_name in pairs(player_inventories[playername]) do
|
||||||
|
-- TODO: persist
|
||||||
|
minetest.remove_detached_inventory(inv_name)
|
||||||
|
end
|
||||||
|
end)
|
|
@ -0,0 +1,3 @@
|
||||||
|
name = detached_chest
|
||||||
|
description = configurable, detached chest
|
||||||
|
depends = default
|
|
@ -0,0 +1,12 @@
|
||||||
|
A configurable chest (mod for minetest)
|
||||||
|
|
||||||
|
# Overview
|
||||||
|
|
||||||
|
State: **WIP**
|
||||||
|
|
||||||
|
# Licenses
|
||||||
|
|
||||||
|
* Code: MIT
|
||||||
|
* Textures: CC-BY-SA 3.0
|
||||||
|
|
||||||
|
* `textures/wifi*.png` https://github.com/minetest-mods/more_chests
|
Binary file not shown.
After Width: | Height: | Size: 864 B |
Binary file not shown.
After Width: | Height: | Size: 833 B |
Binary file not shown.
After Width: | Height: | Size: 741 B |
Loading…
Reference in New Issue