Log In  


I'm having trouble finding an elegant way of feeding {} bracketed data into sspr! The data isn't of any particular fixed length and if I send it directly it assumes the whole table is the first argument, rather than a series of arguments. is there a quick way to process the numbers so sspr will accept it sanely? thank you

1


2

Not out of the box - there is no introspection functions available in pico lua.

I'd recommend a custom unpack function that would stop after x arguments and call sspr, the move on to the next x arguments.

-- unpack a list into an argument list
-- trick from: https://gist.github.com/josefnpat/bfe4aaa5bbb44f572cd0
function munpack(t, from, to)
 local from,to=from or 1,to or #t
 if(from<=to) return t[from], munpack(t, from+1, to)
end

-- data
local data={56,42,16,16,64,64,16,16}
sspr(munpack(data))

thanks, that works really well :3



[Please log in to post a comment]