1 -------------------------------------------------------------------
18 -------------------------------------------------------------------
24 -- call -> protect(f, err)
31 -- getargs = Main.getargs ??
35 if not f
then print(err
); return end
37 if not a
then print(b
); return nil
42 function dostring(s
) return do_(loadstring(s
)) end
43 -- function dofile(s) return do_(loadfile(s)) end
45 -------------------------------------------------------------------
49 foreachi = tab
.foreachi
55 -------------------------------------------------------------------
59 getlocal
= dbg
.getlocal
60 setcallhook
= function () error"`setcallhook' is deprecated" end
61 setlinehook
= function () error"`setlinehook' is deprecated" end
62 setlocal
= dbg
.setlocal
64 -------------------------------------------------------------------
68 acos = function (x
) return math
.deg(math
.acos(x
)) end
69 asin = function (x
) return math
.deg(math
.asin(x
)) end
70 atan = function (x
) return math
.deg(math
.atan(x
)) end
71 atan2 = function (x
,y
) return math
.deg(math
.atan2(x
,y
)) end
73 cos = function (x
) return math
.cos(math
.rad(x
)) end
88 randomseed = math
.randomseed
89 sin = function (x
) return math
.sin(math
.rad(x
)) end
91 tan = function (x
) return math
.tan(math
.rad(x
)) end
93 -------------------------------------------------------------------
107 -------------------------------------------------------------------
111 difftime
= os
.difftime
112 execute = os
.execute --?
117 setlocale = os
.setlocale
121 -------------------------------------------------------------------
122 -- compatibility only
123 getglobal = function (n
) return _G
[n
] end
124 setglobal = function (n
,v
) _G
[n
] = v
end
126 -------------------------------------------------------------------
128 local io
, tab
= io
, table
130 -- IO library (files)
136 seek = io
.stdin
.seek -- sick ;-)
147 function readfrom (name
)
149 local f
, err
, cod
= io
.close(_INPUT
)
153 local f
, err
, cod
= io
.open(name
, "r")
159 function writeto (name
)
161 local f
, err
, cod
= io
.close(_OUTPUT
)
165 local f
, err
, cod
= io
.open(name
, "w")
166 _OUTPUT
= f
or _OUTPUT
171 function appendto (name
)
172 local f
, err
, cod
= io
.open(name
, "a")
173 _OUTPUT
= f
or _OUTPUT
179 if type(arg
[1]) == 'userdata' then
180 f
= tab
.remove(arg
, 1)
182 return f
:read(unpack(arg
))
187 if type(arg
[1]) == 'userdata' then
188 f
= tab
.remove(arg
, 1)
190 return f
:write(unpack(arg
))