code/args added

This commit is contained in:
p.kosyh 2010-06-21 19:33:38 +00:00
parent 38ac49652a
commit 5e362e71b9
3 changed files with 21 additions and 6 deletions

2
debian/changelog vendored
View file

@ -21,6 +21,8 @@ instead (1.2.0) unstable; urgency=low
* improved debugger;
* save vars in _G;
* no duplicated games while looking gamespaths;
* code function!!!;
* args() function;
* many small bugfixes...
-- Peter Kosyh <p.kosyh@gmail.com> Tue, 01 Jun 2010 17:40:00 +0300

View file

@ -166,8 +166,8 @@ fmt = function(...)
end
for i=1,stead.table.maxn(arg) do
if type(arg[i]) == 'string' then
local s = stead.string.gsub(arg[i],'\t',' '):gsub('[\n]+', ' '):gsub('%^','\n');
res = stead.par('', res, s);
local s = stead.string.gsub(arg[i],'\t', ' '):gsub('[\n]+', ' '):gsub('%^','\n'):gsub('~', txtnb(' '));
res = stead.par('', res, s);
end
end
return res

View file

@ -63,9 +63,9 @@ function cctx()
return stead.cctx[stead.call_top];
end
function callpush(v)
function callpush(v, ...)
stead.call_top = stead.call_top + 1;
stead.cctx[stead.call_top] = { txt = nil, self = v };
stead.cctx[stead.call_top] = { txt = nil, self = v, args = arg };
end
function callpop()
@ -83,6 +83,13 @@ function self(v)
return cctx().self;
end
function args(v)
if v ~= nil then
cctx().args = v;
end
return cctx().args;
end
function pclr()
cctx().txt = nil
end
@ -648,7 +655,7 @@ function call(v, n, ...)
return v[n];
end
if type(v[n]) == 'function' then
callpush(v)
callpush(v, unpack(arg))
local a,b = v[n](v, unpack(arg));
if a == nil and b == nil then
a = pget()
@ -2374,7 +2381,13 @@ function check_version(v)
require ("vars");
end
end
function code(v)
local f = loadstring(v)
if not f then
error ("Wrong script: "..tostring(v), 2);
end
return f;
end
--- here the game begins
function stead_init()
pl = player {