Minor changes
|
@ -0,0 +1 @@
|
|||
default
|
7
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
|
||||
|
|
19
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
|
||||
|
|
|
@ -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)
|
||||
|
|
Before Width: | Height: | Size: 438 B |
Before Width: | Height: | Size: 738 B After Width: | Height: | Size: 726 B |
Before Width: | Height: | Size: 672 B After Width: | Height: | Size: 422 B |
Before Width: | Height: | Size: 652 B After Width: | Height: | Size: 493 B |