1stead.wroom_enter = function(self, ...) 2 local w = self.where 3 if stead.type(w) ~= 'table' then 4 w = stead.call(self, 'where') 5 end 6 local r, v = stead.walk(w); 7 if v ~= false then 8 self._toggle = true 9 end 10 return r, v 11end 12 13stead.wroom_save = function(self, name, h, need) 14 if need then 15 local a = stead.tostring(self.oldname); 16 local b = stead.tostring(self.newname); 17 local c = stead.tostring(self.where); 18 19 if a == nil or b == nil or c == nil then 20 error ("Can not save wroom "..name.."\nFunctions can not be saved, use code [[ ]]"); 21 end 22 local t = stead.string.format("%s = wroom(%s, %s, %s);\n", 23 name, a, b, c); 24 h:write(t); 25 end 26 stead.savemembers(h, self, name, false); 27end 28 29function wroom(a, b, c) 30 local v = room { vroom_type = true, nam = a, where = c, enter = stead.wroom_enter, save = stead.wroom_save }; 31 v.newname = b; 32 v.oldname = a; 33 v._toggle = false 34 if c == nil then -- only two parameters 35 v.newname = nil 36 v.where = b 37 end 38 v.nam = function(s) 39 if s._toggle and s.newname then 40 return stead.call(s, 'newname') 41 else 42 return stead.call(s, 'oldname'); 43 end 44 end 45 return v 46end 47