From b8721f7bd6aca1decb8fceb0948dd152c42673fb Mon Sep 17 00:00:00 2001 From: MoNTE48 Date: Thu, 25 Nov 2021 21:01:05 +0100 Subject: [PATCH] Minor changes --- depends.txt | 1 + init.lua | 7 ++----- shop.lua | 19 +++--------------- shop_functions.lua | 32 +++++++++++++++---------------- textures/exchange_shop_arrow.png | Bin 438 -> 0 bytes textures/shop_front.png | Bin 738 -> 726 bytes textures/shop_side.png | Bin 672 -> 422 bytes textures/shop_top.png | Bin 652 -> 493 bytes 8 files changed, 22 insertions(+), 37 deletions(-) create mode 100644 depends.txt delete mode 100644 textures/exchange_shop_arrow.png diff --git a/depends.txt b/depends.txt new file mode 100644 index 0000000..4ad96d5 --- /dev/null +++ b/depends.txt @@ -0,0 +1 @@ +default diff --git a/init.lua b/init.lua index cddd0ed..64cec19 100644 --- a/init.lua +++ b/init.lua @@ -1,13 +1,10 @@ -if not minetest.get_translator then - error("exchange_shop requires at least Minetest 5.0.0-dev.") -end - exchange_shop = {} exchange_shop.storage_size = 5 * 4 exchange_shop.shopname = "exchange_shop:shop" -- Internationalisaton -exchange_shop.S = minetest.get_translator("exchange_shop") +--exchange_shop.S = minetest.get_translator("exchange_shop") +exchange_shop.S = intllib.make_gettext_pair() exchange_shop.FS = function(...) return minetest.formspec_escape(exchange_shop.S(...)) end diff --git a/shop.lua b/shop.lua index c0c66d7..813dc44 100644 --- a/shop.lua +++ b/shop.lua @@ -18,7 +18,7 @@ local function get_exchange_shop_formspec(mode, pos, meta) "listring[current_player;main]" end local function make_slots(x, y, list, label) - local arrow = "exchange_shop_arrow.png" + local arrow = "default_arrow_bg.png" if list == "cust_ow" then arrow = arrow .. "\\^\\[transformFY" end @@ -79,7 +79,7 @@ local function get_exchange_shop_formspec(mode, pos, meta) ) end - local arrow = "exchange_shop_arrow.png" + local arrow = "default_arrow_bg.png" if mode == "owner_custm" then formspec = (formspec.. "button[7.5,0.2;2.5,0.5;view_stock;" .. FS("Income") .. "]".. @@ -169,7 +169,7 @@ end) minetest.register_node(exchange_shop.shopname, { description = S"Exchange Shop", tiles = { - "shop_top.png", "shop_top.png", + "shop_top.png", "shop_top.png", "shop_side.png","shop_side.png", "shop_side.png", "shop_front.png" }, @@ -261,16 +261,3 @@ minetest.register_craft({ minetest.register_on_leaveplayer(function(player) shop_positions[player:get_player_name()] = nil end) - -if minetest.get_modpath("wrench") and wrench then - local STRING = wrench.META_TYPE_STRING - wrench:register_node("exchange_shop:shop", { - lists = {"stock", "custm", "custm_ej", "cust_ow", "cust_og", "cust_ej"}, - metas = { - owner = STRING, - infotext = STRING, - title = STRING, - }, - owned = true - }) -end diff --git a/shop_functions.lua b/shop_functions.lua index 9e69d71..9157e38 100644 --- a/shop_functions.lua +++ b/shop_functions.lua @@ -20,7 +20,7 @@ function exchange_shop.list_contains_item(inv, listname, stack) local list = inv:get_list(listname) local name = stack:get_name() local wear = stack:get_wear() - for _, list_stack in pairs(list) do + for _, list_stack in ipairs(list) do if list_stack:get_name() == name and list_stack:get_wear() <= wear then if list_stack:get_count() >= count then @@ -45,7 +45,7 @@ function exchange_shop.list_remove_item(inv, listname, stack) local remaining = wanted local removed_wear = 0 - for index, list_stack in pairs(list) do + for index, list_stack in ipairs(list) do if list_stack:get_name() == name and list_stack:get_wear() <= wear then local taken_stack = list_stack:take_item(remaining) @@ -76,35 +76,35 @@ function exchange_shop.exchange_action(player_inv, shop_inv) local owner_gives = shop_inv:get_list("cust_og") -- Check validness of stack "owner wants" - for i1, item1 in pairs(owner_wants) do + for i1, item1 in ipairs(owner_wants) do local name1 = item1:get_name() - for i2, item2 in pairs(owner_wants) do + for i2, item2 in ipairs(owner_wants) do if name1 == "" then break end if i1 ~= i2 and name1 == item2:get_name() then - return S("The field '@1' can not contain multiple times the same items.", S("You need")) .. " " .. - S("Please contact the shop owner.") + return S("The field '@1' can not contain multiple times the same items.", + S("You need")) .. " " .. S("Please contact the shop owner.") end end end -- Check validness of stack "owner gives" - for i1, item1 in pairs(owner_gives) do + for i1, item1 in ipairs(owner_gives) do local name1 = item1:get_name() - for i2, item2 in pairs(owner_gives) do + for i2, item2 in ipairs(owner_gives) do if name1 == "" then break end if i1 ~= i2 and name1 == item2:get_name() then - return S("The field '@1' can not contain multiple times the same items.", S("You give")) .. " " .. - S("Please contact the shop owner.") + return S("The field '@1' can not contain multiple times the same items.", + S("You give")) .. " " .. S("Please contact the shop owner.") end end end -- Check for space in the shop - for i, item in pairs(owner_wants) do + for _, item in ipairs(owner_wants) do if not shop_inv:room_for_item("custm", item) then return S("The stock in this shop is full.") .. " " .. S("Please contact the shop owner.") @@ -114,21 +114,21 @@ function exchange_shop.exchange_action(player_inv, shop_inv) local list_contains_item = exchange_shop.list_contains_item -- Check availability of the shop's items - for i, item in pairs(owner_gives) do + for _, item in ipairs(owner_gives) do if not list_contains_item(shop_inv, "stock", item) then return S("This shop is sold out.") end end -- Check for space in the player's inventory - for i, item in pairs(owner_gives) do + for _, item in ipairs(owner_gives) do if not player_inv:room_for_item("main", item) then return S("You do not have enough space in your inventory.") end end -- Check availability of the player's items - for i, item in pairs(owner_wants) do + for _, item in ipairs(owner_wants) do if not list_contains_item(player_inv, "main", item) then return S("You do not have the required items.") end @@ -138,7 +138,7 @@ function exchange_shop.exchange_action(player_inv, shop_inv) -- Conditions are ok: (try to) exchange now local fully_exchanged = true - for i, item in pairs(owner_wants) do + for _, item in ipairs(owner_wants) do local stack = list_remove_item(player_inv, "main", item) if shop_inv:room_for_item("custm", stack) then shop_inv:add_item("custm", stack) @@ -148,7 +148,7 @@ function exchange_shop.exchange_action(player_inv, shop_inv) fully_exchanged = false end end - for i, item in pairs(owner_gives) do + for _, item in ipairs(owner_gives) do local stack = list_remove_item(shop_inv, "stock", item) if player_inv:room_for_item("main", stack) then player_inv:add_item("main", stack) diff --git a/textures/exchange_shop_arrow.png b/textures/exchange_shop_arrow.png deleted file mode 100644 index 4d316d7134045875abea0b3171093b827b755ec8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 438 zcmV;n0ZIOeP) zFGvGX9LM)IML`*gSTtD#!!U`~Rim&dW~;#rD|6K>NO5 z7-)F4S{(2G8;!0pQ89tX!1h9ZSL(V|GJ@yRN$gxJe5D@2ysAHq7+bk`lm4 zuV+?KQUnM*&s+JOIrjTQL~LVBshearo84DRt^KtoBKJV0$G;*M_h!85GT~{|^Rk&C gGZGjHj0A?x7n`Au6}md-pa1{>07*qoM6N<$f*VJ{I{*Lx diff --git a/textures/shop_front.png b/textures/shop_front.png index 9401c9a115244626af24e7c1078a866cf7e3de1e..d8c9c272689dbf6ccf2ab1c8044d2146f823d109 100644 GIT binary patch literal 726 zcmV;{0xA88P)kWJemahC-)* zJDPYjpP!%S=jY?&3&9jOWF)fQT_F^>&yTKA{k{?l1~D{`N1)wthR{1nWVrol#)28NTE(mHKX{D z&olUCjsNaQ6M#e}1)z88L~5fuR&O6u%M3Qnif`P8^vottxa9?o;)!aSQ( zV1Tx(EBH+S7+3c`!%r5Y8ar5Y8arMd^_Z~>Qa1?P~KYE+PxYE+PxYE;l9)oZwcBe23|srrIu zsrrIusrrIusoKxm2W+iLs@hONNg*p$-D?$;`^!bhO4XjUc~F6^TAq@sP!tnO_33df zDMzH-``{afth+xjWNmJ~cgX7AJ!ExV$_JoKse-P{_`uMRW&cuWbeo%1A1Em)I3M(V z#s|iZa6TA@q3Q#ddLN8q)d!@7*FKm?yQ&Ws#monv{n0h!9*Z$&cXVLS0RR9107*qo IM6N<$f{)ZtCIA2c literal 738 zcmV<80v-K{P)mGA<}ZXRVn} zlT4Re18-{YthbHoRp2{w^PBGyNogWxFmB!Ysn^QtSNXXVUW-YU`hLI2m1nU_gJ&b~Z0w5Fu zhrks^hlJRA#z06OS3QL+I%usV?%Iu?2%{oXqxZhlJ+;13RhKr_syfkMdz7-z$waRe7-Ev8gzSvR88Jo?kxvnWz3dzW9W4i68Hj*bvNvMx)_yI2w&kPEK6c1!qLA(j-Adpp>6I z8B+o1ObqVMx1YWL>DSJ=q9`Vl$;l7bK}wzFDD!On62=IO^Luw6AaLgcAs7Qb{Oz?* zzPL>Yxq0nf7kpE9#zo!l>rB1<=IfB;#qgD@&N+r&00+U-vj6M-uZVXqymV!`v=`@d zj9BC<&GQ&Nc)MyAc2zIVFY48*%>k7ZgmUYGl7d85l$rA}dc;66c0f5}l;|~0gRit; zz#H2EBpIWbQeEe&YMnBsWFmnOL?DR4E|>KpO*4nQYg>rkH_hC%nbNwK{y#k}d%5IV zWSW8mzj*xN8=LFfSCcedp8jKO7mR)J<(+>Y{n0GUGuzLZ<-A?3(q2gjF8+S_6fP!i U%0~kJ-~a#s07*qoM6N<$f<*^np8x;= diff --git a/textures/shop_side.png b/textures/shop_side.png index 63a35f6be039e54eda8df3be8d9674a6b5012cde..985eca7e85f070e8fe9a7a9ea400e47731327753 100644 GIT binary patch literal 422 zcmV;X0a^ZuP)VMi^vA8ncE%r++(|cr>bb zES+&AEssft0003cNkl6sbe5PtrpgB7~q~}NgORmrfe-GS`uH6JNS6|A2(716oe;rAJC{$C>jG&z+JNI zUSG$08U-ZPfUfKNesIRI15}`be(D1+;WA)ez`V}OJp1=NZ+V$nDo|Eu0Swsp{n#rf zs|VG2k{MvCsg7nf+d4jZ(w=7`3|v0NuX8}@BliK<-eTJh#}#Vq zNJ)Jrn&!`K6bIsHp*mWqjuxt;h3bHo2SUTEJQytxM#}@?!BrlNwhu-D07dgN=qHb* Q)&Kwi07*qoM6N<$f;nBP)&Kwi literal 672 zcmV;R0$=@!P)aL;~3a zATP5pZ|S9~x|Yj1?By@tNMn>6)-Z7)gw$L}#wf=ajXVdSntl``5 zeozchV+v6+Akk7}2xV|QW#Mhxc*FHD&(rfSzDABR9`=NIxQ;PKrDVyZG;0;Yq)_sd zbcj>RM+SgWquai>Pdx5t4z&W-SU5mWO>#7dz_1Fe!cfZu5T`w&)S@lDfn~`o6AC~H zz)?CgTzDv8`)y}kjA6RFt~s-C^CHhzsC_MwqvB|R@e=kNbxjM`w#Esl)*N(y*=oU8 zzka`e^TuyCR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