šŸ“ƒ SLua Alpha

General discussion and feedback on Second Life's SLua Alpha
lljson encode and decode functions with vectors, quaternions, and UUIDs.
Right now, vectors and quaternions encode to strings and decode to strings with the "<... >" format. Likewise UUIDs decode to strings. This is a major nuisance to scripters when decoding tables with embedded vectors, quaternions or UUIDs, requiring special decoding functions in each and every script using them. The underlying problem is that at present there is no way to differentiate between an encoded vector, quaternion, or UUID and the equivalent string value. i.e vector(1,2,3) and "<1,2,3>" both encode to "<1,2,3>". I'd like to propose a variation to encode/decode, (call them lljson.pack and unpack or better, perhaps, add an optional EncodingType argument to encode and decode), that when a vector or quaternion is encountered, encodes them as they are now. UUIDs would then be encoded by adding the same <> delimiters around the current UUID string. When a string starting with < and ending with > is encountered, encode it adding an extra < and > at each end, then decode such strings by removing the added < and >. Then the vectors, quaternions, and UUIDs can be uniquely identified as such by the undoubled delimiters and the appropriate internal format and decoded directly to the appropriate type. This would allow the encoding and decoding of all SLua types in tables without special intervention by the scripters--significantly simplifying scripting such operations and greatly improving performance (one optimized pass through the data in C, rather than one in C followed by one of random scripter quality in SLua) when passing tables between scripts, or storing and retrieving tables in Linkset Data. The only reason for keeping encode and decode as they are now is for the sake of compatibility with external json operations and even then if vectors, quaternions, or UUIDs are involved the proposed operations would likely be superior as it would be necessary to make accommodations for these types on the remote end anyway.
16
Ā·
Feature
Ā·
complete
Listeners stop listening after the first message
Listener doesn't work after the first message: local function listening(channel, name, id, msg) print(msg) end LLEvents:on("listen", listening) ll.Listen(1, "", "", "") [ typing: /1 hello] -- > hello [ typing: /1 hello] ( nothing ) --- Both listeners don't work after the first message to any of them local function listening(channel, name, id, msg) print(msg) end LLEvents:on("listen", listening) ll.Listen(1, "", "", "") ll.Listen(2, "", "", "") [ typing: /2 hello] -- > hello [ typing: /1 hello] ( nothing ) --- Event handlers are in place: local function listening(channel, name, id, msg) print(msg) end local function touching(events) for _, eventName in LLEvents:eventNames() do for _, myHandler in LLEvents:listeners(eventName) do print(`{eventName} : {debug.info(myHandler,"n")}`) end end end LLEvents:on("listen", listening) LLEvents:on("touch_start", touching) ll.Listen(1, "", "", "") [ typing: /1 hello] -- > hello [ touching ] -- > touch_start : touching -- > listen : listening [ typing: /1 hello] ( nothing ) --- This doesn't work, listeners are removed after calling the event handler: local function listening(channel, name, id, msg) print(msg) ll.Listen(1, "", "", "") end LLEvents:on("listen", listening) ll.Listen(1, "", "", "") --- This works: local function listening(channel, name, id, msg) print(msg) LLTimers:once(0.1, function() ll.Listen(1, "", "", "") ll.Listen(2, "", "", "") end) end LLEvents:on("listen", listening) ll.Listen(1, "", "", "") ll.Listen(2, "", "", "")
4
Ā·
Bug
Ā·
complete
on_damage only triggering once
On damage event is only triggering once for a script and needs the script to be reset to work again This happens in both SLua and LSL: Luau This does not happen in LSL If you setup a once registered event handler on each click, those will report correctly but only if you dont have an existing on registered handler Reproduction Be in a sim with allow damage adjustment set to true - and in a parcel with damage enabled Create a prim Take a copy Add the copy to the prim's inventory (leave it's name as Object ) add this script to the prim LLEvents:on("touch_start", function(detected) ll.OwnerSay(`{#LLEvents:listeners("on_damage")}`) ll.RezObjectWithParams( "Object", { REZ_FLAGS, bit32.bor(REZ_FLAG_TEMP,REZ_FLAG_PHYSICAL,REZ_FLAG_DIE_ON_COLLIDE,REZ_FLAG_DIE_ON_NOENTRY), REZ_POS, vector(0,0,2), true, true, REZ_DAMAGE, 10, REZ_DAMAGE_TYPE, DAMAGE_TYPE_BLUDGEONING, } ) end) LLEvents:on("on_damage",function() ll.OwnerSay(`on damage`) end) Click the prim, outputs 1 on damage Click the prim, outputs 1 Note that every hit after the first prints no on damage text This also happens in LSL: Luau LSL Script default { touch_start(integer count) { llRezObjectWithParams( "Object", [ REZ_FLAGS, REZ_FLAG_TEMP|REZ_FLAG_PHYSICAL|REZ_FLAG_DIE_ON_COLLIDE|REZ_FLAG_DIE_ON_NOENTRY, REZ_POS, <0,0,2>, TRUE, TRUE, REZ_DAMAGE, 10, REZ_DAMAGE_TYPE, DAMAGE_TYPE_BLUDGEONING ] ); } on_damage(integer count) { llOwnerSay("on damage"); } } Saving that back and forth between lsl luau and lsl mono will show the difference
4
Ā·
complete
Load More
→