New upstream version 20210414.1
Julien Puydt
2 years ago
0 | barter = {} | |
0 | currency.barter = {} | |
1 | barter = currency.barter -- Kept as a global variable for compatibility | |
1 | 2 | |
2 | 3 | local S = minetest.get_translator("currency") |
3 | 4 | |
119 | 120 | type = "fixed", |
120 | 121 | fixed = { |
121 | 122 | {-0.500000,0.312500,-0.500000,0.500000,0.500000,0.500000}, |
122 | {-0.437500,-0.500000,-0.437500,-0.250000,0.500000,-0.250000}, | |
123 | {-0.437500,-0.500000,-0.437500,-0.250000,0.500000,-0.250000}, | |
123 | 124 | {-0.437500,-0.500000,0.250000,-0.250000,0.500000,0.437500}, |
124 | 125 | {0.250000,-0.500000,-0.437500,0.437500,0.500000,-0.250000}, |
125 | {0.250000,-0.500000,0.250000,0.437500,0.500000,0.447500}, | |
126 | {0.250000,-0.500000,0.250000,0.437500,0.500000,0.447500}, | |
126 | 127 | }, |
127 | 128 | }, |
128 | 129 | groups = {choppy=2,oddly_breakable_by_hand=2}, |
129 | sounds = default.node_sound_wood_defaults(), | |
130 | sounds = currency.node_sound_wood_defaults(), | |
130 | 131 | on_construct = function(pos) |
131 | 132 | local meta = minetest.get_meta(pos) |
132 | 133 | meta:set_string("infotext", S("Barter Table")) |
0 | minetest.register_craft({ | |
1 | output = 'currency:safe', | |
2 | recipe = { | |
3 | {'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'}, | |
4 | {'default:steel_ingot', 'default:mese_crystal', 'default:steel_ingot'}, | |
5 | {'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'}, | |
6 | } | |
7 | }) | |
0 | if minetest.get_modpath("default") then | |
1 | minetest.register_craft({ | |
2 | output = "currency:safe", | |
3 | recipe = { | |
4 | {"default:steel_ingot", "default:steel_ingot", | |
5 | "default:steel_ingot"}, | |
6 | {"default:steel_ingot", "default:mese_crystal", | |
7 | "default:steel_ingot"}, | |
8 | {"default:steel_ingot", "default:steel_ingot", | |
9 | "default:steel_ingot"}, | |
10 | } | |
11 | }) | |
8 | 12 | |
9 | minetest.register_craft({ | |
10 | output = 'currency:shop', | |
11 | recipe = { | |
12 | {'default:sign_wall'}, | |
13 | {'default:chest_locked'}, | |
14 | } | |
15 | }) | |
13 | minetest.register_craft({ | |
14 | output = "currency:shop", | |
15 | recipe = { | |
16 | {"default:sign_wall"}, | |
17 | {"default:chest_locked"}, | |
18 | } | |
19 | }) | |
16 | 20 | |
17 | minetest.register_craft({ | |
18 | output = 'currency:barter', | |
19 | recipe = { | |
20 | {'default:sign_wall'}, | |
21 | {'default:chest'}, | |
22 | } | |
23 | }) | |
21 | minetest.register_craft({ | |
22 | output = "currency:barter", | |
23 | recipe = { | |
24 | {"default:sign_wall"}, | |
25 | {"default:chest"}, | |
26 | } | |
27 | }) | |
28 | end | |
24 | 29 | |
25 | 30 | minetest.register_craft({ |
26 | 31 | type = "shapeless", |
148 | 153 | type = "shapeless", |
149 | 154 | output = "currency:minegeld_bundle", |
150 | 155 | recipe = { |
151 | "group:minegeld", | |
152 | "group:minegeld", | |
153 | "group:minegeld", | |
154 | "group:minegeld", | |
155 | "group:minegeld", | |
156 | "group:minegeld", | |
157 | "group:minegeld", | |
158 | "group:minegeld", | |
159 | "group:minegeld" | |
156 | "group:minegeld_note", | |
157 | "group:minegeld_note", | |
158 | "group:minegeld_note", | |
159 | "group:minegeld_note", | |
160 | "group:minegeld_note", | |
161 | "group:minegeld_note", | |
162 | "group:minegeld_note", | |
163 | "group:minegeld_note", | |
164 | "group:minegeld_note" | |
160 | 165 | }, |
161 | 166 | }) |
162 | 167 | |
165 | 170 | recipe = "currency:minegeld_bundle", |
166 | 171 | burntime = 1, |
167 | 172 | }) |
168 |
3 | 3 | description = S("@1 Minegeld cent coin", "5"), |
4 | 4 | inventory_image = "minegeld_cent_5.png", |
5 | 5 | stack_max = 1000, |
6 | groups = {minegeld = 1} | |
6 | groups = {minegeld = 1, minegeld_coin = 1} | |
7 | 7 | }) |
8 | 8 | |
9 | 9 | minetest.register_craftitem("currency:minegeld_cent_10", { |
10 | 10 | description = S("@1 Minegeld cent coin", "10"), |
11 | 11 | inventory_image = "minegeld_cent_10.png", |
12 | 12 | stack_max = 1000, |
13 | groups = {minegeld = 1} | |
13 | groups = {minegeld = 1, minegeld_coin = 1} | |
14 | 14 | }) |
15 | 15 | |
16 | 16 | minetest.register_craftitem("currency:minegeld_cent_25", { |
17 | 17 | description = S("@1 Minegeld cent coin", "25"), |
18 | 18 | inventory_image = "minegeld_cent_25.png", |
19 | 19 | stack_max = 1000, |
20 | groups = {minegeld = 1} | |
20 | groups = {minegeld = 1, minegeld_coin = 1} | |
21 | 21 | }) |
22 | 22 | |
23 | 23 | minetest.register_craftitem("currency:minegeld", { |
24 | 24 | description = S("@1 Minegeld Note", "1"), |
25 | 25 | inventory_image = "minegeld.png", |
26 | 26 | stack_max = 65535, |
27 | groups = {minegeld = 1} | |
27 | groups = {minegeld = 1, minegeld_note = 1} | |
28 | 28 | }) |
29 | 29 | |
30 | 30 | minetest.register_craftitem("currency:minegeld_5", { |
31 | 31 | description = S("@1 Minegeld Note", "5"), |
32 | 32 | inventory_image = "minegeld_5.png", |
33 | 33 | stack_max = 65535, |
34 | groups = {minegeld = 1} | |
34 | groups = {minegeld = 1, minegeld_note = 1} | |
35 | 35 | }) |
36 | 36 | |
37 | 37 | minetest.register_craftitem("currency:minegeld_10", { |
38 | 38 | description = S("@1 Minegeld Note", "10"), |
39 | 39 | inventory_image = "minegeld_10.png", |
40 | 40 | stack_max = 65535, |
41 | groups = {minegeld = 1} | |
41 | groups = {minegeld = 1, minegeld_note = 1} | |
42 | 42 | }) |
43 | 43 | |
44 | 44 | minetest.register_craftitem("currency:minegeld_50", { |
45 | 45 | description = S("@1 Minegeld Note", "50"), |
46 | 46 | inventory_image = "minegeld_50.png", |
47 | 47 | stack_max = 65535, |
48 | groups = {minegeld = 1} | |
48 | groups = {minegeld = 1, minegeld_note = 1} | |
49 | 49 | }) |
50 | 50 | |
51 | 51 | minetest.register_craftitem("currency:minegeld_100", { |
52 | 52 | description = S("@1 Minegeld Note", "100"), |
53 | 53 | inventory_image = "minegeld_100.png", |
54 | 54 | stack_max = 65535, |
55 | groups = {minegeld = 1} | |
55 | groups = {minegeld = 1, minegeld_note = 1} | |
56 | 56 | }) |
57 | 57 | |
58 | 58 | minetest.register_craftitem("currency:minegeld_bundle", { |
0 | 0 | local modpath = minetest.get_modpath("currency") |
1 | 1 | |
2 | 2 | minetest.log("info", "Currency mod loading...") |
3 | ||
4 | currency = {} | |
5 | if minetest.global_exists("default") then | |
6 | currency.node_sound_wood_defaults = default.node_sound_wood_defaults | |
7 | else | |
8 | currency.node_sound_wood_defaults = function() end | |
9 | end | |
3 | 10 | |
4 | 11 | dofile(modpath.."/craftitems.lua") |
5 | 12 | minetest.log("info", "[Currency] Craft_items Loaded!") |
2 | 2 | |
3 | 3 | ### barter.lua ### |
4 | 4 | |
5 | Barter Table=Tausch Tisch | |
5 | Barter Table=Handelstisch | |
6 | 6 | Cancel=Abbruch |
7 | 7 | Confirm=Bestätigen |
8 | 8 | Start=Start |
9 | 9 | |
10 | 10 | ### shop.lua ### |
11 | 11 | |
12 | Exchange=Tausch | |
12 | Exchange=Tauschen | |
13 | 13 | |
14 | 14 | ### craftitems.lua ### |
15 | 15 | |
16 | @1 Minegeld Note=@1 Minegeld Banknote | |
17 | @1 Minegeld cent coin= | |
18 | Bundle of random Minegeld notes=Bündel von verschiedenen Minegeld Banknoten | |
16 | @1 Minegeld Note=@1-Minegeld-Banknote | |
17 | @1 Minegeld cent coin=@1-Minegeldcent-Münze | |
18 | Bundle of random Minegeld notes=Bündel mit beliebigen Minegeld-Banknoten | |
19 | 19 | |
20 | 20 | ### safe.lua ### |
21 | 21 | |
22 | Safe=Safe | |
23 | Safe (owned by @1)=Safe (gehört @1) | |
22 | Safe=Tresor | |
23 | Safe (owned by @1)=Tresor (gehört @1) | |
24 | 24 | |
25 | 25 | ### shop.lua ### |
26 | 26 | |
27 | Customer gets:=Kunde bekommt: | |
28 | Customer gives (pay here!)=Kunde gibt (bezahl hier!) | |
27 | Customer gets:=Kunde erhält: | |
28 | Customer gives (pay here!)=Kunde gibt (hier bezahlen!) | |
29 | 29 | Customers gave:=Kunde gab: |
30 | Exchange can not be done, check if you put all items!=Tausch kann nicht abgeschlossen werden, prüfe nochmal alles was du hinein gelegt hast! | |
31 | Exchange can not be done, contact the shop owner.=Tausch kann nicht abgeschlossen werden, benachrichtige den Geschäftsinhaber. | |
30 | Exchange can not be done, check if you put all items!=Tausch kann nicht abgeschlossen werden. Prüfen, ob alle Gegenstände platziert wurden! | |
31 | Exchange can not be done, contact the shop owner.=Tausch kann nicht abgeschlossen werden. Geschäftsinhaber benachrichtigen! | |
32 | 32 | Exchange shop (owned by @1)=Tauschgeschäft (gehört @1) |
33 | 33 | Exchanged!=Getauscht! |
34 | In exchange, you give:=Im Tausch, du gibst: | |
34 | In exchange, you give:=Im Tausch geben Sie: | |
35 | out of stock=Ausverkauft | |
35 | 36 | Owner gives:=Inhaber gibt: |
36 | 37 | Owner wants:=Inhaber will: |
37 | 38 | |
38 | Owner, Use (E)+Place (right mouse button) for customer interface=Inhaber, Benutze (E)+Platziere (rechte Maustaste) für Kunde ... | |
39 | Owner, Use (E)+Place (right mouse button) for customer interface=Inhaber: (E)+Platzieren (rechte Maustaste) drücken für Kundeninterface ... | |
39 | 40 | |
40 | 41 | Shop=Geschäft |
41 | This is your own shop, you can't exchange to yourself!=Das ist dein eigenes Geschäft, du kannst nicht mit dir selbst tauschen! | |
42 | You want:=Du willst: | |
43 | Your stock:=Dein Lager: | |
44 | ||
45 | ||
42 | This is your own shop, you can't exchange to yourself!=Dies ist Ihr eigenes Geschäft, Sie können nicht mit sich selbst tauschen! | |
43 | You want:=Sie wollen: | |
44 | Your stock:=Ihr Lager: |
0 | # textdomain: currency | |
1 | # author: PsycoJaker | |
2 | ||
3 | ||
4 | ### barter.lua ### | |
5 | ||
6 | Barter Table=Mesa de intercambios | |
7 | Cancel=Denegar | |
8 | Confirm=Aceptar | |
9 | Start=Intercambiar | |
10 | ||
11 | ### shop.lua ### | |
12 | ||
13 | Exchange=Trato | |
14 | ||
15 | ### craftitems.lua ### | |
16 | ||
17 | @1 Minegeld Note=Billete de @1 Minegeld | |
18 | @1 Minegeld cent coin= Moneda de @1 Minegeld | |
19 | Bundle of random Minegeld notes=Monton de dinero | |
20 | ||
21 | ### safe.lua ### | |
22 | ||
23 | Safe=Caja fuerte | |
24 | Safe (owned by @1)=Caja fuerte de @1 | |
25 | ||
26 | ### shop.lua ### | |
27 | ||
28 | Customer gets:=Tu compra: | |
29 | Customer gives (pay here!)=Paga aqui | |
30 | Customers gave:=Los compradores ofrecieron: | |
31 | Exchange can not be done, check if you put all items!=La compra ha fallado, comprueba tu pago | |
32 | Exchange can not be done, contact the shop owner.=La compra ha fallado, comunicate con el vendedor | |
33 | Exchange shop (owned by @1)=Tienda de @1 | |
34 | Exchanged!=Comprado | |
35 | In exchange, you give:=Vendes: | |
36 | out of stock=Sin exsitencias | |
37 | Owner gives:=Vendedor ofrece: | |
38 | Owner wants:=Vendedor pide: | |
39 | ||
40 | Owner, Use (E)+Place (right mouse button) for customer interface=Usa, las teclas (especial + boton derecho del raton) para ver a la interfaz del comprador | |
41 | ||
42 | Shop=Tienda | |
43 | This is your own shop, you can't exchange to yourself!=No puedes comprar en tu propia tienda | |
44 | You want:=Tu pides: | |
45 | Your stock:=Tus existencias: |
0 | # textdomain: currency | |
1 | # Saturn, 2020-10-23 | |
2 | ||
3 | ||
4 | ### barter.lua ### | |
5 | ||
6 | Barter Table=Tavolo di baratto | |
7 | Cancel=Annulla | |
8 | Confirm=Conferma | |
9 | Start=Inizia | |
10 | ||
11 | ### shop.lua ### | |
12 | ||
13 | Exchange=Scambia | |
14 | ||
15 | ### craftitems.lua ### | |
16 | ||
17 | @1 Minegeld Note=Banconota da @1 Minegeld | |
18 | @1 Minegeld cent coin=Moneta da @1 centesimo/i Minegeld | |
19 | Bundle of random Minegeld notes=Pacchetto di banconote Minegeld casuali | |
20 | ||
21 | ### safe.lua ### | |
22 | ||
23 | Safe=Cassaforte | |
24 | Safe (owned by @1)=Cassaforte (di proprietà di @1) | |
25 | ||
26 | ### shop.lua ### | |
27 | ||
28 | Customer gets:=Il cliente ottiene: | |
29 | Customer gives (pay here!)=Il cliente dà (paga qui!) | |
30 | Customers gave:=I clienti hanno dato: | |
31 | Exchange can not be done, check if you put all items!=Lo scambio non può essere fatto, controlla di avere messo tutti gli oggetti! | |
32 | Exchange can not be done, contact the shop owner.=Lo scambio non può essere fatto, contatta il proprietario del negozio. | |
33 | Exchange shop (owned by @1)=Negozio di scambio (di proprietà di @1) | |
34 | Exchanged!=Scambiato! | |
35 | In exchange, you give:=In cambio, tu dai: | |
36 | Owner gives:=Il proprietario dà: | |
37 | Owner wants:=Il proprietario vuole: | |
38 | ||
39 | Owner, Use (E)+Place (right mouse button) for customer interface=Proprietario, usa (E)+Posiziona (click destro) per l'UI cliente | |
40 | ||
41 | Shop=Negozio | |
42 | This is your own shop, you can't exchange to yourself!=Questo è il tuo negozio, non puoi fare scambi con te stesso! | |
43 | You want:=Tu vuoi: | |
44 | Your stock:=La tua scorta: |
32 | 32 | Exchange shop (owned by @1)= |
33 | 33 | Exchanged!= |
34 | 34 | In exchange, you give:= |
35 | out of stock= | |
35 | 36 | Owner gives:= |
36 | 37 | Owner wants:= |
37 | 38 |
0 | 0 | name = currency |
1 | depends = default | |
2 | optional_depends = loot, pipeworks | |
1 | optional_depends = default, loot, pipeworks | |
3 | 2 | description = Provides shops, barter tables, safes, and multiple denominations of currency, called "Minegeld". |
4 | 3 | min_minetest_version = 5.2.0 |
0 | 0 | local S = minetest.get_translator("currency") |
1 | 1 | |
2 | function default.get_safe_formspec(pos) | |
2 | function currency.get_safe_formspec(pos) | |
3 | 3 | local spos = pos.x .. "," .. pos.y .. "," ..pos.z |
4 | 4 | local formspec = |
5 | 5 | "size[8,9]".. |
8 | 8 | "listring[nodemeta:".. spos .. ";main]".. |
9 | 9 | "listring[current_player;main]" |
10 | 10 | return formspec |
11 | end | |
12 | ||
13 | if minetest.global_exists("default") then | |
14 | default.get_safe_formspec = currency.get_safe_formspec | |
11 | 15 | end |
12 | 16 | |
13 | 17 | local function has_safe_privilege(meta, player) |
99 | 103 | minetest.show_formspec( |
100 | 104 | clicker:get_player_name(), |
101 | 105 | "currency:safe", |
102 | default.get_safe_formspec(pos) | |
106 | currency.get_safe_formspec(pos) | |
103 | 107 | ) |
104 | 108 | end |
105 | 109 | end, |
0 | 0 | local S = minetest.get_translator("currency") |
1 | 1 | |
2 | default.shop = {} | |
3 | default.shop.current_shop = {} | |
4 | default.shop.formspec = { | |
2 | currency.shop = {} | |
3 | if minetest.global_exists("default") then | |
4 | default.shop = currency.shop | |
5 | end | |
6 | ||
7 | currency.shop.current_shop = {} | |
8 | currency.shop.formspec = { | |
5 | 9 | customer = function(pos) |
6 | 10 | local list_name = "nodemeta:"..pos.x..','..pos.y..','..pos.z |
7 | 11 | local formspec = "size[8,9.5]".. |
36 | 40 | |
37 | 41 | local have_pipeworks = minetest.global_exists("pipeworks") |
38 | 42 | |
39 | default.shop.check_privilege = function(listname,playername,meta) | |
43 | currency.shop.check_privilege = function(listname,playername,meta) | |
40 | 44 | --[[if listname == "pl1" then |
41 | 45 | if playername ~= meta:get_string("pl1") then |
42 | 46 | return false |
55 | 59 | end |
56 | 60 | |
57 | 61 | |
58 | default.shop.give_inventory = function(inv,list,playername) | |
62 | currency.shop.give_inventory = function(inv,list,playername) | |
59 | 63 | player = minetest.get_player_by_name(playername) |
60 | 64 | if player then |
61 | 65 | for k,v in ipairs(inv:get_list(list)) do |
65 | 69 | end |
66 | 70 | end |
67 | 71 | |
68 | default.shop.cancel = function(meta) | |
69 | --[[default.shop.give_inventory(meta:get_inventory(),"pl1",meta:get_string("pl1")) | |
70 | default.shop.give_inventory(meta:get_inventory(),"pl2",meta:get_string("pl2")) | |
72 | currency.shop.cancel = function(meta) | |
73 | --[[currency.shop.give_inventory(meta:get_inventory(),"pl1",meta:get_string("pl1")) | |
74 | currency.shop.give_inventory(meta:get_inventory(),"pl2",meta:get_string("pl2")) | |
71 | 75 | meta:set_string("pl1","") |
72 | 76 | meta:set_string("pl2","") |
73 | 77 | meta:set_int("pl1step",0) |
74 | 78 | meta:set_int("pl2step",0)]] |
75 | 79 | end |
76 | 80 | |
77 | default.shop.exchange = function(meta) | |
78 | --[[default.shop.give_inventory(meta:get_inventory(),"pl1",meta:get_string("pl2")) | |
79 | default.shop.give_inventory(meta:get_inventory(),"pl2",meta:get_string("pl1")) | |
81 | currency.shop.exchange = function(meta) | |
82 | --[[currency.shop.give_inventory(meta:get_inventory(),"pl1",meta:get_string("pl2")) | |
83 | currency.shop.give_inventory(meta:get_inventory(),"pl2",meta:get_string("pl1")) | |
80 | 84 | meta:set_string("pl1","") |
81 | 85 | meta:set_string("pl2","") |
82 | 86 | meta:set_int("pl1step",0) |
83 | 87 | meta:set_int("pl2step",0)]] |
88 | end | |
89 | ||
90 | local check_stock = function( | |
91 | pos | |
92 | ) | |
93 | local meta = minetest.get_meta( | |
94 | pos | |
95 | ) | |
96 | local minv = meta:get_inventory( | |
97 | ) | |
98 | local gives = minv:get_list( | |
99 | "owner_gives" | |
100 | ) | |
101 | local can_exchange = true | |
102 | for i, item in pairs( | |
103 | gives | |
104 | ) do | |
105 | if not minv:contains_item( | |
106 | "stock", | |
107 | item | |
108 | ) then | |
109 | can_exchange = false | |
110 | end | |
111 | end | |
112 | local owner = meta:get_string( | |
113 | "owner" | |
114 | ) | |
115 | if can_exchange then | |
116 | meta:set_string( | |
117 | "infotext", | |
118 | S( | |
119 | "Exchange shop (owned by @1)", | |
120 | owner | |
121 | ) | |
122 | ) | |
123 | local applicable = "currency:shop" | |
124 | local node = minetest.get_node( | |
125 | pos | |
126 | ) | |
127 | if node.name == applicable then | |
128 | return | |
129 | end | |
130 | node.name = applicable | |
131 | minetest.swap_node( | |
132 | pos, | |
133 | node | |
134 | ) | |
135 | else | |
136 | meta:set_string( | |
137 | "infotext", | |
138 | S( | |
139 | "Exchange shop (owned by @1)", | |
140 | owner | |
141 | ) .. ", " .. S( | |
142 | "out of stock" | |
143 | ) | |
144 | ) | |
145 | local applicable = "currency:shop_empty" | |
146 | local node = minetest.get_node( | |
147 | pos | |
148 | ) | |
149 | if node.name == applicable then | |
150 | return | |
151 | end | |
152 | node.name = applicable | |
153 | minetest.swap_node( | |
154 | pos, | |
155 | node | |
156 | ) | |
157 | end | |
84 | 158 | end |
85 | 159 | |
86 | 160 | minetest.register_node("currency:shop", { |
94 | 168 | "shop_front.png"}, |
95 | 169 | inventory_image = "shop_front.png", |
96 | 170 | groups = {choppy=2,oddly_breakable_by_hand=2,tubedevice=1,tubedevice_receiver=1}, |
97 | sounds = default.node_sound_wood_defaults(), | |
171 | sounds = currency.node_sound_wood_defaults(), | |
98 | 172 | after_place_node = function(pos, placer, itemstack) |
99 | 173 | local owner = placer:get_player_name() |
100 | 174 | local meta = minetest.get_meta(pos) |
108 | 182 | inv:set_size("owner_wants", 3*2) |
109 | 183 | inv:set_size("owner_gives", 3*2) |
110 | 184 | if have_pipeworks then pipeworks.after_place(pos) end |
185 | check_stock( | |
186 | pos | |
187 | ) | |
111 | 188 | end, |
112 | 189 | after_dig_node = (have_pipeworks and pipeworks and pipeworks.after_dig), |
113 | 190 | tube = { |
114 | 191 | insert_object = function(pos, node, stack, direction) |
115 | 192 | local meta = minetest.get_meta(pos) |
116 | 193 | local inv = meta:get_inventory() |
117 | return inv:add_item("stock",stack) | |
194 | local result = inv:add_item("stock",stack) | |
195 | check_stock( | |
196 | pos | |
197 | ) | |
198 | return result | |
118 | 199 | end, |
119 | 200 | can_insert = function(pos,node,stack,direction) |
120 | 201 | local meta = minetest.get_meta(pos) |
127 | 208 | on_rightclick = function(pos, node, clicker, itemstack) |
128 | 209 | clicker:get_inventory():set_size("customer_gives", 3*2) |
129 | 210 | clicker:get_inventory():set_size("customer_gets", 3*2) |
130 | default.shop.current_shop[clicker:get_player_name()] = pos | |
211 | currency.shop.current_shop[clicker:get_player_name()] = pos | |
131 | 212 | local meta = minetest.get_meta(pos) |
132 | 213 | if clicker:get_player_name() == meta:get_string("owner") and not clicker:get_player_control().aux1 then |
133 | minetest.show_formspec(clicker:get_player_name(),"currency:shop_formspec",default.shop.formspec.owner(pos)) | |
214 | minetest.show_formspec(clicker:get_player_name(),"currency:shop_formspec",currency.shop.formspec.owner(pos)) | |
134 | 215 | else |
135 | minetest.show_formspec(clicker:get_player_name(),"currency:shop_formspec",default.shop.formspec.customer(pos)) | |
216 | minetest.show_formspec(clicker:get_player_name(),"currency:shop_formspec",currency.shop.formspec.customer(pos)) | |
136 | 217 | end |
137 | 218 | end, |
138 | 219 | allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) |
150 | 231 | if player:get_player_name() ~= meta:get_string("owner") then return 0 end |
151 | 232 | return stack:get_count() |
152 | 233 | end, |
234 | on_metadata_inventory_move = check_stock, | |
235 | on_metadata_inventory_put = check_stock, | |
236 | on_metadata_inventory_take = check_stock, | |
237 | can_dig = function(pos, player) | |
238 | local meta = minetest.get_meta(pos) | |
239 | local inv = meta:get_inventory() | |
240 | return inv:is_empty("stock") and inv:is_empty("customers_gave") and inv:is_empty("owner_wants") and inv:is_empty("owner_gives") | |
241 | end | |
242 | }) | |
243 | ||
244 | minetest.register_node("currency:shop_empty", { | |
245 | description = S("Shop") .. " (" .. S("out of stock") .. ")", | |
246 | paramtype2 = "facedir", | |
247 | tiles = {"shop_top.png", | |
248 | "shop_top.png", | |
249 | "shop_side_empty.png", | |
250 | "shop_side_empty.png", | |
251 | "shop_side_empty.png", | |
252 | "shop_front_empty.png"}, | |
253 | drop = "currency:shop", | |
254 | groups = {choppy=2,oddly_breakable_by_hand=2,tubedevice=1,tubedevice_receiver=1,not_in_creative_inventory=1}, | |
255 | sounds = currency.node_sound_wood_defaults(), | |
256 | after_dig_node = (have_pipeworks and pipeworks and pipeworks.after_dig), | |
257 | tube = { | |
258 | insert_object = function(pos, node, stack, direction) | |
259 | local meta = minetest.get_meta(pos) | |
260 | local inv = meta:get_inventory() | |
261 | local result = inv:add_item("stock",stack) | |
262 | check_stock( | |
263 | pos | |
264 | ) | |
265 | return result | |
266 | end, | |
267 | can_insert = function(pos,node,stack,direction) | |
268 | local meta = minetest.get_meta(pos) | |
269 | local inv = meta:get_inventory() | |
270 | return inv:room_for_item("stock", stack) | |
271 | end, | |
272 | input_inventory = "customers_gave", | |
273 | connect_sides = {left = 1, right = 1, back = 1, front = 1, bottom = 1, top = 1} | |
274 | }, | |
275 | on_rightclick = function(pos, node, clicker, itemstack) | |
276 | clicker:get_inventory():set_size("customer_gives", 3*2) | |
277 | clicker:get_inventory():set_size("customer_gets", 3*2) | |
278 | currency.shop.current_shop[clicker:get_player_name()] = pos | |
279 | local meta = minetest.get_meta(pos) | |
280 | if clicker:get_player_name() == meta:get_string("owner") and not clicker:get_player_control().aux1 then | |
281 | minetest.show_formspec(clicker:get_player_name(),"currency:shop_formspec",currency.shop.formspec.owner(pos)) | |
282 | else | |
283 | minetest.show_formspec(clicker:get_player_name(),"currency:shop_formspec",currency.shop.formspec.customer(pos)) | |
284 | end | |
285 | end, | |
286 | allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) | |
287 | local meta = minetest.get_meta(pos) | |
288 | if player:get_player_name() ~= meta:get_string("owner") then return 0 end | |
289 | return count | |
290 | end, | |
291 | allow_metadata_inventory_put = function(pos, listname, index, stack, player) | |
292 | local meta = minetest.get_meta(pos) | |
293 | if player:get_player_name() ~= meta:get_string("owner") then return 0 end | |
294 | return stack:get_count() | |
295 | end, | |
296 | allow_metadata_inventory_take = function(pos, listname, index, stack, player) | |
297 | local meta = minetest.get_meta(pos) | |
298 | if player:get_player_name() ~= meta:get_string("owner") then return 0 end | |
299 | return stack:get_count() | |
300 | end, | |
301 | on_metadata_inventory_move = check_stock, | |
302 | on_metadata_inventory_put = check_stock, | |
303 | on_metadata_inventory_take = check_stock, | |
153 | 304 | can_dig = function(pos, player) |
154 | 305 | local meta = minetest.get_meta(pos) |
155 | 306 | local inv = meta:get_inventory() |
160 | 311 | minetest.register_on_player_receive_fields(function(sender, formname, fields) |
161 | 312 | if formname == "currency:shop_formspec" and fields.exchange ~= nil and fields.exchange ~= "" then |
162 | 313 | local name = sender:get_player_name() |
163 | local pos = default.shop.current_shop[name] | |
314 | local pos = currency.shop.current_shop[name] | |
164 | 315 | local meta = minetest.get_meta(pos) |
165 | 316 | if meta:get_string("owner") == name then |
166 | 317 | minetest.chat_send_player(name, S("This is your own shop, you can't exchange to yourself!")) |
201 | 352 | pinv:add_item("customer_gets",item) |
202 | 353 | end |
203 | 354 | minetest.chat_send_player(name, S("Exchanged!")) |
355 | check_stock( | |
356 | pos | |
357 | ) | |
204 | 358 | else |
205 | 359 | if owners_fault then |
206 | 360 | minetest.chat_send_player(name, S("Exchange can not be done, contact the shop owner.")) |
211 | 365 | end |
212 | 366 | end |
213 | 367 | end) |
214 |
Binary diff not shown
Binary diff not shown