Page 1 of 1
giveing exp. to players for finding secret
Posted: Wed May 29, 2013 9:04 am
by dukester70
im really needing help with this i either get stackoverflow or i get a nil value
Re: giveing exp. to players for finding secret
Posted: Wed May 29, 2013 9:14 am
by dukester70
function openSecretDoor()
if specialbutton:getPush() == "true" and
party:getChampion(1):getEnabled() == "true" then
party:getChampion(1):gainExp(300)
local name1 = party:getChampion(1):getName()
hudPrint("..name1..","gained 300 experience.")
specialsecretdoor:open()
else specialsecretdoor:close()
break
end
end
so i either get overstack ora nil value for push
Re: giveing exp. to players for finding secret
Posted: Wed May 29, 2013 11:35 am
by antti
There's a few problems I can spot here. Here's a cleaned up version of the script:
Code: Select all
function openSecretDoor()
if party:getChampion(1):getEnabled() == true then
party:getChampion(1):gainExp(300)
local name1 = party:getChampion(1):getName()
hudPrint(name1.. "gained 300 experience.")
specialsecretdoor:open()
else
specialsecretdoor:close()
end
end
First is the getPush() -function. Our buttons don't have such a function and if this script is triggered by pressing the same button, this wouldn't be needed in the first place. If. however, you want to check that some button is pressed, you need to store the information in a variable, for example like this:
Code: Select all
isButtonPressed = false
-- the button is connected to this function
function pressButton()
isButtonPressed = true
end
And then you can check if that variable is true or false. But anyways, back to the original script... Another mistake was that there were quotation marks ("") around the boolean values. If you have quotes around some variable, then it is a string and for example party:getChampion(1):getEnabled() == "true" will always return false (since getEnabled will only return true or false but never "true") whereas party:getChampion(1):getEnabled() == true will do what is expected. The hudPrint also had some confusion with quotes so I cleaned it up too.
I'm not sure if my version of the script will do what you were looking for but I hope this points you to the right direction!
Re: giveing exp. to players for finding secret
Posted: Wed May 29, 2013 7:21 pm
by dukester70
thank you very much very new to scripting now will be trying to give all characters the exp for that...
Re: giveing exp. to players for finding secret
Posted: Thu May 30, 2013 5:43 am
by msyblade
Here you go dukester
Code: Select all
function exp()
hudPrint ("Gained 250 exp.")
for i=1,4 do
party:getChampion(i):gainExp(250)
end
end
Be VERY careful with this, it will open many exp exploits/loops. You can just place one per level and connect to it as many times as you like, but make sure any trigger is either set to activate once, or attached to a counter set to 1, so it cannot be triggered a second time

Re: giveing exp. to players for finding secret
Posted: Thu May 30, 2013 6:54 am
by dukester70
thank you for the easier way of doing this
