GML Checking Previous Variables

W

wonkasnout2

Guest
I am making a top down, turn-based strategy game and I need some help.
obj_player has four "free" variables (left ,right, up, and down). These variables are the x or y position of the furthest empty space in a given direction (sight lines I guess), and are updated whenever the player is facing a certain direction

//step
if global.move = true

{

if place_empty(leftfree,y)
{
do {leftfree = leftfree - 50}
until !place_empty(leftfree, y)
}

}

I need a way to have another variable, left_prev, be equal to what leftfree was before it last changed.
Basically I something to happen when leftfree changes.
 

CloseRange

Member
have a variable called left_prev.
Whenever you change leftfree do this:
Code:
left_prev = leftfree;
leftfree = whatever_leftfree_should_be_now;
 
W

wonkasnout2

Guest
have a variable called left_prev.
Whenever you change leftfree do this:
Code:
left_prev = leftfree;
leftfree = whatever_leftfree_should_be_now;

I tried this and it did not work. Maybe I'm putting it in the wrong place.
I think it might be because leftfree is constantly changing.
 
Top