more clever gamefile
This commit is contained in:
parent
b7077766d7
commit
1cc022e639
|
@ -1,9 +1,11 @@
|
|||
input.click = stead.hook(input.click,
|
||||
function(f, s, press, mb, x, y, px, py, ...)
|
||||
if press and px then
|
||||
return "click "..px..','..py;
|
||||
end
|
||||
return f(s, press, mb, x, y, px, py, unpack(arg))
|
||||
stead.module_init(function()
|
||||
input.click = stead.hook(input.click,
|
||||
function(f, s, press, mb, x, y, px, py, ...)
|
||||
if press and px then
|
||||
return "click "..px..','..py;
|
||||
end
|
||||
return f(s, press, mb, x, y, px, py, unpack(arg))
|
||||
end)
|
||||
end)
|
||||
|
||||
game.action = stead.hook(game.action,
|
||||
|
|
|
@ -202,6 +202,7 @@ dump_object = room {
|
|||
|
||||
choose_location = dlg {
|
||||
debug = true,
|
||||
system_type = true,
|
||||
forcedsc = true,
|
||||
nam = 'Go to',
|
||||
dsc = 'Select location.',
|
||||
|
@ -227,6 +228,7 @@ choose_location = dlg {
|
|||
|
||||
choose_object = dlg {
|
||||
debug = true,
|
||||
system_type = true,
|
||||
forcedsc = true,
|
||||
nam = 'Get object',
|
||||
dsc = 'Select object to get.',
|
||||
|
@ -253,6 +255,7 @@ choose_object = dlg {
|
|||
drop_object = dlg {
|
||||
debug = true,
|
||||
forcedsc = true,
|
||||
system_type = true,
|
||||
nam = 'Drop object',
|
||||
dsc = 'Select object to drop.',
|
||||
gen = function(s)
|
||||
|
@ -287,6 +290,7 @@ end
|
|||
|
||||
debug_dlg = dlg {
|
||||
debug = true,
|
||||
system_type = true,
|
||||
forcedsc = true,
|
||||
nam = 'Debug Tool',
|
||||
dsc = 'Select tool.',
|
||||
|
@ -304,6 +308,7 @@ debug_dlg = dlg {
|
|||
|
||||
debug_tool = menu {
|
||||
debug = true,
|
||||
system_type = true,
|
||||
forcedsc = true,
|
||||
nam = txtb('debug'),
|
||||
lifes = list {},
|
||||
|
@ -329,10 +334,12 @@ function (f, s, cmd, ...)
|
|||
return f(s, cmd, unpack(arg))
|
||||
end)
|
||||
|
||||
input.key = stead.hook(input.key,
|
||||
function(f, s, down, key, ...)
|
||||
if not here().debug and down and key == 'f7' then return 'use_debug' end
|
||||
return f(s, down, key, unpack(arg))
|
||||
stead.module_init(function()
|
||||
input.key = stead.hook(input.key,
|
||||
function(f, s, down, key, ...)
|
||||
if not here().debug and down and key == 'f7' then return 'use_debug' end
|
||||
return f(s, down, key, unpack(arg))
|
||||
end)
|
||||
end)
|
||||
|
||||
putf('debug_tool', me());
|
||||
|
|
|
@ -252,11 +252,13 @@ input_kbd = function(s, down, key)
|
|||
end
|
||||
end
|
||||
|
||||
input.key = stead.hook(input.key,
|
||||
function(f, ...)
|
||||
local r = input_kbd(unpack(arg))
|
||||
if r then return r end
|
||||
return f(unpack(arg))
|
||||
stead.module_init(function()
|
||||
input.key = stead.hook(input.key,
|
||||
function(f, ...)
|
||||
local r = input_kbd(unpack(arg))
|
||||
if r then return r end
|
||||
return f(unpack(arg))
|
||||
end)
|
||||
end)
|
||||
|
||||
function input_esc(s)
|
||||
|
|
|
@ -10,12 +10,15 @@ game.action = stead.hook(game.action, function(f, s, cmd, ...)
|
|||
return f(s, cmd, unpack(arg));
|
||||
end)
|
||||
|
||||
input.key = stead.hook(input.key, function(f, s, down, key, ...)
|
||||
if input._key_hooks[key] then
|
||||
input.key_event = { key = key, down = down };
|
||||
return 'user_kbd'
|
||||
end
|
||||
return f(s, down, key, unpack(arg))
|
||||
stead.module_init(function()
|
||||
input.key = stead.hook(input.key, function(f, s, down, key, ...)
|
||||
if input._key_hooks[key] then
|
||||
input.key_event = { key = key, down = down };
|
||||
return 'user_kbd'
|
||||
end
|
||||
return f(s, down, key, unpack(arg))
|
||||
end)
|
||||
input._key_hooks = {}
|
||||
end)
|
||||
|
||||
function hook_keys(...)
|
||||
|
@ -32,8 +35,4 @@ function unhook_keys(...)
|
|||
end
|
||||
end
|
||||
|
||||
stead.module_init(function()
|
||||
input._key_hooks = {}
|
||||
end)
|
||||
|
||||
-- vim:ts=4
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
prefs = obj {
|
||||
nam = 'preferences',
|
||||
system_type = true,
|
||||
ini = function(s)
|
||||
local name = get_savepath() .. '/prefs';
|
||||
local f, err = loadfile(name);
|
||||
|
|
|
@ -1657,6 +1657,15 @@ end
|
|||
function gamefile(file, forget)
|
||||
stead.clearargs()
|
||||
if forget then
|
||||
timer:stop();
|
||||
init = function() -- null init function
|
||||
end
|
||||
for_each_object(function(k, o) -- destroy all objects
|
||||
if o.system_type then
|
||||
return
|
||||
end
|
||||
_G[k] = nil
|
||||
end);
|
||||
game._scripts = { }
|
||||
game.lifes:zap()
|
||||
game.scriptsforget = true
|
||||
|
@ -2089,47 +2098,6 @@ function delete(v)
|
|||
allocator:delete(v);
|
||||
end
|
||||
|
||||
timer = obj { -- timer calls stead.timer callback
|
||||
nam = 'timer',
|
||||
ini = function(s)
|
||||
if tonumber(s._timer) ~= nil and type(set_timer) == 'function' then
|
||||
set_timer(s._timer);
|
||||
end
|
||||
end,
|
||||
get = function(s)
|
||||
if tonumber(s._timer) == nil then
|
||||
return 0
|
||||
end
|
||||
return tonumber(s._timer);
|
||||
end,
|
||||
stop = function(s)
|
||||
return s:set(0);
|
||||
end,
|
||||
del = function(s)
|
||||
return s:set(0);
|
||||
end,
|
||||
set = function(s, v)
|
||||
s._timer = tonumber(v);
|
||||
if type(set_timer) ~= 'function' then
|
||||
return false
|
||||
end
|
||||
set_timer(v)
|
||||
return true
|
||||
end,
|
||||
--[[ callback = function(s)
|
||||
end, ]]
|
||||
};
|
||||
|
||||
input = obj { -- input object
|
||||
nam = 'input',
|
||||
--[[ key = function(s, down, key)
|
||||
return
|
||||
end, ]]
|
||||
--[[ click = function(s, down, mb, x, y, [ px, py ] )
|
||||
return
|
||||
end ]]
|
||||
};
|
||||
|
||||
function vobj_save(self, name, h, need)
|
||||
local dsc = self.dsc;
|
||||
local w = deref(self.where);
|
||||
|
@ -2624,12 +2592,55 @@ function code(v)
|
|||
return f;
|
||||
end
|
||||
stead.code = code
|
||||
|
||||
--- here the game begins
|
||||
stead.objects = function(s)
|
||||
null = obj {
|
||||
nam = 'null';
|
||||
}
|
||||
|
||||
|
||||
input = obj { -- input object
|
||||
system_type = true,
|
||||
nam = 'input',
|
||||
--[[ key = function(s, down, key)
|
||||
return
|
||||
end, ]]
|
||||
--[[ click = function(s, down, mb, x, y, [ px, py ] )
|
||||
return
|
||||
end ]]
|
||||
};
|
||||
|
||||
timer = obj { -- timer calls stead.timer callback
|
||||
nam = 'timer',
|
||||
ini = function(s)
|
||||
if tonumber(s._timer) ~= nil and type(set_timer) == 'function' then
|
||||
set_timer(s._timer);
|
||||
end
|
||||
end,
|
||||
get = function(s)
|
||||
if tonumber(s._timer) == nil then
|
||||
return 0
|
||||
end
|
||||
return tonumber(s._timer);
|
||||
end,
|
||||
stop = function(s)
|
||||
return s:set(0);
|
||||
end,
|
||||
del = function(s)
|
||||
return s:set(0);
|
||||
end,
|
||||
set = function(s, v)
|
||||
s._timer = tonumber(v);
|
||||
if type(set_timer) ~= 'function' then
|
||||
return false
|
||||
end
|
||||
set_timer(v)
|
||||
return true
|
||||
end,
|
||||
--[[ callback = function(s)
|
||||
end, ]]
|
||||
};
|
||||
|
||||
allocator = obj {
|
||||
nam = 'allocator',
|
||||
get = function(s, n, c)
|
||||
|
|
|
@ -1,12 +1,19 @@
|
|||
game.action = stead.hook(game.action, function(f, s, cmd, ...)
|
||||
if cmd == 'user_timer' then
|
||||
return call(s, 'timer');
|
||||
local r,v
|
||||
r,v = call(s, 'timer');
|
||||
if r == nil and v == nil then
|
||||
return nil, true
|
||||
end
|
||||
return r,v
|
||||
end
|
||||
return f(s, cmd, unpack(arg));
|
||||
end)
|
||||
|
||||
timer.callback = function(s)
|
||||
return 'user_timer'
|
||||
end
|
||||
stead.module_init(function()
|
||||
timer.callback = function(s)
|
||||
return 'user_timer'
|
||||
end
|
||||
end)
|
||||
|
||||
-- vim:ts=4
|
||||
|
|
|
@ -69,6 +69,7 @@ end
|
|||
|
||||
vars_object = obj {
|
||||
nam = 'vars',
|
||||
system_type = true,
|
||||
ini = function(s)
|
||||
__vars_fill(_G)
|
||||
__vars_fill(pl)
|
||||
|
|
Loading…
Reference in a new issue