vendor upgrade system with old shops

This commit is contained in:
Freeman 2023-08-18 06:19:38 +02:00
parent f2f9cf9fc7
commit c2b42ae51b

@ -27,6 +27,8 @@ local settings = minetest.settings
local shopcraft = core.settings:get_bool("emeraldbank.shop_craft") or true
local formspec_prefix = "emeraldbank:shop_formspec"
local display_node = (settings:get("fancy_vend.display_node") or "mcl_core:glass")
local max_logs = (tonumber(settings:get("fancy_vend.log_max")) or 40)
local autorotate_speed = (tonumber(settings:get("fancy_vend.autorotate_speed")) or 1)
@ -1602,7 +1604,7 @@ minetest.register_craft({
-- Vendor Upgrade System --
---------------------------
local old_vendor_mods = string.split((minetest.setting_get("fancy_vend_old_vendor_mods") or ""), ",")
local old_vendor_mods = string.split((minetest.setting_get("fancy_vend_old_vendor_mods") or "emeraldbank"), ",")
local old_vendor_mods_table = {}
for i in pairs(old_vendor_mods) do
@ -1621,9 +1623,9 @@ local base_upgrade_template = {
sounds = mcl_sounds.node_sound_wood_defaults(),
drop = drop_vendor,
tiles = {
"player_vend.png", "player_vend.png",
"player_vend.png^mcl_core_emerald.png", "player_vend.png^mcl_core_emerald.png",
"player_vend.png^mcl_core_emerald.png", "upgrade_front.png",
"player_vend.png^mcl_core_emerald.png",
"player_vend.png^mcl_core_emerald.png",
"upgrade_front.png",
},
on_place = function(itemstack, placer, pointed_thing)
return ItemStack(drop_vendor.." "..itemstack:get_count())
@ -1648,11 +1650,27 @@ local base_upgrade_template = {
local clear_craft_vendors = {}
if old_vendor_mods_table["emeraldbank"] then
emeraldbank.shop_drop = drop_vendor
emeraldbank.shop_empty_drop = drop_vendor
else
emeraldbank.shop_drop = "emeraldbank:shop"
emeraldbank.shop_empty_drop = "emeraldbank:shop"
local emeraldbank_template = table.copy(base_upgrade_template)
emeraldbank_template.can_dig = function(pos, player)
local pname = player:get_player_name()
local is_admin = core.check_player_privs(pname, {admin_shop=true})
local meta = core.get_meta(pos)
local owner = meta:get_string("owner")
local inv = meta:get_inventory()
return inv:is_empty("stock") and (pname == owner or is_admin)
end
emeraldbank_template.on_rightclick = function(pos, node, clicker, itemstack)
local meta = core.get_meta(pos)
local nodename = core.get_node(pos).name
local owner = meta:get_string("owner")
local pname = clicker:get_player_name()
emeraldbank.get_stonks(pos, clicker)
core.show_formspec(pname, formspec_prefix..core.pos_to_string(pos), emeraldbank.get_shop_fs(pos, clicker))
end
minetest.override_item("emeraldbank:shop", emeraldbank_template)
table.insert(clear_craft_vendors, "emeraldbank:shop")
minetest.override_item("emeraldbank:shop_empty", emeraldbank_template)
table.insert(clear_craft_vendors, "emeraldbank:shop_empty")
end
if old_vendor_mods_table["currency"] then