[shop] make two separate prices for privs shop, formspec update

This commit is contained in:
elite 2017-08-01 21:31:34 -04:00
parent 91faa71432
commit b68a753a50
2 changed files with 19 additions and 16 deletions

View File

@ -1,26 +1,27 @@
-- Privs Shop -- Privs Shop
-- Global privs shop price, settable by /shop -- Global privs shop price, settable by /shop
shop.price = 1 shop.price1 = 2
shop.price2 = 8
-- Formspec -- Formspec
function shop.setform(pos) function shop.setform(pos)
local spos = pos.x..","..pos.y..","..pos.z local spos = pos.x..","..pos.y..","..pos.z
local formspec = local formspec =
"size[8,6]" .. "size[8,7]" ..
default.gui_bg .. default.gui_bg ..
default.gui_bg_img .. default.gui_bg_img ..
default.gui_slots .. default.gui_slots ..
"label[0,0;Priv Shop]" .. "label[3.3,0;Privs Shop]" ..
"label[2.45,0.25;Fly]" .. "label[2,0.4;Fly]" ..
"label[4.45,0.25;Fast]" .. "label[5,0.4;Fast]" ..
"list[nodemeta:" ..spos.. ";fly;2.5,0.75;1,1;]" .. "list[nodemeta:" ..spos.. ";fly;2,1;1,1;]" ..
"list[nodemeta:" ..spos.. ";fast;4.5,0.75;1,1;]" .. "list[nodemeta:" ..spos.. ";fast;5,1;1,1;]" ..
"item_image[2.5,0.75;1,1;shop:coin]" .. "item_image[2,1;1,1;shop:coin]" ..
"item_image[4.5,0.75;1,1;shop:coin]" .. "item_image[5,1;1,1;shop:coin]" ..
"label[2.45,1.75;" .. shop.price .. " sec/$]" .. "label[2,2;" .. shop.price1 .. " Coin per second]" ..
"label[4.45,1.75;" .. shop.price .. " sec/$]" .. "label[5,2;" .. shop.price2 .. " Coins per second]" ..
"list[current_player;main;0,2.25;8,4;]" "list[current_player;main;0,3;8,4;]"
return formspec return formspec
end end
@ -32,7 +33,7 @@ function shop.buy(pos, listname, index, stack, player)
local count = stack:get_count() local count = stack:get_count()
inv:remove_item("fly", stack) inv:remove_item("fly", stack)
local name = player:get_player_name() local name = player:get_player_name()
local time = count * shop.price local time = count / shop.price1
local q = playereffects.get_player_effects(name) local q = playereffects.get_player_effects(name)
for i=1, #q do for i=1, #q do
@ -49,7 +50,7 @@ function shop.buy(pos, listname, index, stack, player)
local count = stack:get_count() local count = stack:get_count()
inv:remove_item("fast", stack) inv:remove_item("fast", stack)
local name = player:get_player_name() local name = player:get_player_name()
local time = count * shop.price local time = count / shop.price2
local q = playereffects.get_player_effects(name) local q = playereffects.get_player_effects(name)
for i=1, #q do for i=1, #q do
@ -141,7 +142,8 @@ playereffects.register_effect_type("fast", "Fast mode available", nil, {"fast"},
false, false,
false) false)
--Lets do this via code instead since there are now two different prices.
--[[
-- /shop chat command registration -- /shop chat command registration
minetest.register_chatcommand("shop", { minetest.register_chatcommand("shop", {
params = "<price>", params = "<price>",
@ -157,6 +159,7 @@ minetest.register_chatcommand("shop", {
end end
end end
}) })
--]]
minetest.register_craft({ minetest.register_craft({
output = "shop:privs", output = "shop:privs",

View File

@ -168,7 +168,7 @@ minetest.register_craftitem("shop:coin", {
-- Crafts & Craft Items -- Crafts & Craft Items
minetest.register_craft({ minetest.register_craft({
output = "shop:coin 9", output = "shop:coin 4",
recipe = { recipe = {
{"default:gold_ingot"}, {"default:gold_ingot"},
} }