code cleanup

This commit is contained in:
p.kosyh 2010-06-22 06:34:45 +00:00
parent ff8e0214e9
commit 935fc1ac86

View file

@ -92,7 +92,7 @@ end
function pget() function pget()
return cctx().txt; return cctx().txt;
end end
stead.pget = pget
function p(...) function p(...)
local i local i
for i = 1, stead.table.maxn(arg) do for i = 1, stead.table.maxn(arg) do
@ -100,19 +100,19 @@ function p(...)
end end
cctx().txt = stead.cat(cctx().txt, ' '); cctx().txt = stead.cat(cctx().txt, ' ');
end end
stead.p = p
function pr(...) function pr(...)
local i local i
for i = 1, stead.table.maxn(arg) do for i = 1, stead.table.maxn(arg) do
cctx().txt = stead.par('',cctx().txt, arg[i]); cctx().txt = stead.par('',cctx().txt, arg[i]);
end end
end end
stead.pr = pr
function pn(...) function pn(...)
p(unpack(arg)); p(unpack(arg));
cctx().txt = stead.par('',cctx().txt,'^'); cctx().txt = stead.par('',cctx().txt,'^');
end end
stead.pn = pn
-- merge strings with "space" as separator -- merge strings with "space" as separator
function par(space,...) function par(space,...)
local i, res local i, res
@ -653,7 +653,7 @@ function call(v, n, ...)
callpush(v, unpack(arg)) callpush(v, unpack(arg))
local a,b = v[n](v, unpack(arg)); local a,b = v[n](v, unpack(arg));
if a == nil and b == nil then if a == nil and b == nil then
a = pget() a = stead.pget()
b = nil b = nil
end end
callpop() callpop()
@ -1458,7 +1458,7 @@ function savevar (h, v, n, need)
if v == nil or type(v) == "userdata" or if v == nil or type(v) == "userdata" or
type(v) == "function" then type(v) == "function" then
if type(v) == "function" and stead.functions[v] and need then if type(v) == "function" and stead.functions[v] and need then
h:write(stead.string.format("%s=code %q\n", n, stead.functions[v])) h:write(stead.string.format("%s=code %q\n", n, stead.functions[v].code))
end end
-- if need then -- if need then
-- error ("Variable "..n.." can not be saved!"); -- error ("Variable "..n.." can not be saved!");
@ -2387,7 +2387,7 @@ function code(v)
if not f then if not f then
error ("Wrong script: "..tostring(v), 2); error ("Wrong script: "..tostring(v), 2);
end end
stead.functions[f] = v; stead.functions[f] = { f = f, code = v };
return f; return f;
end end
--- here the game begins --- here the game begins