Light Switch Timer Program, Momentary switch

I am trying to write a program to turn on a light for a time when a motion detector is triggered ( and reset the time on subsequent motion detection )
Some of the above example will be used in the program but i dont see how the original brief of 30 minutes run on is included in your correction.

VAR1 : TIMELFT1 , the time left for the lights to be on
VAR2: TIMEON1 , the time the lights will stay on for each hit of the switch
IN1: LIGHTSW1 , Light switch, momentary contact
OUT1: LIGHT1, the lights

10 IF+ LIGHTSW1 THEN TIMELFT1 = TIMEON1
20 IF INTERVAL( 0:0:01 ) AND TIMELFT1 > 0:0:00 THEN TIMELFT1 = TIMELFT1 - 0:0:01
30 IF TIMELFT1 > 0:0:00 THEN START LIGHT1 ELSE STOP LIGHT1

In line 10, the IF+ catches the pulses on the light switch and resets the timer to the full interval. Line20 decrements the time left timer every second till it hits zero. In line 30, if TIMELFT1 is greater than zero the lights will be on.