[RMVX ACE] VARIABLES.

Posts

Pages: 1
I am learning variables and following a tutorial where there are two objects ( I'm using crates) that need to be pushed onto certain tiles that I will change to switches later for completion.
This event is checking for crate one X+Y to be equal to tile one X+Y and crate two X+Y to be equal to tile two X+Y for the solution.
I would like to set this up so that either crate can be set on either tile?
I've done many puzzles in games and it doesn't seem to matter which object ends up on which tile or switch, etc.
Would it just be another separate event checking for crate one X+Y equal to tile two X+Y and crate two X+Y equal to tile one X+Y?
Thanks
So you know how to test an AND condition using conditional branches.
While what you want to do here is an OR condition.

You can use another variable for a count of crates in the correct places, and add 1 to it whenever any crate is moved into position, subtract 1 whenever a crate is moved off (if your puzzle doesn't lock things in place when correctly positioned)

Consider this for each crate:


Set Move Route (this event: move away from player), skip, wait
Control variables X = this event X position
Control variables Y = this event Y position
Conditional branch X == 4:
Conditional branch Y == 2:
# block is in position 1
Conditional branch self switch A is off
# and just moved there
Control self switch A on
Control variables count += 1
end
Exit Event Processing
end
end
Conditional branch X == 3:
Conditional branch Y == 9:
# block is in position 2
Conditional branch self switch A is off
# and just moved there
Control self switch A on
Control variables count += 1
end
Exit Event Processing
end
end
Conditional branch self switch A is on
# not in position, just moved off
Control self switch A off
Control variables count -= 1
end
The above event checks if the crate is either at 4,2 or 3,9. In either case it increases the count variable (to say 1 more crate is correctly positioned), and sets the self switch A (*this* crate is correctly positioned)

The "exit event processing" command stops the later branches being tested, so the crate doesn't switch itself back off again.

The final block tests if the crate was correctly positioned (A is on), but isn't anymore (because neither of the above branches was true).

Having said all of that (which is useful general knowledge), here's an easier way:

On your map, use the region layer to paint a specific region number on all the "correct" spots.
Then use the "get location info" command to find the region number under the event.
Then instead of testing all the possible X,Y positions, you should only need to test the region number.
author=coelocanth
So you know how to test an AND condition using conditional branches.
While what you want to do here is an OR condition.

You can use another variable for a count of crates in the correct places, and add 1 to it whenever any crate is moved into position, subtract 1 whenever a crate is moved off (if your puzzle doesn't lock things in place when correctly positioned)

Consider this for each crate:


Set Move Route (this event: move away from player), skip, wait
Control variables X = this event X position
Control variables Y = this event Y position
Conditional branch X == 4:
Conditional branch Y == 2:
# block is in position 1
Conditional branch self switch A is off
# and just moved there
Control self switch A on
Control variables count += 1
end
Exit Event Processing
end
end
Conditional branch X == 3:
Conditional branch Y == 9:
# block is in position 2
Conditional branch self switch A is off
# and just moved there
Control self switch A on
Control variables count += 1
end
Exit Event Processing
end
end
Conditional branch self switch A is on
# not in position, just moved off
Control self switch A off
Control variables count -= 1
end

The above event checks if the crate is either at 4,2 or 3,9. In either case it increases the count variable (to say 1 more crate is correctly positioned), and sets the self switch A (*this* crate is correctly positioned)

The "exit event processing" command stops the later branches being tested, so the crate doesn't switch itself back off again.

The final block tests if the crate was correctly positioned (A is on), but isn't anymore (because neither of the above branches was true).

Having said all of that (which is useful general knowledge), here's an easier way:

On your map, use the region layer to paint a specific region number on all the "correct" spots.
Then use the "get location info" command to find the region number under the event.
Then instead of testing all the possible X,Y positions, you should only need to test the region number.

Thank you. This is very interesting but I'm new to variables although, I'm understanding what I've been learning. I will study this and when I'm a little more familiar, it will sure be handy.
Thanks , again.
Pages: 1