^^ Yeah, a good suggestion from Calin there. So it looks like Lua's C8PaletteMap has some holes in it, not all palette slots are being set in ProcessPalette().
One thing I notice about ProcessPalette() is that you're taking an array of parameters using palindex = {...} but this array will start from 1 rather than 0, and later code adapted from AGSScript naturally isn't expecting this. So to change it to a 0-based array, you could change the first few lines of ProcessPalette() from:
Code: Lua
...to:
Code: Lua
A second thing in ProcessPalette(): it looks like, in the first while-loop, where the original AGSScript version of the function uses ags.palette[palindex[ i ]].r etc. the Lua version uses (the equivalent of) ags.palette[ i ].r
One thing I notice about ProcessPalette() is that you're taking an array of parameters using palindex = {...} but this array will start from 1 rather than 0, and later code adapted from AGSScript naturally isn't expecting this. So to change it to a 0-based array, you could change the first few lines of ProcessPalette() from:
function ProcessPalette (...)
local palindex = {...}
local paltemp = {...}
local palsiz = #palindex
...to:
function ProcessPalette (...)
local palindex = {}
local paltemp = {}
local palsiz = select('#', ...) -- get number of arguments
for n = 1, palsiz do
palindex[n - 1] = select(n, ...) -- get nth argument
paltemp[n - 1] = select(n, ...)
end
A second thing in ProcessPalette(): it looks like, in the first while-loop, where the original AGSScript version of the function uses ags.palette[palindex[ i ]].r etc. the Lua version uses (the equivalent of) ags.palette[ i ].r