This sounds like simple event-ing, unless I'm missing something.
(Like a reason it needs to be in a script, rather than the event?)
Page 1:
Do some stuff
Turn on Self-Switch A
Page 2: Condition: Self-Switch A is ON, Trigger: Player Touch (or event touch)
Turn on Self-Switch B
Page 3: Condition: Self-Switch B is ON, Trigger: Parallel
Do your parallel processing
Turn on Self Switch C (to go to a new page) OR
Turn off Self Switch B (to go back to previous page)
If it must be in script,
key = [$game_map.map_id, @event_id, "A"]
if $game_self_switches[key] == true
# your code here
end