Your script is kind of weird, since after asking the player if they want to turn on the light (and they say no) it will ask them if they want to turn it off again. Similarly, after initially choosing yes or no they will be asked if they want to turn it the other way around. No offence, but the way that this script is set up doesn't seem to be very good.
Anyway, I've added some parts to your script which tell the game whether the light is on or not. When the light is turned on, flag 0x200 will become set, whereas if it is off, the flag will be cleared. You could also use a variable rather than flags if you want to.