How do I return variable name as string?

Get help using Construct 2

Post » Thu Dec 04, 2014 4:32 pm

Is it possible to convert a variable name into a string? Here's what I'm attempting to do with proximity checks. Based on if a boolean is true, it would append its variable name to a string variable. This long string would then be used to call one of many functions. Example:

prox_Wall=true
prox_Floor=false
prox_Ledge=false
prox_Ceiling=true

Run check on all prox_variables to see what is true, remove "prox_" prefix and return string "var2str"

varcheck(prox_)=var2str

If function exists, run func_action(var2str)

--or--

varcheck(prox_)=WallCeiling

If function exists, run func_action(WallCeiling)

Or something like that. I suppose also, is it possible to query what variables are available, or would this be better to store all this in an array?
B
6
S
2
Posts: 21
Reputation: 494

Post » Thu Dec 04, 2014 4:45 pm

Nope. No way to reference the variable name.
Best method would be to use an array where the indices are the variable names arrayAt(0) = prox_wall, etc.
Use them in a container for automatic picking, or better yet use a string in a variable using tokenAt() with the method above.
Image ImageImage
B
169
S
50
G
173
Posts: 8,321
Reputation: 110,286

Post » Thu Dec 04, 2014 4:47 pm

Cool, thanks for the speedy reply!
B
6
S
2
Posts: 21
Reputation: 494


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 29 guests