Use a global or a remote variable and use it as a flag. The state of the flag can be used to toggle the script between opening or closing the exit when you use the "push" command. Here's one of my own scripts using a global as a flag. The important thing to remember is to set your flag to 1 or 0 depending on the last state of the door. For example, if the door is open set your flag to 1, then if your door is closed set your flag to 0. HELP GLOBAL or HELP REMOTE for more details.
Code:
Trigger Intended Assignment: Objects
Trigger Type: Random , Numeric Arg: 100, Arg list: None
Commands:
context %self.id%
if %weather.sunlight% == 3 && !%park_light_on_zone600%
set park_light_on_zone600 1
global park_light_on_zone600
%echo% %self.shortdesc% on the side of the path flickers momentarily as its LED matrix comes to life.
elseif %weather.sunlight% == 1 && %park_light_on_zone600%
set park_light_on_zone600 0
global park_light_on_zone600
%echo% %self.shortdesc% on the side of the path dims as its LED matrix slowly winks out.
elseif %weather.sunlight% == 1 && %park_light_on_zone600% != 0
set park_light_on_zone600 0
global park_light_on_zone600
elseif %weather.sunlight% == 3 && %park_light_on_zone600% != 1
set park_light_on_zone600 1
global park_light_on_zone600
end
Using a flag as a toggle in my code above is probably not really necessary, but I was paranoid about things not working or firing repeatedly instead of only once.