back vs goback, pl:back deprecated

This commit is contained in:
p.kosyh 2010-07-11 17:59:45 +00:00
parent 4a6b07b499
commit b3b5448f9d
2 changed files with 34 additions and 3 deletions

View file

@ -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

View file

@ -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