Cheat Console

Get help using Construct 2

Post » Tue Dec 11, 2012 10:47 pm

I'm trying to make a console that I can use to directly manipulate variables in game. I can easily set something up when it involves just one word, but I'm a bit clueless on how to have two words describe a variable and a value to set it to (eg. "DestroyAlEnemies" vs. "SetLives 10"). Any help would be much appreciated
B
4
Posts: 2
Reputation: 329

Post » Tue Dec 11, 2012 11:44 pm

You can use the tokenAt(text, index, seperator) expression to split up strings.

tokenAt("SetLives 10", 0, " ") = "SetLives"
and
tokenAt("SetLives 10", 1, " ") = "10"

So:

if tokenAt(input.Text, 0, " ") = "SetLives"
then set lives to int(tokenAt(input.Text, 1, " "))
B
54
S
28
G
18
Posts: 1,520
Reputation: 25,020

Post » Wed Dec 12, 2012 12:10 am

Thanks. After testing some things, I was able to pass the string to an array and call from it to get the command. I think I'll go with your method since it's a lot cleaner, though.
B
4
Posts: 2
Reputation: 329


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 16 guests