From b3b5448f9da0e9491356bfabd2e2b6aee51924dd Mon Sep 17 00:00:00 2001 From: "p.kosyh" Date: Sun, 11 Jul 2010 17:59:45 +0000 Subject: [PATCH] back vs goback, pl:back deprecated --- stead/goto.lua | 32 ++++++++++++++++++++++++++++++-- stead/stead.lua | 5 ++++- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/stead/goto.lua b/stead/goto.lua index 887811e..d09f965 100644 --- a/stead/goto.lua +++ b/stead/goto.lua @@ -1,4 +1,4 @@ -go = function (self, where, back) +go = function (self, where, back, forceenter) local was = self.where; local need_scene = false; local ret @@ -49,7 +49,8 @@ go = function (self, where, back) self.where = deref(where); end - if not jump and (not back or not isDialog(ref(was)) or isDialog(ref(where))) then + if not jump and (not back or forceenter or + not isDialog(ref(was)) or isDialog(ref(where))) then v, r = call(ref(where), 'enter', ref(was)); if r == false then self.where = was; @@ -102,6 +103,33 @@ go = function (self, where, back) return res; end +function player_go(self, where) -- cmd iface + local w = ref(self.where).way:srch(where); + if not w then + return nil,false + end + return self:goto(w); +end + +function player_goto(self, where, ...) -- real work + local v, r = go(self, where, unpack(arg)); + return v, r; +end + +function player_back(self) -- deprecated + error ("Do not use me():back(). It's deprecated.", 2) +end + +function back() + local where = here(); + return me():goto(where.__from__, true); +end + +function goback() + local where = here(); + return me():goto(where.__from__, true, true); +end + game.ini = stead.hook(game.ini,function(f, ...) if isRoom(here()) then here().__visited = 1 diff --git a/stead/stead.lua b/stead/stead.lua index ef21ecc..da2fc68 100644 --- a/stead/stead.lua +++ b/stead/stead.lua @@ -1275,6 +1275,7 @@ function player_goto(self, where) local v, r = go(self, where, false); return v, r; end + function player_go(self, where) local w = ref(self.where).way:srch(where); if not w then @@ -2108,7 +2109,7 @@ function vroom_save(self, name, h, need) end function vroom_enter(self, ...) - return go(me(), self.where, false); + return me():goto(self.where); end function isVroom(v) @@ -2124,9 +2125,11 @@ function goto(what) me():tag(); return v,r; end + function back() return me():back(); end + function rnd(m) return math.random(m); end