giveing exp. to players for finding secret

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
Post Reply
dukester70
Posts: 21
Joined: Thu May 16, 2013 11:31 pm

giveing exp. to players for finding secret

Post by dukester70 »

im really needing help with this i either get stackoverflow or i get a nil value
dukester70
Posts: 21
Joined: Thu May 16, 2013 11:31 pm

Re: giveing exp. to players for finding secret

Post 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
User avatar
antti
Posts: 688
Joined: Thu Feb 23, 2012 1:43 pm
Location: Espoo, Finland
Contact:

Re: giveing exp. to players for finding secret

Post 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!
Steven Seagal of gaming industry
dukester70
Posts: 21
Joined: Thu May 16, 2013 11:31 pm

Re: giveing exp. to players for finding secret

Post by dukester70 »

thank you very much very new to scripting now will be trying to give all characters the exp for that...
User avatar
msyblade
Posts: 792
Joined: Fri Oct 12, 2012 4:40 am
Location: New Mexico, USA
Contact:

Re: giveing exp. to players for finding secret

Post 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 :)
Currently conspiring with many modders on the "Legends of the Northern Realms"project.

"You have been captured by a psychopathic diety who needs a new plaything to torture."
Hotel Hades
dukester70
Posts: 21
Joined: Thu May 16, 2013 11:31 pm

Re: giveing exp. to players for finding secret

Post by dukester70 »

thank you for the easier way of doing this :mrgreen:
Post Reply