I have identifed the solution, I just need a bit of help now. In regards to StreamSlide's post, I've used this code to change around my modules.lua.
So now the discount function is defined, I'm unsure on how to modify the syntax for buying items.. for example here is a sample code of a normal shop module without the discount attribute.
How do I change the rest of my buyable items module to allow for an extra variable "discount" to something like this:
My modules.lua: http//pastebin.com/5ygMXK6S
(Ignore the top line on this pastebin, my copy pasta game is weak!)
Again, thank you so much to anyone who takes their time to help me!!
The help I've received here is both undeserved and most helpful, I seriously love this forum!
Code:
-- Discount function for postman style quests
local travelDiscounts = {
['letter'] = {price = 3, storage = 60200, value = 1},
}
function StdModule.travelDiscount(player, discounts)
local discountPrice, discount = 0
if type(discounts) == 'string' then
discount = travelDiscounts[discounts]
if discount and player:getStorageValue(discount.storage) >= discount.value then
return discount.price
end
else
for i = 1, #discounts do
discount = travelDiscounts[discounts[i]]
if discount and player:getStorageValue(discount.storage) >= discount.value then
discountPrice = discountPrice + discount.price
end
end
end
return discountPrice
end
So now the discount function is defined, I'm unsure on how to modify the syntax for buying items.. for example here is a sample code of a normal shop module without the discount attribute.
Code:
shopModule:addBuyableItem({'letter'},2597, 8, 'letter')
How do I change the rest of my buyable items module to allow for an extra variable "discount" to something like this:
Code:
shopModule:addBuyableItem({'letter'},2597, 8, 'letter', 'postmanDiscount')
My modules.lua: http//pastebin.com/5ygMXK6S
(Ignore the top line on this pastebin, my copy pasta game is weak!)
Again, thank you so much to anyone who takes their time to help me!!
The help I've received here is both undeserved and most helpful, I seriously love this forum!