steed/doc/examples/visual.lua

50 lines
943 B
Lua
Raw Normal View History

2010-11-29 20:44:49 +02:00
-- example module
2010-10-30 16:04:46 +03:00
require "timer"
require "theme"
2010-11-03 14:20:22 +02:00
function fading_goto(where, step, bg)
2010-10-30 16:04:46 +03:00
fading_room.where = where
2010-11-03 14:20:22 +02:00
fading_room.step = game.gui.fading;
if step then fading_room.step = step end
2010-10-30 16:04:46 +03:00
fading_room._bg = bg
2010-11-03 14:20:22 +02:00
return goto 'fading_room'
2010-10-30 16:04:46 +03:00
end
game.fading = stead.hook(game.fading,
function(f, s, ...)
local r,v = f(s, unpack(arg))
2010-11-03 14:20:22 +02:00
if r and fading_room.active then
if from() == fading_room then
fading_room.active = false
end
2010-10-30 16:04:46 +03:00
return true, fading_room.step
end
return r,v
end)
fading_room = room {
2010-11-03 14:20:22 +02:00
nam = true;
var { active = false };
2010-10-30 16:04:46 +03:00
var { where = 'main' };
var { step = 4 };
2010-11-03 14:20:22 +02:00
pic = true;
2010-10-30 16:04:46 +03:00
entered = function(s)
2010-11-03 14:20:22 +02:00
s.active = true;
2010-10-30 16:04:46 +03:00
if s._bg then
s._saved_bg = theme.get 'scr.gfx.bg';
theme.gfx.bg(s._bg);
end
s._timer = timer:get();
timer:set(1);
end;
exit = function(s)
if s._bg then
theme.gfx.bg(s._saved_bg)
end
end;
timer = function(s)
timer:set(s._timer);
goto(s.where)
end
}