integer "type casting" in "lists" for ll functions
in progress
WolfGang Senizen
Secondlife functions like
ll.GetObjectDetails
, ll.SetLinkPrimitiveParams
, ll.ParticleSystem
that take lists as arguments require integer and booleans inside them to be converted to a userdata integer object.This is extremely cumbersome for basic use.
An example
ll.ParticleSystem({
integer(0),
integer(bit32.bor(0x100,0x400,0x008)),
integer(9),
integer(0x01),
integer(17),
1.0,
integer(1),
vector(0.8,0.0,0.0)
})
It would be great if luau could be setup to allow for the use of normal number types and booleans.
Like this
ll.ParticleSystem({
0,
bit32.bor(0x100,0x400,0x008),
9,
0x01,
17,
1.0,
1,
vector(0.8,0.0,0.0)
})
Correctly "cast" constants would improve this somewhat, but still leaves allot to be desired.
For now I have made myself a function to "auto cast" these for me, but that is sub optimal at best...
function table2FuncList(tab)
for k,v in pairs(tab) do
if type(v) == "number" and math.round(v) == v then
tab[k] = integer(v)
elseif type(v) == "boolean" then
tab[k] = integer(v and 1 or 0)
end
end
return tab
end
Log In
Thornotter Resident
Appreciate the hard work on the fixes so far from the Lindens!
Hopefully some sort of "type casting wrapper" can be used internally for the remaining integer requirements.
Using the Lua numeric natively for all the ll* functions would make coding a lot simpler and avoid technical debt carrying into the future. Having an integer type is going to confuse every new Second Life Lua developer for years and years to come - they'll think it's a native part of Lua. Better to try to get rid of it now, if possible. đ
Kristy Aurelia
While in the area, it might be worth considering adding support for
nil
as keep current value
especially for ll.SetLinkPrimitiveParams
that take texture UUIDs as parameters. As you know - keep existing/do not change
and similar has been much requested feature for LSL so this might be a great opportunity to introduce it.Signal Linden
in progress
Thanks for the report, WolfGang Senizen. We will be partially solving this in a release later today.
From our engineers:
> bit32 operations now return an integer if all arguments were integers, but the core issue of list typing for particle and prim param functions still needs to be dealt with.
Maestro Linden
The integer casts in your example are _mostly_ unnecessary; this works for example:
ll.ParticleSystem({
PSYS_PART_FLAGS,
integer(bit32.bor(PSYS_PART_EMISSIVE_MASK, PSYS_PART_RIBBON_MASK, PSYS_PART_WIND_MASK)),
PSYS_SRC_PATTERN,
PSYS_SRC_PATTERN_DROP,
PSYS_SRC_BURST_SPEED_MIN,
1.0,
PSYS_PART_START_COLOR,
vector(0.8,0.0,0.0)
})
It does seem like
bit32
requires an explicit cast to integer for the interpreter to be happy. The bitwise operators from Lua 5.3 would be a lot cleaner to use if they were working, and should return an integer already: https://www.lua.org/manual/5.3/manual.html#3.4.2WolfGang Senizen
Maestro Linden
Yeh this was before the constants were added
We still need to ternary or "cast" bools/numbers if we want properties to be decided by logic or math which is going to keep leading to gotcha's forever
Lua is a "clean slate" it'd be nice if it could start as clean as possible.