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)
|
2011-10-11 16:53:15 +00:00
|
|
|
local status, res = pcall(DBG_.loadstring(funcstr))
|
2011-09-25 15:11:47 +00:00
|
|
|
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')
|
2012-01-28 14:37:24 +00:00
|
|
|
print('numsectors: ' .. gv.numsectors)
|
|
|
|
|
2011-10-11 16:53:15 +00:00
|
|
|
---[[
|
2011-09-20 19:12:24 +00:00
|
|
|
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
|
2011-12-21 18:43:08 +00:00
|
|
|
|
2012-01-28 14:38:41 +00:00
|
|
|
local vol, lev
|
|
|
|
vol, lev = TEMP_getvollev()
|
|
|
|
print('volume='..vol..', level='..lev)
|
|
|
|
|
|
|
|
if (vol==1 and lev==1) then -- E1L1
|
|
|
|
print('tweaking some sprites 2')
|
|
|
|
i = 562
|
|
|
|
spriteext[i].alpha = 0.5;
|
|
|
|
sprite[i].cstat = bit.bor(sprite[i].cstat, 2+512);
|
|
|
|
spriteext[i].pitch = 128;
|
|
|
|
spriteext[i].roll = 256;
|
|
|
|
|
|
|
|
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
|
2012-01-28 14:37:24 +00:00
|
|
|
|
2012-01-28 14:38:41 +00:00
|
|
|
--this is a problem
|
|
|
|
--actor = {}
|
|
|
|
actor[562].flags = bit.bor(actor[562].flags, 2); -- pal 6 with goggles on front SEENINE
|
|
|
|
end
|
|
|
|
|
|
|
|
if (vol==1 and lev==8) then
|
2012-02-04 14:29:59 +00:00
|
|
|
print('tweaking bunch 1');
|
2012-01-28 14:38:41 +00:00
|
|
|
-- trueror1.map
|
|
|
|
for i in sectorsofbunch(1, gv.CEILING) do
|
|
|
|
sector[i].ceilingz = sector[i].ceilingz - 3*1024;
|
|
|
|
end
|
|
|
|
for i in sectorsofbunch(1, gv.FLOOR) do
|
|
|
|
sector[i].floorz = sector[i].floorz - 3*1024;
|
|
|
|
end
|
|
|
|
end
|
2011-12-21 18:43:08 +00:00
|
|
|
|
2011-10-11 16:53:15 +00:00
|
|
|
--]]
|
2011-09-25 15:11:47 +00:00
|
|
|
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
|
2012-01-28 14:37:24 +00:00
|
|
|
checkfail('gv.QWE = 4') -- cannot create new fields in 'gv'
|
2011-09-25 15:11:47 +00:00
|
|
|
checkfail('sector[4] = sector[6]') -- direct sector write access forbidden
|
2012-01-28 14:37:24 +00:00
|
|
|
checkfail('nextspritesect[4] = -666') -- that would be horrible...
|
|
|
|
checkfail('print(nextspritesect[4].whatfield)') -- we're indexing a plain array!
|
|
|
|
checkfail('wall[4].QWE = 123') -- creating new keys forbidden... handled by LuaJit
|
2011-10-11 16:53:15 +00:00
|
|
|
checkfail("require('os')") -- 'require' has been thrown away to be replaced by
|
|
|
|
-- something more restricted later
|
2012-01-28 14:37:24 +00:00
|
|
|
checkfail("new_global = 345") -- we should declare globals
|
2011-09-20 19:12:24 +00:00
|
|
|
|
|
|
|
print('--- end test script ---')
|