I am in the midsts of making a dungeon to post here and I want to make a shop that uses 1 alcove, a pressure plate and has dialogue with a modified monster.
So far I have got most of this working and the first item is automatically delivered when the correct amount of gold is deposited into the alove. However if I put more gold in and script for this using an if statement it just does not work
Can someone please advise? I am quite new to this scripting LUA so please forgive this script. Also note that I did use parts from around the forum to get it working how I wanted it. Its great so far but I need to check for lots options, i.e. if I put 5 gold I get a dagger, if I put 6 gold I get a shield. Here is the code. Please if anyone can help I would be so happy
Code: Select all
-- to add some dialogue :)
traded = false
function Merchant1()
if traded == false then
hudPrint("Greetings!")
hudPrint("I am a trader here.")
hudPrint("please place your item into the alove to receive your item!")
else
hudPrint("At the moment I have nothing to offer")
end
end
function checkAlcoveForItems()
-- Offer
local itemName = "dm_coin_gor_gold"
-- offer alcove
local alcoveID = alcove_offer1
-- checks if the offer alcove has an item
if alcove_offer1:getItemCount() == 0 then
hudPrint("Trade not worked?")
end
-- checks if the offer is equal to the item you want
for i in alcoveID:containedItems() do
if i.name == itemName then
local amount = i:getStackSize()
if (amount == 5) then
hudPrint("Thou art a fine scholar!")
for i in alcove_offer1:containedItems() do
if i.name == "dm_coin_gor_gold" then
i:destroy()
-- spawns the item which you will get
alcove_offer1:addItem(spawn("dagger"))
end
if (amount == 6) then
hudPrint("Thou art a fine scholar!")
for i in alcove_offer1:containedItems() do
if i.name == "dm_coin_gor_gold" then
i:destroy()
-- spawns the item which you will get
alcove_offer1:addItem(spawn("round_shield"))
end
-- else
-- hudPrint("This has not worked!")
end
end
end
end
end
end
end
end
end