From c9d0b5a9c383633bb6cfd9975c72e84ea6adb735 Mon Sep 17 00:00:00 2001 From: stujones11 Date: Mon, 13 May 2019 21:25:43 +0100 Subject: [PATCH] Update inventory and chests --- games/default/files/creative/inventory.lua | 159 +++++++++--------- .../creative/textures/creative_active.png | Bin 187 -> 246 bytes .../creative/textures/inventory_creative.png | Bin 3064 -> 4283 bytes games/default/files/default/chests.lua | 43 +---- 4 files changed, 84 insertions(+), 118 deletions(-) diff --git a/games/default/files/creative/inventory.lua b/games/default/files/creative/inventory.lua index e719a7cf5..f78f63a6a 100644 --- a/games/default/files/creative/inventory.lua +++ b/games/default/files/creative/inventory.lua @@ -1,62 +1,62 @@ local player_inventory = {} local inventory_cache = {} -local ofs = {} -local ofy = {} -local hoch = {} +local ofs_tab = {} +local ofs_img = {} local bg = {} +local rot = {} -ofs["blocks"] = {x=-0.29, y=-0.25} -ofs["deco"] = {x=0.98, y=-0.25} -ofs["mese"] = {x=2.23, y=-0.25} -ofs["rail"] = {x=3.495, y=-0.25} -ofs["misc"] = {x=4.75, y=-0.25} -ofs["all"] = {x=8.99, y=-0.25} -ofs["food"] = {x=-0.29, y=8.12} -ofs["tools"] = {x=0.98, y=8.12} -ofs["combat"] = {x=2.23, y=8.12} -ofs["brew"] = {x=4.78, y=8.12} -ofs["matr"] = {x=3.495, y=8.12} -ofs["inv"] = {x=8.99, y=8.12} +rot["all"] = "^[transformR270" +rot["inv"] = "^[transformR270" +rot["blocks"] = "" +rot["deco"] = "" +rot["mese"] = "" +rot["rail"] = "" +rot["misc"] = "" +rot["food"] = "" +rot["tools"] = "" +rot["combat"] = "" +rot["matr"] = "" +rot["brew"] = "" -ofy["blocks"] = 0.24 -ofy["deco"] = 0.24 -ofy["mese"] = 0.24 -ofy["rail"] = 0.24 -ofy["misc"] = 0.24 -ofy["all"] = 0.24 -ofy["food"] = 0.14 -ofy["tools"] = 0.14 -ofy["combat"] = 0.14 -ofy["brew"] = 0.14 -ofy["matr"] = 0.14 -ofy["inv"] = 0.14 +ofs_tab["all"] = "10.05,0.84" +ofs_tab["inv"] = "10.05,6.93" +ofs_tab["blocks"] = "-0.29,-0.32" +ofs_tab["deco"] = "0.74,-0.32" +ofs_tab["mese"] = "1.78,-0.32" +ofs_tab["rail"] = "2.81,-0.32" +ofs_tab["misc"] = "3.84,-0.32" +ofs_tab["food"] = "4.88,-0.32" +ofs_tab["tools"] = "5.91,-0.32" +ofs_tab["combat"] = "6.94,-0.32" +ofs_tab["matr"] = "7.98,-0.32" +ofs_tab["brew"] = "9.01,-0.32" -hoch["blocks"] = "" -hoch["deco"] = "" -hoch["mese"] = "" -hoch["rail"] = "" -hoch["misc"] = "" -hoch["all"] = "" -hoch["food"] = "^[transformfy" -hoch["tools"] = "^[transformfy" -hoch["combat"] = "^[transformfy" -hoch["brew"] = "^[transformfy" -hoch["matr"] = "^[transformfy" -hoch["inv"] = "^[transformfy" +ofs_img["all"] = "10.27,1" +ofs_img["inv"] = "10.27,7.15" +ofs_img["blocks"] = "-0.15,-0.15" +ofs_img["deco"] = "0.88,-0.15" +ofs_img["mese"] = "1.92,-0.15" +ofs_img["rail"] = "2.96,-0.15" +ofs_img["misc"] = "4,-0.15" +ofs_img["food"] = "5.05,-0.15" +ofs_img["tools"] = "6.11,-0.15" +ofs_img["combat"] = "7.14,-0.15" +ofs_img["matr"] = "8.18,-0.15" +ofs_img["brew"] = "9.21,-0.15" +bg["inv"] = "creative_inv.png" bg["blocks"] = "default_grass_side.png" bg["deco"] = "default_sapling.png" bg["mese"] = "jeija_lightstone_gray_on.png" bg["rail"] = "boats_inventory.png" bg["misc"] = "bucket_water.png" -bg["all"] = "creative_all.png" bg["food"] = "creative_food.png" bg["tools"] = "default_tool_diamondpick.png" bg["combat"] = "default_tool_steelsword.png" -bg["brew"] = "potions_bottle.png" bg["matr"] = "default_emerald.png" -bg["inv"] = "creative_inv.png" +bg["brew"] = "potions_bottle.png" +bg["all"] = "creative_all.png" local function get_item_list(group) local item_list = {} @@ -121,7 +121,8 @@ function creative.init_creative_inventory(player) end, on_take = function(inv, listname, index, stack, player2) if stack and stack:get_count() > 0 then - minetest.log("action", player_name .. " takes " .. stack:get_name().. " from creative inventory") + minetest.log("action", player_name.." takes ".. + stack:get_name().." from creative inventory") end end, }, player_name) @@ -133,8 +134,8 @@ function creative.update_creative_inventory(player_name, tab_content) local creative_list = {} local inv = player_inventory[player_name] or creative.init_creative_inventory(minetest.get_player_by_name(player_name)) - local player_inv = minetest.get_inventory({type = "detached", name = "creative_" .. player_name}) - + local player_inv = minetest.get_inventory({type="detached", + name="creative_"..player_name}) local items = inventory_cache[tab_content] or init_creative_cache(tab_content) for name, def in pairs(items) do @@ -169,51 +170,51 @@ local function get_creative_formspec(player_name, start_i, pagenum, page, pagema pagenum = math.floor(pagenum) or 1 pagemax = (pagemax and pagemax ~= 0) and pagemax or 1 local slider_height = 4 / pagemax - local slider_pos = slider_height * (pagenum - 1) + 2.2 + local slider_pos = slider_height * (pagenum - 1) + 2.15 local formspec = "" local main_list = "list[detached:creative_" .. player_name .. - ";main;0,1.75;9,5;"..tostring(start_i).."]" + ";main;0,1.69;9,5;"..tostring(start_i).."]" local name = "all" if page ~= nil then name = page end if name == "inv" then - main_list = "image[-0.2,1.7;11.35,2.33;creative_bg.png]".. + main_list = "image[-0.2,1.6;11.35,2.33;creative_bg.png]".. "image[-0.3,0.15;3,4.3;inventory_armor.png]".. - "list[current_player;main;0,3.75;9,3;9]".. + "list[current_player;main;0,3.68;9,3;9]".. "list[detached:"..player_name.."_armor;armor;0.02,1.7;1,1;]".. "list[detached:"..player_name.."_armor;armor;0.02,2.7;1,1;1]".. "list[detached:"..player_name.."_armor;armor;0.98,1.7;1,1;2]".. "list[detached:"..player_name.."_armor;armor;0.98,2.7;1,1;3]" end - local formspec = "image_button_exit[8.4,-0.1;0.75,0.75;close.png;exit;;true;true;]".. - "background[-0.19,-0.25;10.5,9.87;inventory_creative.png]".. + local formspec = "image_button_exit[10.4,-0.1;0.75,0.75;close.png;exit;;true;true;]".. + "background[-0.19,-0.25;11.5,8.5;inventory_creative.png]".. "bgcolor[#080808BB;true]".. "listcolors[#9990;#FFF7;#FFF0;#160816;#D4D2FF]".. "label[-5,-5;"..name.."]".. - "image_button[-0.1,0;1,1;"..bg["blocks"]..";build;;;false]".. --build blocks - "image_button[1.15,0;1,1;"..bg["deco"]..";deco;;;false]".. --decoration blocks - "image_button[2.415,0;1,1;"..bg["mese"]..";mese;;;false]".. --bluestone - "image_button[3.693,0;1,1;"..bg["rail"]..";rail;;;false]".. --transportation - "image_button[4.93,0;1,1;"..bg["misc"]..";misc;;;false]".. --miscellaneous - "image_button[9.19,0;1,1;"..bg["all"]..";default;;;false]".. --search - "image[0,1;5,0.75;fnt_"..name..".png]".. - "list[current_player;main;0,7;9,1;]".. - main_list.. - "image_button[9.03,1.74;0.85,0.6;creative_up.png;creative_prev;]".. - "image_button[9.03,6.15;0.85,0.6;creative_down.png;creative_next;]".. - "image_button[-0.1,8.28;1,1;"..bg["food"]..";food;;;false]".. --foodstuff - "image_button[1.15,8.28;1,1;"..bg["tools"]..";tools;;;false]".. --tools - "image_button[2.415,8.28;1,1;"..bg["combat"]..";combat;;;false]".. --combat - "image_button[3.693,8.28;1,1;"..bg["matr"]..";matr;;;false]".. --brewing - "image_button[4.93,8.28;1,1;"..bg["brew"]..";brew;;;false]".. --materials - "image_button[9.19,8.28;1,1;"..bg["inv"]..";inv;;;false]".. --inventory - "list[detached:creative_trash;main;9.02,7.02;1,1;]".. - "image["..ofs[name].x..", "..ofs[name].y..";1.5,1.44;creative_active.png"..hoch[name].."]".. - "image["..(ofs[name].x + 0.17)..", "..(ofs[name].y + ofy[name])..";1,1;"..bg[name].."]".. - "image[9.04," .. tostring(slider_pos) .. ";0.78,"..tostring(slider_height) .. ";creative_slider.png]" + "image_button[-0.16,-0.15;1,1;"..bg["blocks"]..";build;;;false]".. --build blocks + "image_button[0.87,-0.15;1,1;"..bg["deco"]..";deco;;;false]".. --decoration blocks + "image_button[1.92,-0.15;1,1;"..bg["mese"]..";mese;;;false]".. --bluestone + "image_button[2.96,-0.15;1,1;"..bg["rail"]..";rail;;;false]".. --transportation + "image_button[4,-0.15;1,1;"..bg["misc"]..";misc;;;false]".. --miscellaneous + "image[0,0.95;5,0.75;fnt_"..name..".png]".. + "list[current_player;main;0,6.955;9,1;]"..main_list.. + "image_button[9.02,1.69;0.98,0.6;creative_up.png;creative_prev;]".. + "image_button[9.02,6.08;0.98,0.6;creative_down.png;creative_next;]".. + "image_button[5.05,-0.15;1,1;"..bg["food"]..";food;;;false]".. --foodstuff + "image_button[6.1,-0.15;1,1;"..bg["tools"]..";tools;;;false]".. --tools + "image_button[7.15,-0.15;1,1;"..bg["combat"]..";combat;;;false]".. --combat + "image_button[8.17,-0.15;1,1;"..bg["matr"]..";matr;;;false]".. --materials + "image_button[9.2,-0.15;1,1;"..bg["brew"]..";brew;;;false]".. --brewing + "image_button[10.27,1;1,1;"..bg["all"]..";default;;;false]".. --all items + "image_button[10.27,7.15;1,1;"..bg["inv"]..";inv;;;false]".. --inventory + "list[detached:creative_trash;main;9.02,6.955;1,1;]".. + "image["..ofs_tab[name]..";1.45,1.45;creative_active.png"..rot[name].."]".. + "image["..ofs_img[name]..";1,1;"..bg[name].."]".. + "image[9.04," .. tostring(slider_pos) .. ";0.93,"..tostring(slider_height) .. ";creative_slider.png]" if name == "all" then - formspec = formspec .. "field_close_on_enter[suche;false]" .. - "field[5.3,1.3;4,0.75;suche;;]" + formspec = formspec .. "field_close_on_enter[search;false]".. + "field[5.3,1.27;4,0.75;search;;]".. + "image_button[9.02,0.93;1,0.8;creative_search.png;creative_search;;;false]" end if pagenum ~= nil then formspec = formspec .. "p"..tostring(pagenum) @@ -236,7 +237,7 @@ function creative.register_tab(name, title, items) local pagemax = math.ceil(inv.size / (5*9)) local formspec = get_creative_formspec(player_name, start_i, pagenum, name, pagemax) - return sfinv.make_formspec(player, context, formspec, false, "size[10,9.3]") + return sfinv.make_formspec(player, context, formspec, false, "size[11,9]") end, on_enter = function(self, player, context) local player_name = player:get_player_name() @@ -275,10 +276,11 @@ function creative.register_tab(name, title, items) sfinv.set_page(player, "creative:inv") elseif fields.brew then sfinv.set_page(player, "creative:brew") - elseif fields.suche and - fields.key_enter_field == "suche" then + elseif fields.search and + (fields.creative_search or + fields.key_enter_field == "search") then inv.start_i = 0 - inv.filter = fields.suche:lower() + inv.filter = fields.search:lower() creative.update_creative_inventory(player_name, items) sfinv.set_player_inventory_formspec(player, context) elseif not fields.quit then @@ -297,7 +299,6 @@ function creative.register_tab(name, title, items) start_i = 0 end end - inv.start_i = start_i sfinv.set_player_inventory_formspec(player, context) end diff --git a/games/default/files/creative/textures/creative_active.png b/games/default/files/creative/textures/creative_active.png index b7d8f42c81863697744fdc74416bc06554b161cb..a9507da7447da736dcdb58fa90ab776f6cd45b99 100644 GIT binary patch literal 246 zcmeAS@N?(olHy`uVBq!ia0vp^aUjgX3?w7|?283bLIFM@uF3g1K&GIeU`9s9wX4tm z|NnpI|LN&KA;yv*zhDN3XE)M7oFs2|7lsa2Sq~tGv%n*=n1O*?7=#%aX3dcR3bL1Y z`ns||X65A*5W1Ru%LphG>*?Yc5^?zL>5ZHX4k9cUMNPsFGV$m*` zcTbo29RDw&Put*)X-@OfW3sJV)xK=`%=I#R<5!Pu*K*8epG~XYd=pFqspNGBMRE_E bzy1C0m)(52HX*OmL2mGL^>bP0l+XkKxq32L)saAWI-DjfkYuL{0@vgHS+5#vNgU5aME#JHE z-ut`1mn5nig#d4caX1{o$g+d7k2w)zH2nq_~a5!OMVHk!b#-FD|1 zuQoL`wY9aix3_n9clY)@e(~bPU$&jOuwY)5(+4yU3n z{ZqhY=V}6_@-Zh@d*z1^0a>S7)Dtw0!>K)Sva|7uy!U+Qf#)v{n(-c_r0xhp@F#-n zr(z_v^oLn4n^lAUQBg2|?0z#-SMxdN<8}T1S1>X%TTk=#HSs=w61&yKYD`-2xyv$ zmP)bUE|#juN-klX!J8p@EoC3VHR16<6j$OP*1i%(vP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SYP zy<2L1e0^vat1O|QsYu&dP?Rwj7bcrq*dS(!(GJZ0*m4foRQ`E;FuY4=YZ36B!2WR? zUOs%V^yppQp^zlFC(jz3vH-#JLKrk8wO%^sjV{rd+X5io)lS-T1oIy z_6(#rA}bb{hlLe$fv`6)Dhtb%%Ecwa=t2`~PHQ}u8yA!|>yp)+KkTL^%wH0QY4eA^ z&aQ4`d0hrDR9o;^=`LD1?P0X`Kf=TD%AuIZc&qt>1`=)sZdNMPK|e*^7@nA)O1Dm&aJc}BgHgwY2#fwYz9IP X{q<^^PyUz(e6!cx%dPa!2UGtGk7Y!Z diff --git a/games/default/files/default/chests.lua b/games/default/files/default/chests.lua index d32ab199b..6b1df6981 100644 --- a/games/default/files/default/chests.lua +++ b/games/default/files/default/chests.lua @@ -26,20 +26,6 @@ local function get_chest_neighborpos(pos, param2, side) end end -local function hacky_swap_node(pos,name, param2) - local node = minetest.get_node(pos) - local meta = minetest.get_meta(pos) - if node.name == name then - return - end - node.name = name - node.param2 = param2 or node.param2 - local meta0 = meta:to_table() - minetest.set_node(pos,node) - meta = minetest.get_meta(pos) - meta:from_table(meta0) -end - default.chest_formspec = "size[9,9.75]".. "image_button_exit[8.4,-0.1;0.75,0.75;close.png;exit;;true;true;]".. @@ -53,27 +39,6 @@ default.chest_formspec = local chest_inv_size = 4*9 local chest_inv_vers = 2 -function default.get_locked_chest_formspec(pos) - local meta = minetest.get_meta(pos) - local inv_v = meta:get_int("chest_inv_ver") - if inv_v and inv_v < chest_inv_vers then - local inv = meta:get_inventory() - inv:set_size("main",chest_inv_size) - meta:set_int("chest_inv_ver",chest_inv_vers) - end - local spos = pos.x .. "," .. pos.y .. "," ..pos.z - local formspec = - "size[9,9.75]".. - "image_button_exit[8.4,-0.1;0.75,0.75;close.png;exit;;true;true;]".. - "background[-0.19,-0.25;9.41,10.48;formspec_chest.png]".. - "bgcolor[#080808BB;true]".. - "listcolors[#9990;#FFF7;#FFF0;#160816;#D4D2FF]".. - "list[nodemeta:".. spos .. ";main;0,0.5;9,4;]".. - "list[current_player;main;0,5.5;9,3;9]".. - "list[current_player;main;0,8.74;9,1;]" - return formspec -end - minetest.register_abm({ nodenames = {"default:chest"}, interval = 1, @@ -111,7 +76,7 @@ minetest.register_node("default:chest", { "list[current_player;main;0,7;9,3;9]".. "list[current_player;main;0,10.5;9,1;]") meta:set_string("infotext", "Large Chest") - hacky_swap_node(p, "default:chest_left", param2) + minetest.swap_node(p, {name="default:chest_left", param2=param2}) local m = minetest.get_meta(p) m:set_string("formspec", "size[9,11.5]".. @@ -132,7 +97,7 @@ minetest.register_node("default:chest", { "list[current_player;main;0,7;9,3;9]".. "list[current_player;main;0,10.5;9,1;]") meta:set_string("infotext", "Large Chest") - hacky_swap_node(p, "default:chest_right", param2) + minetest.swap_node(p, {name="default:chest_right", param2=param2}) local m = minetest.get_meta(p) m:set_string("formspec", "size[9,11.5]".. @@ -214,7 +179,7 @@ minetest.register_node("default:chest_left", { "list[current_player;main;0,4;9,3;9]".. "list[current_player;main;0,7.5.5;9,1;]") meta:set_string("infotext", "Chest") - hacky_swap_node(p, "default:chest") + minetest.swap_node(p, {name="default:chest", param2=param2}) end, after_dig_node = function(pos, oldnode, oldmetadata, digger) local meta = minetest.get_meta(pos) @@ -269,7 +234,7 @@ minetest.register_node("default:chest_right", { "list[current_player;main;0,4;9,3;9]".. "list[current_player;main;0,7.5.5;9,1;]") meta:set_string("infotext", "Chest") - hacky_swap_node(p, "default:chest") + minetest.swap_node(p, {name="default:chest", param2=param2}) end, after_dig_node = function(pos, oldnode, oldmetadata, digger) local meta = minetest.get_meta(pos)