diff --git a/changelog.txt b/changelog.txt index 357af07..1d98fe4 100644 --- a/changelog.txt +++ b/changelog.txt @@ -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. diff --git a/mods/common/formspec.lua b/mods/common/formspec.lua index 689a2c0..90a121f 100644 --- a/mods/common/formspec.lua +++ b/mods/common/formspec.lua @@ -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'.. diff --git a/mods/creative/inventory.lua b/mods/creative/inventory.lua index 12f5ea4..551d873 100644 --- a/mods/creative/inventory.lua +++ b/mods/creative/inventory.lua @@ -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() diff --git a/mods/gamer/init.lua b/mods/gamer/init.lua index ed113ad..bf7c644 100644 --- a/mods/gamer/init.lua +++ b/mods/gamer/init.lua @@ -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) diff --git a/mods/sfinv/api.lua b/mods/sfinv/api.lua index 42caaa6..641f376 100644 --- a/mods/sfinv/api.lua +++ b/mods/sfinv/api.lua @@ -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 diff --git a/mods/spawn/vending_machine.lua b/mods/spawn/vending_machine.lua index 673e73c..36fd71d 100644 --- a/mods/spawn/vending_machine.lua +++ b/mods/spawn/vending_machine.lua @@ -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;]' diff --git a/mods/storage/chests.lua b/mods/storage/chests.lua new file mode 100644 index 0000000..8486492 --- /dev/null +++ b/mods/storage/chests.lua @@ -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, +}) diff --git a/mods/storage/depends.txt b/mods/storage/depends.txt new file mode 100644 index 0000000..30e1159 --- /dev/null +++ b/mods/storage/depends.txt @@ -0,0 +1 @@ +common diff --git a/mods/storage/formspecs.lua b/mods/storage/formspecs.lua new file mode 100644 index 0000000..e69de29 diff --git a/mods/storage/functions.lua b/mods/storage/functions.lua new file mode 100644 index 0000000..7d715b3 --- /dev/null +++ b/mods/storage/functions.lua @@ -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 diff --git a/mods/storage/init.lua b/mods/storage/init.lua new file mode 100644 index 0000000..4e90df9 --- /dev/null +++ b/mods/storage/init.lua @@ -0,0 +1,3 @@ +storage = {} +dofile(minetest.get_modpath('storage')..'/functions.lua') +dofile(minetest.get_modpath('storage')..'/chests.lua') diff --git a/mods/storage/textures/storage_label.png b/mods/storage/textures/storage_label.png new file mode 100644 index 0000000..3f62d93 Binary files /dev/null and b/mods/storage/textures/storage_label.png differ diff --git a/mods/storage/textures/storage_wooden_chest_back.png b/mods/storage/textures/storage_wooden_chest_back.png new file mode 100644 index 0000000..fdbb122 Binary files /dev/null and b/mods/storage/textures/storage_wooden_chest_back.png differ diff --git a/mods/storage/textures/storage_wooden_chest_front.png b/mods/storage/textures/storage_wooden_chest_front.png new file mode 100644 index 0000000..89d78ac Binary files /dev/null and b/mods/storage/textures/storage_wooden_chest_front.png differ diff --git a/mods/storage/textures/storage_wooden_chest_lock.png b/mods/storage/textures/storage_wooden_chest_lock.png new file mode 100644 index 0000000..6ff2205 Binary files /dev/null and b/mods/storage/textures/storage_wooden_chest_lock.png differ diff --git a/mods/storage/textures/storage_wooden_chest_side.png b/mods/storage/textures/storage_wooden_chest_side.png new file mode 100644 index 0000000..129db5c Binary files /dev/null and b/mods/storage/textures/storage_wooden_chest_side.png differ diff --git a/mods/storage/textures/storage_wooden_chest_top.png b/mods/storage/textures/storage_wooden_chest_top.png new file mode 100644 index 0000000..528492d Binary files /dev/null and b/mods/storage/textures/storage_wooden_chest_top.png differ