2011-09-20 19:12:24 +00:00
|
|
|
-- test script for ELua/Lunatic Interpreter
|
|
|
|
|
|
|
|
print('--- ELua Test script ---')
|
|
|
|
|
2011-09-25 15:11:47 +00:00
|
|
|
local function checkfail(funcstr)
|
|
|
|
local status, res = pcall(loadstring(funcstr))
|
|
|
|
if (status) then
|
|
|
|
print('ERROR: '..funcstr.." DIDN'T fail")
|
|
|
|
else
|
|
|
|
print('SUCCESS: '..funcstr.." failed: "..res)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-09-20 19:12:24 +00:00
|
|
|
local i
|
|
|
|
|
|
|
|
print('tweaking sector pals')
|
|
|
|
for i = 0, gv.numsectors/2 do
|
|
|
|
sector[i].floorpal = 1;
|
|
|
|
sector[i].ceilingpal = 2;
|
|
|
|
end
|
|
|
|
|
2011-09-25 15:11:47 +00:00
|
|
|
checkfail('gv.sprite[0].yrepeat = 100') -- direct gv array access forbidden
|
|
|
|
print('tweaking some sprites')
|
|
|
|
for spr in spritesofsect(307) do -- some fence sprites in E1L1
|
|
|
|
print('spr', spr)
|
|
|
|
sprite[spr].pal = 6
|
|
|
|
end
|
|
|
|
for spr in spritesofsect(236) do
|
|
|
|
print('#spr', spr)
|
|
|
|
end
|
|
|
|
|
|
|
|
print('_G contains:')
|
|
|
|
for k,v in pairs(_G) do
|
|
|
|
print(k, v)
|
|
|
|
end
|
|
|
|
|
|
|
|
checkfail('print(sprite[100000].ceilingpal)') -- oob read access
|
|
|
|
checkfail('setmetatable(sprite, {})') -- set metatable forbidden
|
|
|
|
checkfail('sector[-1].ceilingpal = 4') -- oob write access
|
|
|
|
checkfail('sector[0].wallnum = 0') -- wallnum member is read-only
|
|
|
|
checkfail('gv.numsectors = 4') -- gv.numsectors is read-only
|
|
|
|
checkfail('sector[4] = sector[6]') -- direct sector write access forbidden
|
|
|
|
|
2011-09-20 19:12:24 +00:00
|
|
|
|
|
|
|
print('--- end test script ---')
|
|
|
|
|
2011-09-25 15:11:47 +00:00
|
|
|
os = require("os")
|
|
|
|
print('clk', os.clock())
|