Pass Object to link_message
WolfGang Senizen
Provide
link_message
event with an object representing the request instead of the LSL parameters sender
, num
, str
, id
I'd propose if possible an object with the following structure
type LinkMessage = {
source: number,
num: number,
length: number,
getMessage: (self: LinkMessage) -> string,
id_length: number, -- not sure about this...
getID: (self: LinkMessage) -> string|uuid
}
Example use
LLEvents:on("link_message",function(message)
print("From prim", message.source)
print("Num", message.num)
if message.length < 500 then
print("Message", message:getMessage())
end
end)
This would make link_messages safer and easier to manage especially with large unknown scripts from other parties
Log In
Nexii Malthus
message.num
/ message.length
/ message.getMessage()
/ message.id_length
/ message.getID()
all feel odd and out of place with eachother.For consistency either go with the shorthands (
num
, str
, id
) or expand to readable versions (number
, string
, identifier
). Latter is preferable, reads well and is easy to understand.Likewise with the length just suffix to be specific to the parameter as it is too vague:
stringLength
/ identifierLength
Thus:
type LinkMessage = {
source: number,
number: number,
stringLength: number,
getString: (self: LinkMessage) -> string,
identifierLength: number,
getIdentifier: (self: LinkMessage) -> string|uuid
}