NEED HELP WITH MY ALCOVE SCRIPT!
Posted: Tue Aug 12, 2014 12:45 pm
I have written a script for an alcove in my game that requires a skull to be placed there. When the skull is put in the alcove, the script increases the party`s experience points, and prints their names on screen to confirm this. It then also opens a closed door. At first glance, the code seemed to work well. My script is as follows:
function itemPuzzle()
for i in itemPuzzleAlcove:containedItems() do
if i.name == "skull" then
for i=1,4 do
party:getChampion(i):gainExp(250)
for n=1,4 do
local name1 = party:getChampion(n):getName()
hudPrint(""..name1..", has gained experience!")
end
templedooramulet:open()
playSound("secret")
end
else
templedooramulet:close()
end
end
end
I have two problems with this.
1) If I keep taking out and putting back the skull in the alcove, it keeps increasing the experience points. I need someway to terminate the script or stop it working once the skull has been placed into the alcove for the first time.
2) The script prints out all 4 of the party`s names as intended, but for some strange reason it prints out the first champions name again (so 5 names appear on screen). Anyway of fixing this?
Any help greatly appreciated. thanks.
function itemPuzzle()
for i in itemPuzzleAlcove:containedItems() do
if i.name == "skull" then
for i=1,4 do
party:getChampion(i):gainExp(250)
for n=1,4 do
local name1 = party:getChampion(n):getName()
hudPrint(""..name1..", has gained experience!")
end
templedooramulet:open()
playSound("secret")
end
else
templedooramulet:close()
end
end
end
I have two problems with this.
1) If I keep taking out and putting back the skull in the alcove, it keeps increasing the experience points. I need someway to terminate the script or stop it working once the skull has been placed into the alcove for the first time.
2) The script prints out all 4 of the party`s names as intended, but for some strange reason it prints out the first champions name again (so 5 names appear on screen). Anyway of fixing this?
Any help greatly appreciated. thanks.