From f6fb0fe96f2a242a20a9655b8373c22df3fad33c Mon Sep 17 00:00:00 2001 From: Alexander Yakovlev Date: Mon, 28 Mar 2016 11:17:28 +0700 Subject: [PATCH] goBack() now returns to start if it's too early to tell. --- lib/salet.coffee | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/salet.coffee b/lib/salet.coffee index d5a847b..72c7a70 100644 --- a/lib/salet.coffee +++ b/lib/salet.coffee @@ -304,7 +304,11 @@ class Salet # Go back N rooms. It's not an UNDO. # Also, steps = 1 is the current room @goBack = (steps = 2) => - @processClick(@progress.path[@progress.path.length - steps]) + if @progress.path.length > steps + location = @progress.path[@progress.path.length - steps] + else + location = @start + @processClick(location) # Transition between rooms. @doTransitionTo = (newRoomId) =>