Обновление proxymenu

This commit is contained in:
Alexander Yakovlev 2019-03-23 23:32:05 +07:00
parent d8dc936c3a
commit bbd777e186
Signed by: oreolek
GPG Key ID: 1CDC4B7820C93BD3
2 changed files with 33 additions and 18 deletions

View File

@ -1,5 +1,5 @@
--$Author: Alexander Yakolev$
--$Version: 1.2$
--$Version: 1.2.1$
--$Name: Инженер$
-- instead_version "3.2.0"
require "fmt"

View File

@ -8,20 +8,26 @@ local function proxy_wrap(nam, fwd)
local t
local o = _(s.ref)
local act = s.acts or { }
local par = { ... }
act = act[nam] or nam
local r, v = std.call(std.game, 'before_'..act, o, ...)
if nam == 'use' then
local oo = par[1]
if oo:type 'proxy' then
oo = _(oo.ref)
par[1] = oo
end
end
local r, v = std.call(std.game, 'before_'..act, o, std.unpack(par))
t = std.par(std.scene_delim, t or false, r)
if v == false then
return t or r, true
end
if nam == 'use' then
local oo = {...}
oo = oo[1]
if oo:type 'proxy' then
oo = _(oo.ref)
end
r, v = std.call(oo, s.acts.used or 'used', o, ...)
r, v = std.call(par[1], s.acts.used or 'used', o)
t = std.par(std.scene_delim, t or false, r)
if v == true then
oo['__nr_used'] = (oo['__nr_used'] or 0) + 1
@ -29,7 +35,8 @@ local function proxy_wrap(nam, fwd)
end
end
r, v = std.call(o, act, ...)
r, v = std.call(o, act, std.unpack(par))
t = std.par(std.scene_delim, t or false, r)
if type(v) == 'boolean' then
@ -41,12 +48,10 @@ local function proxy_wrap(nam, fwd)
end
if v then
r, v = std.call(std.game, 'after_'..act, o, ...)
r, v = std.call(std.game, 'after_'..act, o, std.unpack(par))
t = std.par(std.scene_delim, t or false, r)
end
if not t then -- game action
r, v = std.call(game, act, o, ...)
else -- game action
r, v = std.call(game, act, o, std.unpack(par))
t = std.par(std.scene_delim, t or false, r)
end
return t or r, true
@ -70,10 +75,14 @@ std.proxy_obj = std.class ({
end;
disp = function(s)
local o = _(s.ref)
if have(o) then
return stead.proxy_prefix..fmt.em(std.dispof(o))
local d = std.dispof(o)
if type(d) ~= 'string' then
return d
end
return stead.proxy_prefix..std.dispof(o)
if have(o) then
return stead.proxy_prefix..fmt.em(d)
end
return stead.proxy_prefix..d
end;
act = proxy_wrap ('act');
inv = proxy_wrap ('inv');
@ -175,6 +184,9 @@ std.menu_player = std.class ({
if type(v) ~= 'table' then
std.err ("Wrong argument to std.menu_player: "..std.tostr(v), 2)
end
if not v.nam then
v.nam = 'menu_player'
end
if not v.room then
v.room = 'main'
end
@ -212,7 +224,10 @@ std.mod_init(function() -- declarations
declare 'proxy_menu' (proxy_menu)
end)
std.mod_step(function()
std.mod_step(function(state)
if not state then
return
end
me().obj:for_each(function(v)
if v:type 'proxy_menu' then
v:fill()