Cannot get the variable to change...

Get help using Construct 2

Post » Sun Jan 19, 2014 4:39 am

Hello! I'm stuck. I'm trying to generate a random room, but it isn't working...

This is what I have, in a nutshell:


Global.doorVAR = 0

IF system: doorVAR = 0
{set doorVAR = random(15)

THEN: (based on that number, a certain number of doors will appear at north, south, east and west. If I edit the variable directly, this works, but it seems like no matter what I can't get the game to recognize the statement to alter the variable. I've tried EVERYTHING I can think of. I made the condition a given (IF player is visible...), I tried changing it from random to other number (set doorVAR = 4), but even that wouldn't change it.

The only way to change a variable seems to be by changing it in its declaration: (doorVAR = 13) as opposed to a condition that should do the same thing.

I've come so far but this is just not working... What am I doing wrong?
B
11
S
2
G
1
Posts: 172
Reputation: 1,486

Post » Sun Jan 19, 2014 6:28 am

well, it is impossible to tell without seeing your actual code... it could be just about anything.

you may have placed the code somewhere that never actually runs.

Random(15) will return a floating point number between 0 and 14.9999, so the chances of getting an integer are almost zero. If the rest of your code is expecting an integer then use something like Round(Random(15))
or Int(Random(15))+1 if you don't want it to ever pick zero.
B
94
S
33
G
20
Posts: 438
Reputation: 17,615

Post » Sun Jan 19, 2014 10:11 am

Dude, it worked, and it's amazing. My random dungeon room is all setup thanks to you. Take it easy.
B
11
S
2
G
1
Posts: 172
Reputation: 1,486


Return to How do I....?

Who is online

Users browsing this forum: Malhog and 18 guests