Page 1 of 2
"Secret Found" simple setup tutorial
Posted: Thu Oct 04, 2012 5:28 pm
by Komag
When I want a secret in my dungeon, here is one way to manually set it all up:
- Place an S "secret" item (this is just for the statistical purpose I believe)
- place a hidden pressure plate (only triggered by party and set to "activate once")
- place a script item:
Code: Select all
function foundthesecret()
playSound("secret")
hudPrint("Secret Found")
end
- connect the plate to the script with "foundthesecret"
I couldn't find any shortcut to this, no settings for the S "secret" item. I guess there needs to be flexibility, so manual it must be.
The sound and the hudPrint could be triggered by anything, but I'm just guessing that to have the secret properly accounted for in the game statistics, you must place the S and step in that square for the S to be counted.
(I also have noticed that functions can't have underscores _ in the name. I can't call it found_secret() for example)
EDIT - NEVER MIND ALL THAT!
Just:
- Place an S "secret" item
- place a hidden pressure plate (only triggered by party)
- connect the plate to the S with activate
The S will only activate once no matter how many times you step there. Activating the S is probably the only way to properly account for the secret being found
Re: "Secret Found" simple setup tutorial
Posted: Thu Oct 04, 2012 5:38 pm
by djoldgames
Komag wrote:When I want a secret in my dungeon, here is one way to manually set it all up:
And what about this if you have secret entity with ID=secret_1 ?
Code: Select all
function foundthesecret()
secret_1:activate()
end
This automaticaly play the secret sound and print the message, and of course increase system secrets counter for statistic...
Re: "Secret Found" simple setup tutorial
Posted: Thu Oct 04, 2012 5:38 pm
by Grimwold
I usually use a connector instead of a script, but this works too. Thanks.
I didn't realise you couldn't have underscores... thought it was just a convention to use camel-case for function names... e.g. foundSecret()
Re: "Secret Found" simple setup tutorial
Posted: Thu Oct 04, 2012 6:09 pm
by Komag
djoldgames wrote:And what about this if you have secret entity with ID=secret_1 ?
Code: Select all
function foundthesecret()
secret_1:activate()
end
This automaticaly play the secret sound and print the message, and of course increase system secrets counter for statistic...
I had no idea! Well then to heck with the script and everything, just link the plate to the secret! (why didn't I try that first?!?)
And that's probably the only way to get it to count it for the stats anyway (I was just guessing about stepping on it)
FIRST POST EDITED!
Re: "Secret Found" simple setup tutorial
Posted: Thu Oct 04, 2012 6:40 pm
by Obyvvatel
I think you can just ignore the "activate once" thingy. The secret will activate only one time

Re: "Secret Found" simple setup tutorial
Posted: Thu Oct 04, 2012 6:46 pm
by Lyverbe
Grimwold wrote:I usually use a connector instead of a script, but this works too. Thanks.
I didn't realise you couldn't have underscores... thought it was just a convention to use camel-case for function names... e.g. foundSecret()
That's what I've always done too. No need to script anything.
Re: "Secret Found" simple setup tutorial
Posted: Thu Oct 04, 2012 6:49 pm
by Komag
Obyvvatel wrote:I think you can just ignore the "activate once" thingy. The secret will activate only one time

ah, good to know
Re: "Secret Found" simple setup tutorial
Posted: Thu Feb 28, 2013 1:27 pm
by Damonya
Hello,
I am looking for a script solution, so that when you find a secret this mark: 1 to X secret found (2 to x etc...). X is the total. Or better yet, that the mark only when you go on a healing crystal or at the end of each level (whatever).
Perhaps by incrementing a counter every secret. But I prefere a simple solution with the hidden plate and the S marker rather than a big script, but it may not be possible. Any ideas?
PS : I'm french, sorry for my bad english.
EDIT : There is no connector with the S marker and the healing crystal. So at the end of each level with a hidden plate is the best solution I think. So with each hidden_secret_plate I incremente a counter in script. And I get the number of the counter whith the hidden plate at the end of my level. Am I right?
Re: "Secret Found" simple setup tutorial
Posted: Thu Feb 28, 2013 3:43 pm
by antti
Damonya wrote:EDIT : There is no connector with the S marker and the healing crystal. So at the end of each level with a hidden plate is the best solution I think. So with each hidden_secret_plate I incremente a counter in script. And I get the number of the counter whith the hidden plate at the end of my level. Am I right?
Yeah, this sounds like a good solution to me.
Re: "Secret Found" simple setup tutorial
Posted: Thu Feb 28, 2013 6:26 pm
by Damonya
Ok I tested and it's fine. Very easy in fact.
- Create a counter (Initial value = 0)
- Connect all your pressure_plate_hidden to their S secret and to this counter. Check "Activate once" otherwise the counter increment several times.
- Calcul the number of all your secret. Example 10.
- Create a pressure_plate_hidden at the end of your level (or what you want) and connect to a script with this function :
Code: Select all
function CounterSecret()
local number = counter:getValue()
hudPrint(number.. " secrets to 10 found")
end