added a chest.

master
NathanSalapat 2017-05-29 18:32:04 -05:00
parent 8559e43195
commit 9896cc8203
17 changed files with 106 additions and 10 deletions

View File

@ -1,3 +1,6 @@
2017-05-29:
Added a chest and did some updates to the players inventory and formspecs.
2017-05-27:
Added in doors to the spawn mod. I have a feeling they are going to need lots more work.

View File

@ -19,8 +19,7 @@ common.gui_survival_form = 'size[8,7.5]'..
common.gui_bg..
common.gui_bg_img..
common.gui_slots..
'list[current_player;main;0,3.5;8,1;]'..
'list[current_player;main;0,4.5;8,3;8]'..
'list[current_player;main;0,4;8,3;]'..
'list[current_player;craft;0,0;3,3;]'..
'list[current_player;craftpreview;4,1;1,1;]'..
'image[3,1;1,1;common_arrow.png'..

View File

@ -92,8 +92,7 @@ function creative.register_tab(name, title, items)
[[
image[4,3.3;1,1;creative_trash_icon.png]
listcolors[#00000069;#5A5A5A;#141318;#30434C;#FFF]
list[current_player;main;0,4.7;8,1;]
list[current_player;main;0,5.85;8,3;8]
list[current_player;main;0,4.5;8,3;]
list[detached:creative_trash;main;4,3.3;1,1;]
listring[]
button[5.4,3.2;0.8,0.9;creative_prev;<]
@ -108,9 +107,8 @@ function creative.register_tab(name, title, items)
"field[0.3,3.5;2.2,1;creative_filter;;" .. minetest.formspec_escape(inv.filter) .. "]" ..
"listring[detached:creative_" .. player_name .. ";main]" ..
"list[detached:creative_" .. player_name .. ";main;0,0;8,3;" .. tostring(start_i) .. "]" ..
-- common.get_hotbar_bg(0,4.7) ..
common.gui_bg .. common.gui_bg_img .. common.gui_slots
.. creative.formspec_add, false)
.. creative.formspec_add, false, "size[8,7.25]")
end,
on_enter = function(self, player, context)
local player_name = player:get_player_name()

View File

@ -104,6 +104,7 @@ end
-- Update appearance when the player joins
minetest.register_on_joinplayer(function(player)
player:get_inventory():set_size('main', 8*3)
gamer.player_attached[player:get_player_name()] = false
gamer.player_set_model(player, 'gamer_model.b3d')
player:set_local_animation({x=0, y=79}, {x=168, y=187}, {x=189, y=198}, {x=200, y=219}, 30)

View File

@ -39,13 +39,12 @@ local theme_main = "bgcolor[#080808BB;true]" .. common.gui_bg ..
common.gui_bg_img
local theme_inv = common.gui_slots .. [[
list[current_player;main;0,3.5;8,1;]
list[current_player;main;0,4.5;8,3;8]
list[current_player;main;0,3.5;8,3;]
]]
function sfinv.make_formspec(player, context, content, show_inv, size)
local tmp = {
size or "size[8,7.5]",
size or "size[8,6.25]",
theme_main,
sfinv.get_nav_fs(player, context, context.nav_titles, context.nav_idx),
content

View File

@ -7,7 +7,7 @@ formspec_owner =
'list[context;cost;2,1;1,1;]'..
'field[3.3,1.4;1,1;costa;;1]'..
'field[5.3,0.4;3,1;sname;store name;Unconfigured Vending Machine]'..
'field[0.3,2.4;8,1;desc;item description;What this item is.]'..
'field[0.3,2.4;8,1;desc;item description;What this item is.]'..
'button_exit[5,1;3,1;save;Save Vending Machine]'..
'list[current_player;main;0,3;8,4;]'

32
mods/storage/chests.lua Normal file
View File

@ -0,0 +1,32 @@
minetest.register_node('storage:wooden_chest', {
description = 'Wooden Chest',
tiles = {'storage_wooden_chest_top.png',
'storage_wooden_chest_top.png',
'storage_wooden_chest_side.png',
'storage_wooden_chest_side.png',
'storage_wooden_chest_back.png',
'storage_wooden_chest_front.png'},
groups = {choppy=2,oddly_breakable_by_hand=2},
paramtype2 = 'facedir',
-- sounds = default.node_sound_wood_defaults(),
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string('formspec', storage.wooden_chest_formspec(''))
local inv = meta:get_inventory()
inv:set_size('main', 6*3)
end,
can_dig = function(pos,player)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
return inv:is_empty('main')
end,
on_receive_fields = function(pos, formname, fields, sender)
local meta = minetest.get_meta(pos)
if fields ['save'] then
meta:set_string('infotext', fields.description)
meta:set_string('formspec', storage.wooden_chest_formspec(fields.description))
elseif fields ['sort'] then
storage.sort_inventory(meta:get_inventory())
end
end,
})

1
mods/storage/depends.txt Normal file
View File

@ -0,0 +1 @@
common

View File

View File

@ -0,0 +1,60 @@
function storage.wooden_chest_formspec(name)
local formspec =
'size[8,7.75]'..
common.gui_bg..
common.gui_bg_img..
common.gui_slots..
'list[current_name;main;1,0;6,3;]'..
'image[0,3;1,1;storage_label.png]'..
'field[1.3,3.3;2,1;description;;'..name..']'..
'button[3,3;1,1;save;Save]'..
'button[4,3;1,1;sort;Sort]'..
'list[current_player;main;0,4;8,3;]'..
'listring[]'
return formspec
end
function storage.sort_inventory(inv) -- Copied from the Technic_chests mod.
local inlist = inv:get_list("main")
local typecnt = {}
local typekeys = {}
for _, st in ipairs(inlist) do
if not st:is_empty() then
local n = st:get_name()
local w = st:get_wear()
local m = st:get_metadata()
local k = string.format("%s %05d %s", n, w, m)
if not typecnt[k] then
typecnt[k] = {
name = n,
wear = w,
metadata = m,
stack_max = st:get_stack_max(),
count = 0,
}
table.insert(typekeys, k)
end
typecnt[k].count = typecnt[k].count + st:get_count()
end
end
table.sort(typekeys)
local outlist = {}
for _, k in ipairs(typekeys) do
local tc = typecnt[k]
while tc.count > 0 do
local c = math.min(tc.count, tc.stack_max)
table.insert(outlist, ItemStack({
name = tc.name,
wear = tc.wear,
metadata = tc.metadata,
count = c,
}))
tc.count = tc.count - c
end
end
if #outlist > #inlist then return end
while #outlist < #inlist do
table.insert(outlist, ItemStack(nil))
end
inv:set_list("main", outlist)
end

3
mods/storage/init.lua Normal file
View File

@ -0,0 +1,3 @@
storage = {}
dofile(minetest.get_modpath('storage')..'/functions.lua')
dofile(minetest.get_modpath('storage')..'/chests.lua')

Binary file not shown.

After

Width:  |  Height:  |  Size: 370 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB