Page 2 of 2
Re: "Secret Found" simple setup tutorial
Posted: Thu Feb 28, 2013 9:59 pm
by Radar6590
Damonya wrote: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
That's actually a really good idea...
Edit: The fact that this began the second page is awkward and I'm sorry for that. Quoted the post I'm talking about for clarity.
Re: "Secret Found" simple setup tutorial
Posted: Fri Mar 01, 2013 2:43 am
by Marble Mouth
Hi Damonya. Here's a little script that can simplify your job by counting the secrets for you:
Code: Select all
totalSecrets = 0
for l = 1,getMaxLevels() do
for entity in allEntities(l) do
if entity.name == "secret" then
totalSecrets = totalSecrets + 1
end
end
end
which also means that you don't have to update the total when you add or remove a secret, the script will just count the secrets every time you click play in the editor or start a new game with this custom dungeon. I have chosen to make totalSecrets non-local so that it only needs to be calculated once, and the value will persist through saving and loading.
Also, prepositions are often one of the most difficult aspects of English for non-native speakers. This sounds more natural:
Code: Select all
hudPrint( number .. " secrets out of " .. totalSecrets .. " found")
Re: "Secret Found" simple setup tutorial
Posted: Fri Mar 01, 2013 10:38 am
by Damonya
Thank You Marble Mouth.
Just a question. getMaxLevels return the number of level, so the total is the total secrets of all level, not by level ? Is it right ?
Re: "Secret Found" simple setup tutorial
Posted: Sat Mar 02, 2013 12:39 am
by Marble Mouth
You're welcome. That's correct, totalSecrets will include secrets from all levels of your mod.