Conditional Autorun Script

Ask and answer questions about making games and related topics. Unrelated topics go in that other forum.

Moderators: marionline, SDHawk

Post Reply
splendidland
Red Slime
Posts: 42
Joined: Tue Feb 19, 2013 11:06 am
Contact:

Conditional Autorun Script

Post by splendidland »

Hiya, I'm currently working on a sequence in my game which involves the player stumbling across a hive of monsters and alerting them, initiating a chase sequence in which they swarm after you.

The chase sequence takes place across multiple maps that you have previously visited, and I think the best way to initiate it would be with the autorun script, but obviously it shouldn't activate when you are not being chased, so the script needs to do a check to see if Tag 50 is on before running, if it's off the script should end.

I'm not too sure how the "If" functions work at the moment so I need a bit of help with this, thanks in advance!

-Samanthuel
User avatar
Feenicks
Metal Slime
Posts: 697
Joined: Tue Aug 10, 2010 9:23 pm
Location: ON THE AIR IN THE AIR
Contact:

Post by Feenicks »

If/else statements are set up like this:

Code: Select all

If(condition) then(
#things to do if condition is true
)
#you can add extra 'else if(condition) then()' statements here if you need to
else(
#things to do if condition is false; if there's nothing here, you can leave out the else() statement
)
Hopefully this is useful.
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

Specifically, use the "check tag" command, eg.

Code: Select all

if (check tag(50)) then (...)
User avatar
kylekrack
Liquid Metal Slime
Posts: 1242
Joined: Mon Jun 16, 2014 8:58 am
Location: USA
Contact:

Post by kylekrack »

I learned if statements and other things basically as sentences with weird grammar and punctuation. I could say, "If this tag is true, then run the script. If something else, then don't." Maybe this isn't really helpful, but I found it a good way to make sense of, for example, what Pheonix wrote right there. It at least puts it in perspective.

Also, there are websites like Codecademy that have free tutorials on several different languages, many of them for beginners. I just looked at the JavaScript one and it starts out with explaining if statements. They work differently in syntax than HamsterSpeak, but it's the same idea.
My pronouns are they/them
Ps. I love my wife
Post Reply