From 806af5b0db2c646352f1f80d718169f22c3987a6 Mon Sep 17 00:00:00 2001 From: tapple Date: Tue, 13 Jan 2026 18:22:42 -0800 Subject: [PATCH 001/102] typing improvements from https://github.com/secondlife/sl-vscode-plugin/pull/57 --- lsl_definitions.yaml | 96 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) diff --git a/lsl_definitions.yaml b/lsl_definitions.yaml index a83392c..a22fc95 100644 --- a/lsl_definitions.yaml +++ b/lsl_definitions.yaml @@ -629,6 +629,7 @@ constants: type: integer value: 2147483646 COMBAT_LOG_ID: + luaType: uuid tooltip: Messages from the region to the COMBAT_CHANNEL will all be from this ID.\n Scripts may filter llListen calls on this ID to receive only system generated combat log messages. type: string @@ -1139,46 +1140,57 @@ constants: type: integer value: 3 IMG_USE_BAKED_AUX1: + luaType: uuid tooltip: '' type: string value: "9742065b-19b5-297c-858a-29711d539043" IMG_USE_BAKED_AUX2: + luaType: uuid tooltip: '' type: string value: "03642e83-2bd1-4eb9-34b4-4c47ed586d2d" IMG_USE_BAKED_AUX3: + luaType: uuid tooltip: '' type: string value: "edd51b77-fc10-ce7a-4b3d-011dfc349e4f" IMG_USE_BAKED_EYES: + luaType: uuid tooltip: '' type: string value: "52cc6bb6-2ee5-e632-d3ad-50197b1dcb8a" IMG_USE_BAKED_HAIR: + luaType: uuid tooltip: '' type: string value: "09aac1fb-6bce-0bee-7d44-caac6dbb6c63" IMG_USE_BAKED_HEAD: + luaType: uuid tooltip: '' type: string value: "5a9f4a74-30f2-821c-b88d-70499d3e7183" IMG_USE_BAKED_LEFTARM: + luaType: uuid tooltip: '' type: string value: "ff62763f-d60a-9855-890b-0c96f8f8cd98" IMG_USE_BAKED_LEFTLEG: + luaType: uuid tooltip: '' type: string value: "8e915e25-31d1-cc95-ae08-d58a47488251" IMG_USE_BAKED_LOWER: + luaType: uuid tooltip: '' type: string value: "24daea5f-0539-cfcf-047f-fbc40b2786ba" IMG_USE_BAKED_SKIRT: + luaType: uuid tooltip: '' type: string value: "43529ce8-7faa-ad92-165a-bc4078371687" IMG_USE_BAKED_UPPER: + luaType: uuid tooltip: '' type: string value: "ae2de45c-d252-50b8-5c6e-19f39ce79317" @@ -1512,6 +1524,7 @@ constants: type: integer value: 2 NULL_KEY: + luaType: uuid tooltip: '' type: string value: "00000000-0000-0000-0000-000000000000" @@ -3858,22 +3871,27 @@ constants: type: integer value: 11 TEXTURE_BLANK: + luaType: uuid tooltip: '' type: string value: "5748decc-f629-461c-9a36-a35a221fe21f" TEXTURE_DEFAULT: + luaType: uuid tooltip: '' type: string value: "89556747-24cb-43ed-920b-47caed15465f" TEXTURE_MEDIA: + luaType: uuid tooltip: '' type: string value: "8b5fec65-8d8d-9dc5-cda8-8fdf2716e361" TEXTURE_PLYWOOD: + luaType: uuid tooltip: '' type: string value: "89556747-24cb-43ed-920b-47caed15465f" TEXTURE_TRANSPARENT: + luaType: uuid tooltip: '' type: string value: "8dcd4a48-2d37-4909-9f78-f7a9eb4ef903" @@ -4553,6 +4571,7 @@ events: - ID: tooltip: '' type: key + luaType: string tooltip: Triggered when object receives a link message via llMessageLinked function call. linkset_data: @@ -4751,6 +4770,9 @@ functions: # sleep: Additional sleep time imposed by the script after this function completes. # mono-sleep: Sleep in the mono script runtime # return: Return type of the function. +# lua-return: More specific return type for lua type-checking. +# lua-type: More specific argument type for lua type-checking. +# type-arguments: An array of strings naming the type variables used for generic type-checking this function. # arguments: An array of maps of maps describing the parameters to this function. # tooltip: A brief description of this function. Map of maps is used to retain ordering. # func-id: The LSO function identifier, (See comment at the top of this file.) @@ -4863,6 +4885,7 @@ functions: llAllowInventoryDrop: arguments: - Flag: + luaType: numeric tooltip: Boolean, If TRUE allows anyone to drop inventory on prim, FALSE revokes. type: integer bool-semantics: true @@ -4892,6 +4915,7 @@ functions: tooltip: Amount of impulse force to apply. type: vector - Local: + luaType: numeric tooltip: Boolean, if TRUE, force is treated as a local directional vector instead of region directional vector. type: integer @@ -4909,6 +4933,7 @@ functions: tooltip: Amount of impulse force to apply. type: vector - Local: + luaType: numeric tooltip: Boolean, if TRUE, uses local axis, if FALSE, uses region axis. type: integer bool-semantics: true @@ -5075,6 +5100,7 @@ functions: tooltip: '' type: string energy: 10.0 + luaReturn: '{string}' func-id: 196 pure: true return: list @@ -5393,6 +5419,7 @@ functions: llDeleteSubList: arguments: - Source: + luaType: '{T}' tooltip: '' type: list - Start: @@ -5404,6 +5431,7 @@ functions: tooltip: '' type: integer energy: 10.0 + luaReturn: '{T}' func-id: 193 native: true pure: true @@ -5415,6 +5443,8 @@ functions: to count backwards from the length of the list, so 0, -1 would delete the entire list.\nIf Start is larger than End the list deleted is the exclusion of the entries; so 6, 4 would delete the entire list except for the 5th list entry. + typeParameters: + - T llDeleteSubString: arguments: - Source: @@ -5960,6 +5990,7 @@ functions: llForceMouselook: arguments: - Enable: + luaType: numeric tooltip: Boolean, if TRUE when an avatar sits on the prim, the avatar will be forced into mouse-look mode.\nFALSE is the default setting and will undo a previously set TRUE or do nothing. @@ -6141,6 +6172,7 @@ functions: energy: 10.0 func-id: 523 return: list + luaReturn: '{uuid}' sleep: 0.0 tooltip: Returns a list of keys of all visible (not HUD) attachments on the avatar identified by the ID argument @@ -6155,6 +6187,7 @@ functions: type: list energy: 10.0 func-id: 518 + luaReturn: '{uuid}' return: list sleep: 0.0 tooltip: Retrieves a list of attachments on an avatar. @@ -6166,6 +6199,7 @@ functions: type: key energy: 10.0 func-id: 277 + luaReturn: '{vector}' return: list sleep: 0.0 tooltip: Returns the bounding box around the object (including any linked prims) @@ -7033,6 +7067,7 @@ functions: tooltip: Region coordinates (z is ignored) of parcel. type: vector - SimWide: + luaType: numeric tooltip: Boolean. If FALSE then the return is the maximum prims supported by the parcel. If TRUE then it is the combined number of prims on all parcels in the region owned by the specified parcel's owner. @@ -7064,6 +7099,7 @@ functions: tooltip: A PARCEL_COUNT_* flag. type: integer - SimWide: + luaType: numeric tooltip: Boolean. If FALSE then the return is the maximum prims supported by the parcel. If TRUE then it is the combined number of prims on all parcels in the region owned by the specified parcel's owner. @@ -7742,6 +7778,7 @@ functions: tooltip: Distance above the ground. type: float - Water: + luaType: numeric tooltip: Boolean, if TRUE then hover above water too. type: integer bool-semantics: true @@ -8099,6 +8136,7 @@ functions: flag' type: integer - QueueEnable: + luaType: numeric tooltip: 'Boolean, sound queuing for the linked prim: TRUE enables, FALSE disables (default).' type: integer @@ -8399,6 +8437,7 @@ functions: llList2List: arguments: - ListVariable: + luaType: '{T}' tooltip: '' type: list - Start: @@ -8410,6 +8449,7 @@ functions: tooltip: '' type: integer energy: 10.0 + luaReturn: '{T}' func-id: 192 native: true pure: true @@ -8420,9 +8460,12 @@ functions: End causes the index to count backwards from the length of the string, so 0, -1 would capture the entire string.\nIf Start is greater than End, the sub string is the exclusion of the entries. + typeParameters: + - T llList2ListSlice: arguments: - ListVariable: + luaType: '{T}' tooltip: '' type: list - Start: @@ -8442,6 +8485,7 @@ functions: type: integer energy: 10.0 func-id: 801 + luaReturn: '{T}' return: list sleep: 0.0 tooltip: Returns a subset of entries from ListVariable, in a range specified by @@ -8453,9 +8497,12 @@ functions: falls outside range of stride, an empty list is returned. slice_index is zero-based. (e.g. A stride of 2 has valid indices 0,1) must-use: true + typeParameters: + - T llList2ListStrided: arguments: - ListVariable: + luaType: '{T}' tooltip: '' type: list - Start: @@ -8470,12 +8517,15 @@ functions: tooltip: '' type: integer energy: 10.0 + luaReturn: '{T}' func-id: 198 return: list sleep: 0.0 tooltip: Copies the strided slice of the list from Start to End.\nReturns a copy of the strided slice of the specified list from Start to End. must-use: true + typeParameters: + - T llList2Rot: arguments: - ListVariable: @@ -8599,9 +8649,11 @@ functions: llListInsertList: arguments: - Target: + luaType: '{T}' tooltip: '' type: list - ListVariable: + luaType: '{T}' tooltip: '' type: list - Position: @@ -8609,6 +8661,7 @@ functions: tooltip: '' type: integer energy: 10.0 + luaReturn: '{T}' func-id: 200 native: true pure: true @@ -8618,9 +8671,12 @@ functions: elements from ListVariable inserted at Position start.\nReturns a new list, created by inserting ListVariable into the Target list at Position. Note this does not alter the Target. + typeParameters: + - T llListRandomize: arguments: - ListVariable: + luaType: '{T}' tooltip: '' type: list - Stride: @@ -8628,18 +8684,23 @@ functions: type: integer energy: 10.0 func-id: 197 + luaReturn: '{T}' return: list sleep: 0.0 tooltip: Returns a version of the input ListVariable which has been randomized by blocks of size Stride.\nIf the remainder from the length of the list, divided by the stride is non-zero, this function does not randomize the list. must-use: true + typeParameters: + - T llListReplaceList: arguments: - Target: + luaType: '{T}' tooltip: '' type: list - ListVariable: + luaType: '{T}' tooltip: '' type: list - Start: @@ -8651,6 +8712,7 @@ functions: type: integer index-semantics: true energy: 10.0 + luaReturn: '{T}' func-id: 296 native: true pure: true @@ -8661,20 +8723,25 @@ functions: Start to End with the specified ListVariable. Start and End are inclusive, so 0, 1 would replace the first two entries and 0, 0 would replace only the first list entry. + typeParameters: + - T llListSort: arguments: - ListVariable: + luaType: '{T}' tooltip: List to sort. type: list - Stride: tooltip: Stride length. type: integer - Ascending: + luaType: numeric tooltip: Boolean. TRUE = result in ascending order, FALSE = result in descending order. type: integer bool-semantics: true energy: 10.0 + luaReturn: '{T}' func-id: 184 return: list sleep: 0.0 @@ -8682,9 +8749,12 @@ functions: order (if Ascending is TRUE, otherwise descending). Note that sort only works if the first entry of each block is the same datatype. must-use: true + typeParameters: + - T llListSortStrided: arguments: - ListVariable: + luaType: '{T}' tooltip: List to sort. type: list - Stride: @@ -8695,11 +8765,13 @@ functions: type: integer index-semantics: true - Ascending: + luaType: numeric tooltip: Boolean. TRUE = result in ascending order, FALSE = result in descending order. type: integer bool-semantics: true energy: 10.0 + luaReturn: '{T}' func-id: 802 return: list sleep: 0.0 @@ -8707,6 +8779,8 @@ functions: of stride in ascending order (if Ascending is TRUE, otherwise descending). Note that sort only works if the first entry of each block is the same datatype. must-use: true + typeParameters: + - T llListStatistics: arguments: - Operation: @@ -9108,9 +9182,11 @@ functions: tooltip: '' type: integer - Text: + luaType: string | uuid tooltip: '' type: string - ID: + luaType: string | uuid tooltip: '' type: key energy: 10.0 @@ -9319,12 +9395,15 @@ functions: tooltip: '' type: string - Separators: + luaType: '{string}' tooltip: '' type: list - Spacers: + luaType: '{string}' tooltip: '' type: list energy: 10.0 + luaReturn: '{string}' func-id: 214 pure: true return: list @@ -9338,12 +9417,15 @@ functions: tooltip: '' type: string - Separators: + luaType: '{string}' tooltip: '' type: list - Spacers: + luaType: '{string}' tooltip: '' type: list energy: 10.0 + luaReturn: '{string}' func-id: 285 pure: true return: list @@ -9368,6 +9450,7 @@ functions: llPassCollisions: arguments: - Pass: + luaType: numeric tooltip: Boolean, if TRUE, collisions are passed from children on to parents. type: integer bool-semantics: true @@ -9382,6 +9465,7 @@ functions: llPassTouches: arguments: - Pass: + luaType: numeric tooltip: Boolean, if TRUE, touches are passed from children on to parents. type: integer bool-semantics: true @@ -9669,6 +9753,7 @@ functions: tooltip: Integer set on target prim as a Personal Information Number code. type: integer - Running: + luaType: numeric tooltip: If the script should be set running in the target prim. type: integer bool-semantics: true @@ -10645,6 +10730,7 @@ functions: tooltip: Directional force. type: vector - Local: + luaType: numeric tooltip: Boolean, if TRUE uses local axis, if FALSE uses region axis. type: integer bool-semantics: true @@ -10663,6 +10749,7 @@ functions: tooltip: Torque force. type: vector - Local: + luaType: numeric tooltip: Boolean, if TRUE uses local axis, if FALSE uses region axis. type: integer bool-semantics: true @@ -10689,6 +10776,7 @@ functions: tooltip: Distance above the ground. type: float - Water: + luaType: numeric tooltip: Boolean, if TRUE then hover above water too. type: integer bool-semantics: true @@ -11188,6 +11276,7 @@ functions: tooltip: '' type: string - Running: + luaType: numeric tooltip: '' type: integer bool-semantics: true @@ -11209,6 +11298,7 @@ functions: llSetSoundQueueing: arguments: - QueueEnable: + luaType: numeric tooltip: 'Boolean, sound queuing: TRUE enables, FALSE disables (default).' type: integer bool-semantics: true @@ -11237,8 +11327,10 @@ functions: tooltip: '' type: integer - Value: + luaType: numeric tooltip: '' type: integer + boolean-semantics: true energy: 10.0 func-id: 45 return: void @@ -11324,6 +11416,7 @@ functions: tooltip: Torque force. type: vector - Local: + luaType: numeric tooltip: Boolean, if TRUE uses local axis, if FALSE uses region axis. type: integer bool-semantics: true @@ -11715,10 +11808,12 @@ functions: tooltip: Bit-field of CONTROL_* flags. type: integer - Accept: + luaType: numeric tooltip: Boolean, determines whether control events are generated. type: integer bool-semantics: true - PassOn: + luaType: numeric tooltip: Boolean, determines whether controls are disabled. type: integer bool-semantics: true @@ -12106,6 +12201,7 @@ functions: llVolumeDetect: arguments: - DetectEnabled: + luaType: numeric tooltip: TRUE enables, FALSE disables. type: integer bool-semantics: true From 8ae92f745c0df65190aea4b997a625ca897e3df0 Mon Sep 17 00:00:00 2001 From: tapple Date: Tue, 13 Jan 2026 18:30:12 -0800 Subject: [PATCH 002/102] added missing definitions, copied from vscode json --- lsl_definitions.yaml | 57 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/lsl_definitions.yaml b/lsl_definitions.yaml index a22fc95..acc227b 100644 --- a/lsl_definitions.yaml +++ b/lsl_definitions.yaml @@ -2056,6 +2056,44 @@ constants: tooltip: '' type: integer value: 5 + PARCEL_SALE_AGENT: + tooltip: The agent authorized to purchase the parcel. + type: integer + value: '2' + PARCEL_SALE_ERROR_BAD_PARAMS: + tooltip: The parameters provided to set the sale information are invalid. + type: integer + value: '5' + PARCEL_SALE_ERROR_INVALID_PRICE: + tooltip: The price set for the parcel is invalid (e.g., less than or equal to + 0). + type: integer + value: '4' + PARCEL_SALE_ERROR_IN_ESCROW: + tooltip: The parcel is currently in escrow and cannot be set for sale. + type: integer + value: '3' + PARCEL_SALE_ERROR_NO_PARCEL: + tooltip: The parcel could not be found. + type: integer + value: '1' + PARCEL_SALE_ERROR_NO_PERMISSIONS: + tooltip: The script does not have the required permissions to set the sale information. + type: integer + value: '2' + PARCEL_SALE_OBJECTS: + tooltip: Are the objects on the parcel included in the sale? + type: integer + value: '3' + PARCEL_SALE_OK: + tooltip: The sale information was successfully set. + type: integer + value: '0' + PARCEL_SALE_PRICE: + tooltip: The price of the parcel. If no authorized agent is set, must be greater + than 0. + type: integer + value: '1' PASSIVE: tooltip: Static in-world objects. type: integer @@ -11098,6 +11136,25 @@ functions: sleep: 0.0 tooltip: Sets the specified PermissionFlag permission to the value specified by PermissionMask on the object the script is attached to. + llSetParcelForSale: + arguments: + - ForSale: + luaType: numeric + tooltip: If TRUE, the parcel is put up for sale. + type: integer + bool-semantics: true + - Options: + tooltip: A list of options to set for the sale. + type: list + bool-semantics: true + energy: 10.0 + return: integer + sleep: 0.0 + tooltip: Sets the parcel the object is on for sale.\nForSale is a boolean, if + TRUE the parcel is put up for sale. Options is a list of options to set for + the sale, such as price, authorized buyer, and whether to include objects + on the parcel.\n Setting ForSale to FALSE will remove the parcel from sale + and clear any options that were set. llSetParcelMusicURL: arguments: - URL: From c38c3608a70d2b8268edf7d6f2dd677b61fdb8f9 Mon Sep 17 00:00:00 2001 From: tapple Date: Tue, 13 Jan 2026 18:30:26 -0800 Subject: [PATCH 003/102] added missing definitions, copied from vscode json --- lsl_definitions.yaml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lsl_definitions.yaml b/lsl_definitions.yaml index acc227b..d7c0f31 100644 --- a/lsl_definitions.yaml +++ b/lsl_definitions.yaml @@ -2065,8 +2065,7 @@ constants: type: integer value: '5' PARCEL_SALE_ERROR_INVALID_PRICE: - tooltip: The price set for the parcel is invalid (e.g., less than or equal to - 0). + tooltip: The price set for the parcel is invalid (e.g., less than or equal to 0). type: integer value: '4' PARCEL_SALE_ERROR_IN_ESCROW: @@ -2090,8 +2089,7 @@ constants: type: integer value: '0' PARCEL_SALE_PRICE: - tooltip: The price of the parcel. If no authorized agent is set, must be greater - than 0. + tooltip: The price of the parcel. If no authorized agent is set, must be greater than 0. type: integer value: '1' PASSIVE: From 313263a571c6630fda4c4a302a0694665d83072f Mon Sep 17 00:00:00 2001 From: tapple Date: Wed, 14 Jan 2026 05:05:39 -0800 Subject: [PATCH 004/102] converted the lua half of syntax_defs_default.json to yaml from https://github.com/secondlife/sl-vscode-plugin/pull/57 --- slua_definitions.yaml | 1901 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1901 insertions(+) create mode 100644 slua_definitions.yaml diff --git a/slua_definitions.yaml b/slua_definitions.yaml new file mode 100644 index 0000000..7538a8d --- /dev/null +++ b/slua_definitions.yaml @@ -0,0 +1,1901 @@ +classes: +- comment: 'Luau Type Definition for LSL UserData Type: quaternion' + methods: + - name: __add + parameters: + - name: self + - name: other + type: quaternion + returnType: quaternion + - name: __sub + parameters: + - name: self + - name: other + type: quaternion + returnType: quaternion + - name: __mul + parameters: + - name: self + - name: other + type: quaternion + returnType: quaternion + - name: __div + parameters: + - name: self + - name: other + type: quaternion + returnType: quaternion + - name: __unm + parameters: + - name: self + returnType: quaternion + - name: __eq + parameters: + - name: self + - name: other + type: quaternion + returnType: boolean + - name: __tostring + parameters: + - name: self + returnType: string + name: quaternion + properties: + - name: x + type: number + - name: y + type: number + - name: z + type: number + - name: s + type: number +- comment: 'Luau Type Definition for LSL UserData Type: uuid' + methods: + - name: __tostring + parameters: + - name: self + returnType: string + name: uuid + properties: + - comment: Returns true if the UUID is not the null UUID (all zeros) + name: istruthy + type: boolean + - comment: Returns the raw 16-byte binary string of the UUID, or nil if the UUID + is not in a compressed state + name: bytes + type: string? +- comment: 'Luau Type Definition for LSL UserData Type: vector' + methods: + - comment: Native component-wise addition + name: __add + parameters: + - name: self + - name: other + type: vector + returnType: vector + - comment: Native component-wise subtraction + name: __sub + parameters: + - name: self + - name: other + type: vector + returnType: vector + - comment: Unary negation + name: __unm + parameters: + - name: self + returnType: vector + - comment: 'Multiplication: vector * vector / number -> vector (Scale), vector + * quaternion -> vector (Rotation)' + luaReturnType: vector + name: __mul + parameters: + - name: self + - name: other + type: number | vector | quaternion + returnType: vector + - comment: 'Division: vector / number -> vector (Scale), vector / quaternion -> + vector (Rotation by inverse)' + name: __div + parameters: + - name: self + - name: other + type: number | vector | quaternion + returnType: vector + - comment: 'LSL-style modulo: vector % vector -> vector (Cross Product)' + name: __mod + parameters: + - name: self + - name: other + type: vector + returnType: vector + - name: __tostring + parameters: + - name: self + returnType: string + name: vector + properties: + - name: x + type: number + - name: y + type: number + - name: z + type: number +- comment: Event detection class providing access to detected object/avatar information + methods: [] + name: LLDetectedEvent + properties: + - name: index + type: number + - name: valid + type: boolean + - name: canAdjustDamage + type: boolean +- comment: Event registration and management class for Second Life events + methods: + - comment: Registers a callback for an event. Returns the callback. + name: 'on' + parameters: + - name: self + - name: event + type: LLEventName + - name: callback + type: LLEventHandler + returnType: LLEventHandler + - comment: Unregisters a callback. Returns true if found and removed. + name: 'off' + parameters: + - name: self + - name: event + type: LLEventName + - name: callback + type: LLEventHandler + returnType: boolean + - comment: Registers a one-time callback. Returns the wrapper function. + name: once + parameters: + - name: self + - name: event + type: LLEventName + - name: callback + type: LLEventHandler + returnType: LLEventHandler + - comment: Returns a list of all listeners for a specific event. + name: listeners + parameters: + - name: self + - name: event + type: LLEventName + returnType: '{LLEventHandler}' + - comment: Returns a list of all event names that have listeners. + name: eventNames + parameters: + - name: self + returnType: '{string}' + name: LLEvents +- comment: Timer management class for scheduling periodic and one-time callbacks + methods: + - comment: Registers a callback to be called every N seconds. Returns the callback. + name: every + parameters: + - name: self + - name: seconds + type: number + - name: callback + type: LLTimerEveryCallback + returnType: LLTimerCallback + - comment: Registers a callback to be called once after N seconds. Returns the + callback. + name: once + parameters: + - name: self + - name: seconds + type: number + - name: callback + type: LLTimerOnceCallback + returnType: LLTimerCallback + - comment: Unregisters a timer callback. Returns true if found and removed. + name: 'off' + parameters: + - name: self + - name: callback + type: LLTimerCallback + returnType: boolean + name: LLTimers +constants: [] +globalFunctions: +- comment: Dangerously executes a required module function + name: dangerouslyexecuterequiredmodule + parameters: + - name: f + type: (...any) -> ...any + returnType: '...any' +- comment: Converts a string, buffer, or uuid to a uuid, returns nil if invalid + name: touuid + parameters: + - name: val + type: string | buffer | uuid + returnType: uuid? +- comment: Converts a value to a vector, returns nil if invalid + name: tovector + parameters: + - name: val + type: any + returnType: vector? +- comment: Converts a value to a quaternion, returns nil if invalid + name: toquaternion + parameters: + - name: val + type: any + returnType: quaternion? +- comment: Converts a value to a rotation (quaternion), returns nil if invalid + name: torotation + parameters: + - name: val + type: any + returnType: quaternion? +globalVariables: +- comment: Global 'quaternion' library table with callable metatable + name: quaternion + type: + callSignature: + parameters: + - name: x + type: number + - name: y + type: number + - name: z + type: number + - name: s + type: number + returnType: quaternion + kind: callable-table + tableType: + properties: + - comment: Constructor + name: create + type: + kind: function + parameters: + - name: x + type: number + - name: y + type: number + - name: z + type: number + - name: s + type: number + returnType: quaternion + - comment: Identity quaternion constant + name: identity + type: quaternion + - comment: Returns normalized quaternion + name: normalize + type: + kind: function + parameters: + - name: q + type: quaternion + returnType: quaternion + - comment: Returns magnitude of quaternion + name: magnitude + type: + kind: function + parameters: + - name: q + type: quaternion + returnType: number + - comment: Dot product of two quaternions + name: dot + type: + kind: function + parameters: + - name: a + type: quaternion + - name: b + type: quaternion + returnType: number + - comment: Spherical linear interpolation + name: slerp + type: + kind: function + parameters: + - name: a + type: quaternion + - name: b + type: quaternion + - name: t + type: number + returnType: quaternion + - comment: Returns conjugate of quaternion + name: conjugate + type: + kind: function + parameters: + - name: q + type: quaternion + returnType: quaternion + - comment: Returns forward vector from quaternion rotation + name: tofwd + type: + kind: function + parameters: + - name: q + type: quaternion + returnType: vector + - comment: Returns left vector from quaternion rotation + name: toleft + type: + kind: function + parameters: + - name: q + type: quaternion + returnType: vector + - comment: Returns up vector from quaternion rotation + name: toup + type: + kind: function + parameters: + - name: q + type: quaternion + returnType: vector +- comment: '''rotation'' global is an alias to the ''quaternion'' library' + name: rotation + type: + kind: typeof + target: quaternion +- comment: Global 'uuid' library table + name: uuid + type: + kind: table + properties: + - comment: Creates a new uuid from a string, buffer, or existing uuid. Returns + nil if the string is not a valid UUID. Throws an error if the buffer is + shorter than 16 bytes. + name: create + type: + kind: function + parameters: + - name: value + type: + kind: union + types: + - string + - buffer + - uuid + returnType: uuid? + - comment: Allows calling uuid() as a constructor + name: __call + type: + kind: function + parameters: + - name: self + type: any + - name: value + type: + kind: union + types: + - string + - buffer + - uuid + returnType: uuid? +- comment: Global 'vector' library table + name: vector + type: + kind: table + properties: + - comment: Creates a new vector with the given component values + name: create + type: + kind: function + parameters: + - name: x + type: number + - name: y + type: number + - name: z + optional: true + type: number + returnType: vector + - comment: Calculates the magnitude of a given vector + name: magnitude + type: + kind: function + parameters: + - name: v + type: vector + returnType: number + - comment: Computes the normalized version (unit vector) of a given vector + name: normalize + type: + kind: function + parameters: + - name: v + type: vector + returnType: vector + - comment: Computes the cross product of two vectors + name: cross + type: + kind: function + parameters: + - name: a + type: vector + - name: b + type: vector + returnType: vector + - comment: Computes the dot product of two vectors + name: dot + type: + kind: function + parameters: + - name: a + type: vector + - name: b + type: vector + returnType: number + - comment: Computes the angle between two vectors in radians. The axis, if specified, + is used to determine the sign of the angle. + name: angle + type: + kind: function + parameters: + - name: a + type: vector + - name: b + type: vector + - name: axis + optional: true + type: vector + returnType: number + - comment: Applies math.floor to every component of the input vector + name: floor + type: + kind: function + parameters: + - name: v + type: vector + returnType: vector + - comment: Applies math.ceil to every component of the input vector + name: ceil + type: + kind: function + parameters: + - name: v + type: vector + returnType: vector + - comment: Applies math.abs to every component of the input vector + name: abs + type: + kind: function + parameters: + - name: v + type: vector + returnType: vector + - comment: Applies math.sign to every component of the input vector + name: sign + type: + kind: function + parameters: + - name: v + type: vector + returnType: vector + - comment: Applies math.clamp to every component of the input vector + name: clamp + type: + kind: function + parameters: + - name: v + type: vector + - name: min + type: vector + - name: max + type: vector + returnType: vector + - comment: Applies math.max to the corresponding components of the input vectors + name: max + type: + kind: function + parameters: + - name: v + type: vector + - type: vector + variadic: true + returnType: vector + - comment: Applies math.min to the corresponding components of the input vectors + name: min + type: + kind: function + parameters: + - name: v + type: vector + - type: vector + variadic: true + returnType: vector + - comment: Linear interpolation between two vectors + name: lerp + type: + kind: function + parameters: + - name: a + type: vector + - name: b + type: vector + - name: t + type: number + returnType: vector + - comment: A zero vector <0,0,0> + name: zero + type: vector + - comment: A one vector <1,1,1> + name: one + type: vector + - comment: 'Constructor call: vector(x, y, z)' + name: __call + type: + kind: function + parameters: + - name: self + type: any + - name: x + type: number + - name: y + type: number + - name: z + optional: true + type: number + returnType: vector +- comment: loadstring is removed in SLua + name: loadstring + type: nil +- comment: getfenv is removed in SLua + name: getfenv + type: nil +- comment: setfenv is removed in SLua + name: setfenv + type: nil +modules: +- comment: Bitwise operations library + functions: + - comment: Arithmetic right shift + name: arshift + parameters: + - name: x + type: number + - name: disp + type: number + returnType: number + - comment: Bitwise AND of all arguments + name: band + parameters: + - type: number + variadic: true + returnType: number + - comment: Bitwise NOT + name: bnot + parameters: + - name: x + type: number + returnType: number + - comment: Bitwise OR of all arguments + name: bor + parameters: + - type: number + variadic: true + returnType: number + - comment: Bitwise XOR of all arguments + name: bxor + parameters: + - type: number + variadic: true + returnType: number + - comment: Returns true if bitwise AND of all arguments is not zero + name: btest + parameters: + - type: number + variadic: true + returnType: boolean + - comment: Extracts bits from n at position field with width + name: extract + parameters: + - name: n + type: number + - name: field + type: number + - name: width + optional: true + type: number + returnType: number + - comment: Left rotate + name: lrotate + parameters: + - name: x + type: number + - name: disp + type: number + returnType: number + - comment: Left shift + name: lshift + parameters: + - name: x + type: number + - name: disp + type: number + returnType: number + - comment: Replaces bits in n at position field with width using value v + name: replace + parameters: + - name: n + type: number + - name: v + type: number + - name: field + type: number + - name: width + optional: true + type: number + returnType: number + - comment: Right rotate + name: rrotate + parameters: + - name: x + type: number + - name: disp + type: number + returnType: number + - comment: Right shift + name: rshift + parameters: + - name: x + type: number + - name: disp + type: number + returnType: number + - comment: Count leading zeros + name: countlz + parameters: + - name: n + type: number + returnType: number + - comment: Count trailing zeros + name: countrz + parameters: + - name: n + type: number + returnType: number + - comment: Swap byte order + name: byteswap + parameters: + - name: n + type: number + returnType: number + name: bit32 +- comment: Buffer manipulation library for binary data + functions: + - comment: Creates a new buffer of the specified size + name: create + parameters: + - name: size + type: number + returnType: buffer + - comment: Creates a buffer from a string + name: fromstring + parameters: + - name: str + type: string + returnType: buffer + - comment: Converts buffer to string + name: tostring + parameters: + - name: b + type: buffer + returnType: string + - comment: Read signed 8-bit integer + name: readi8 + parameters: + - name: b + type: buffer + - name: offset + type: number + returnType: number + - comment: Read unsigned 8-bit integer + name: readu8 + parameters: + - name: b + type: buffer + - name: offset + type: number + returnType: number + - comment: Read signed 16-bit integer + name: readi16 + parameters: + - name: b + type: buffer + - name: offset + type: number + returnType: number + - comment: Read unsigned 16-bit integer + name: readu16 + parameters: + - name: b + type: buffer + - name: offset + type: number + returnType: number + - comment: Read signed 32-bit integer + name: readi32 + parameters: + - name: b + type: buffer + - name: offset + type: number + returnType: number + - comment: Read unsigned 32-bit integer + name: readu32 + parameters: + - name: b + type: buffer + - name: offset + type: number + returnType: number + - comment: Read 32-bit float + name: readf32 + parameters: + - name: b + type: buffer + - name: offset + type: number + returnType: number + - comment: Read 64-bit float + name: readf64 + parameters: + - name: b + type: buffer + - name: offset + type: number + returnType: number + - comment: Write signed 8-bit integer + name: writei8 + parameters: + - name: b + type: buffer + - name: offset + type: number + - name: value + type: number + returnType: () + - comment: Write unsigned 8-bit integer + name: writeu8 + parameters: + - name: b + type: buffer + - name: offset + type: number + - name: value + type: number + returnType: () + - comment: Write signed 16-bit integer + name: writei16 + parameters: + - name: b + type: buffer + - name: offset + type: number + - name: value + type: number + returnType: () + - comment: Write unsigned 16-bit integer + name: writeu16 + parameters: + - name: b + type: buffer + - name: offset + type: number + - name: value + type: number + returnType: () + - comment: Write signed 32-bit integer + name: writei32 + parameters: + - name: b + type: buffer + - name: offset + type: number + - name: value + type: number + returnType: () + - comment: Write unsigned 32-bit integer + name: writeu32 + parameters: + - name: b + type: buffer + - name: offset + type: number + - name: value + type: number + returnType: () + - comment: Write 32-bit float + name: writef32 + parameters: + - name: b + type: buffer + - name: offset + type: number + - name: value + type: number + returnType: () + - comment: Write 64-bit float + name: writef64 + parameters: + - name: b + type: buffer + - name: offset + type: number + - name: value + type: number + returnType: () + - comment: Read string from buffer + name: readstring + parameters: + - name: b + type: buffer + - name: offset + type: number + - name: count + type: number + returnType: string + - comment: Write string to buffer + name: writestring + parameters: + - name: b + type: buffer + - name: offset + type: number + - name: value + type: string + - name: count + optional: true + type: number + returnType: () + - comment: Returns the length of the buffer + name: len + parameters: + - name: b + type: buffer + returnType: number + - comment: Copy data from source buffer to target buffer + name: copy + parameters: + - name: target + type: buffer + - name: targetOffset + type: number + - name: source + type: buffer + - name: sourceOffset + optional: true + type: number + - name: count + optional: true + type: number + returnType: () + - comment: Fill buffer with a value + name: fill + parameters: + - name: b + type: buffer + - name: offset + type: number + - name: value + type: number + - name: count + optional: true + type: number + returnType: () + - comment: Read bits from buffer + name: readbits + parameters: + - name: b + type: buffer + - name: bitOffset + type: number + - name: bitCount + type: number + returnType: number + - comment: Write bits to buffer + name: writebits + parameters: + - name: b + type: buffer + - name: bitOffset + type: number + - name: bitCount + type: number + - name: value + type: number + returnType: () + name: buffer +- comment: Coroutine manipulation library + functions: + - comment: Creates a new coroutine from a function + name: create + parameters: + - name: f + type: (...any) -> ...any + returnType: thread + - comment: Resumes a coroutine, returns success and results + name: resume + parameters: + - name: co + type: thread + - type: any + variadic: true + returnType: (boolean, ...any) + - comment: Returns the running coroutine, or nil if called from main thread + name: running + parameters: [] + returnType: thread? + - comment: Returns the status of a coroutine + name: status + parameters: + - name: co + type: thread + returnType: '"running" | "suspended" | "normal" | "dead"' + - comment: Creates a coroutine and returns a function that resumes it + name: wrap + parameters: + - name: f + type: (...any) -> ...any + returnType: (...any) -> ...any + - comment: Suspends the coroutine and returns values to resume + name: yield + parameters: + - type: any + variadic: true + returnType: '...any' + - comment: Returns true if the coroutine can yield + name: isyieldable + parameters: [] + returnType: boolean + - comment: Closes a coroutine, returns success and optional error message + name: close + parameters: + - name: co + type: thread + returnType: (boolean, string?) + name: coroutine +- comment: Debug library for introspection + functions: + - comment: Returns information about a function or stack level + name: info + overloads: + - comment: Returns information about a stack level + parameters: + - name: level + type: number + - name: options + type: string + returnType: '...any' + - comment: Returns information about a function + parameters: + - name: func + type: (...any) -> ...any + - name: options + type: string + returnType: '...any' + parameters: + - name: thread + type: thread + - name: level + type: number + - name: options + type: string + returnType: '...any' + - comment: Returns a string with a traceback of the call stack + name: traceback + overloads: + - comment: Returns a string with a traceback of the current call stack + parameters: + - name: message + optional: true + type: string + - name: level + optional: true + type: number + returnType: string + parameters: + - name: thread + type: thread + - name: message + optional: true + type: string + - name: level + optional: true + type: number + returnType: string + name: debug +- comment: Base64 encoding/decoding library + functions: + - comment: Encodes a string or buffer to base64 + name: encode + parameters: + - name: data + type: string | buffer + returnType: string + - comment: Decodes a base64 string to a string + name: decode + overloads: + - comment: Decodes a base64 string to a string or buffer + parameters: + - name: data + type: string + - name: asBuffer + optional: true + type: boolean + returnType: string | buffer + parameters: + - name: data + type: string + returnType: string + name: llbase64 +- comment: JSON encoding/decoding library for Second Life + functions: + - comment: Encodes a Lua value as JSON + name: encode + parameters: + - name: value + type: any + returnType: string + - comment: Decodes a JSON string to a Lua value + name: decode + parameters: + - name: json + type: string + returnType: any + - comment: Encodes a Lua value as JSON preserving SL types. Use tight to encode + more compactly. + name: slencode + parameters: + - name: value + type: any + - name: tight + optional: true + type: boolean + returnType: string + - comment: Decodes a JSON string to a Lua value preserving SL types + name: sldecode + parameters: + - name: json + type: string + returnType: any + name: lljson + properties: + - comment: A constant to pass for null to json encode + name: 'null' + type: any + - comment: Metatable for declaring table as an empty array for json encode + name: empty_array_mt + type: '{ [any]: any }' + - comment: Metatable for declaring table as an array for json encode + name: array_mt + type: '{ [any]: any }' + - comment: A constant to pass for an empty array to json encode + name: empty_array + type: any + - comment: Name of the lljson library + name: _NAME + type: string + - comment: Version of the lljson library + name: _VERSION + type: string +- comment: Mathematical functions library + functions: + - comment: Returns the absolute value of x + name: abs + parameters: + - name: x + type: number + returnType: number + - comment: Returns the arc cosine of x (in radians) + name: acos + parameters: + - name: x + type: number + returnType: number + - comment: Returns the arc sine of x (in radians) + name: asin + parameters: + - name: x + type: number + returnType: number + - comment: Returns the arc tangent of x (in radians) + name: atan + parameters: + - name: x + type: number + returnType: number + - comment: Returns the arc tangent of y/x (in radians), using the signs to determine + the quadrant + name: atan2 + parameters: + - name: y + type: number + - name: x + type: number + returnType: number + - comment: Returns the smallest integer larger than or equal to x + name: ceil + parameters: + - name: x + type: number + returnType: number + - comment: Returns n clamped between min and max + name: clamp + parameters: + - name: n + type: number + - name: min + type: number + - name: max + type: number + returnType: number + - comment: Returns the cosine of x (x in radians) + name: cos + parameters: + - name: x + type: number + returnType: number + - comment: Returns the hyperbolic cosine of x + name: cosh + parameters: + - name: x + type: number + returnType: number + - comment: Converts x from radians to degrees + name: deg + parameters: + - name: x + type: number + returnType: number + - comment: Returns e^x + name: exp + parameters: + - name: x + type: number + returnType: number + - comment: Returns the largest integer smaller than or equal to x + name: floor + parameters: + - name: x + type: number + returnType: number + - comment: Returns the remainder of x/y that rounds towards zero + name: fmod + parameters: + - name: x + type: number + - name: y + type: number + returnType: number + - comment: Returns m and e such that x = m * 2^e + name: frexp + parameters: + - name: x + type: number + returnType: (number, number) + - comment: Returns m * 2^e + name: ldexp + parameters: + - name: m + type: number + - name: e + type: number + returnType: number + - comment: Linear interpolation between a and b by t + name: lerp + parameters: + - name: a + type: number + - name: b + type: number + - name: t + type: number + returnType: number + - comment: Returns the logarithm of x in the given base (default e) + name: log + parameters: + - name: x + type: number + - name: base + optional: true + type: number + returnType: number + - comment: Returns the base-10 logarithm of x + name: log10 + parameters: + - name: x + type: number + returnType: number + - comment: Maps x from input range to output range + name: map + parameters: + - name: x + type: number + - name: inMin + type: number + - name: inMax + type: number + - name: outMin + type: number + - name: outMax + type: number + returnType: number + - comment: Returns the maximum value among the arguments + name: max + parameters: + - name: x + type: number + - type: number + variadic: true + returnType: number + - comment: Returns the minimum value among the arguments + name: min + parameters: + - name: x + type: number + - type: number + variadic: true + returnType: number + - comment: Returns the integer and fractional parts of x + name: modf + parameters: + - name: x + type: number + returnType: (number, number) + - comment: Returns Perlin noise value for the given coordinates + name: noise + parameters: + - name: x + type: number + - name: y + optional: true + type: number + - name: z + optional: true + type: number + returnType: number + - comment: Returns base^exponent + name: pow + parameters: + - name: base + type: number + - name: exponent + type: number + returnType: number + - comment: Converts x from degrees to radians + name: rad + parameters: + - name: x + type: number + returnType: number + - comment: Returns a pseudo-random number + name: random + parameters: + - name: m + optional: true + type: number + - name: n + optional: true + type: number + returnType: number + - comment: Sets the seed for the pseudo-random generator + name: randomseed + parameters: + - name: seed + type: number + returnType: () + - comment: Returns x rounded to the nearest integer + name: round + parameters: + - name: x + type: number + returnType: number + - comment: Returns -1, 0, or 1 depending on the sign of x + name: sign + parameters: + - name: x + type: number + returnType: number + - comment: Returns the sine of x (x in radians) + name: sin + parameters: + - name: x + type: number + returnType: number + - comment: Returns the hyperbolic sine of x + name: sinh + parameters: + - name: x + type: number + returnType: number + - comment: Returns the square root of x + name: sqrt + parameters: + - name: x + type: number + returnType: number + - comment: Returns the tangent of x (x in radians) + name: tan + parameters: + - name: x + type: number + returnType: number + - comment: Returns the hyperbolic tangent of x + name: tanh + parameters: + - name: x + type: number + returnType: number + - comment: Returns true if x is NaN + name: isnan + parameters: + - name: x + type: number + returnType: boolean + - comment: Returns true if x is infinite + name: isinf + parameters: + - name: x + type: number + returnType: boolean + - comment: Returns true if x is finite + name: isfinite + parameters: + - name: x + type: number + returnType: boolean + name: math + properties: + - comment: The value of pi + name: pi + type: number + - comment: A value larger than any other numeric value (infinity) + name: huge + type: number +- comment: Operating system facilities library + functions: + - comment: Returns CPU time used by the program in seconds + name: clock + parameters: [] + returnType: number + - comment: Returns a string or table containing date and time + name: date + parameters: + - name: format + optional: true + type: string + - name: time + optional: true + type: number + returnType: string | OsDateTime | nil + - comment: Returns the difference in seconds between two times + name: difftime + parameters: + - name: t2 + type: number + - name: t1 + optional: true + type: number + returnType: number + - comment: Returns the current time or converts a table to time + name: time + parameters: + - name: time + optional: true + type: OsDateTime + returnType: number? + name: os +- comment: String manipulation library + functions: + - comment: Returns the internal numeric codes of the characters + name: byte + parameters: + - name: s + type: string + - name: i + optional: true + type: number + - name: j + optional: true + type: number + returnType: '...number' + - comment: Returns a string from character codes + name: char + parameters: + - type: number + variadic: true + returnType: string + - comment: Finds first match of pattern in string + name: find + parameters: + - name: s + type: string + - name: pattern + type: string + - name: init + optional: true + type: number + - name: plain + optional: true + type: boolean + returnType: (number?, number?, ...string) + - comment: Returns a formatted string + name: format + parameters: + - name: formatstring + type: string + - type: any + variadic: true + returnType: string + - comment: Returns an iterator function for pattern matches + name: gmatch + parameters: + - name: s + type: string + - name: pattern + type: string + returnType: () -> ...string + - comment: Global substitution of pattern matches + name: gsub + parameters: + - name: s + type: string + - name: pattern + type: string + - name: repl + type: 'string | { [string]: string } | (...string) -> string' + - name: n + optional: true + type: number + returnType: (string, number) + - comment: Returns the length of the string + name: len + parameters: + - name: s + type: string + returnType: number + - comment: Converts string to lowercase + name: lower + parameters: + - name: s + type: string + returnType: string + - comment: Returns captures from pattern match + name: match + parameters: + - name: s + type: string + - name: pattern + type: string + - name: init + optional: true + type: number + returnType: '...string' + - comment: Packs values into a binary string + name: pack + parameters: + - name: fmt + type: string + - type: any + variadic: true + returnType: string + - comment: Returns the size of a packed string for the given format + name: packsize + parameters: + - name: fmt + type: string + returnType: number + - comment: Returns a string repeated n times + name: rep + parameters: + - name: s + type: string + - name: n + type: number + returnType: string + - comment: Reverses a string + name: reverse + parameters: + - name: s + type: string + returnType: string + - comment: Splits a string by separator + name: split + parameters: + - name: s + type: string + - name: separator + optional: true + type: string + returnType: '{string}' + - comment: Returns a substring + name: sub + parameters: + - name: s + type: string + - name: i + type: number + - name: j + optional: true + type: number + returnType: string + - comment: Unpacks values from a binary string + name: unpack + parameters: + - name: fmt + type: string + - name: s + type: string + - name: pos + optional: true + type: number + returnType: '...any' + - comment: Converts string to uppercase + name: upper + parameters: + - name: s + type: string + returnType: string + name: string +- comment: Table manipulation library + functions: + - comment: Concatenates table elements into a string + name: concat + parameters: + - name: list + type: '{string}' + - name: sep + optional: true + type: string + - name: i + optional: true + type: number + - name: j + optional: true + type: number + returnType: string + - comment: Iterates over table key-value pairs (deprecated) + name: foreach + parameters: + - name: t + type: '{[T]: U}' + - name: f + type: '(key: T, value: T) -> any' + returnType: any? + typeParameters: + - T + - U + - comment: Iterates over array indices (deprecated) + name: foreachi + parameters: + - name: t + type: '{T}' + - name: f + type: '(index: number, value: T) -> any' + returnType: any? + typeParameters: + - T + - comment: 'Returns the length of a table (deprecated, use # operator)' + name: getn + parameters: + - name: t + type: '{any}' + returnType: number + - comment: Returns the largest positive numeric index + name: maxn + parameters: + - name: t + type: '{any}' + returnType: number + - comment: Inserts an element at the end of a list + name: insert + overloads: + - comment: Inserts an element at a specific position + parameters: + - name: list + type: '{T}' + - name: pos + type: number + - name: value + type: T + returnType: () + typeParameters: + - T + parameters: + - name: list + type: '{T}' + - name: value + type: T + returnType: () + typeParameters: + - T + - comment: Removes and returns an element from a list + name: remove + parameters: + - name: list + type: '{T}' + - name: pos + optional: true + type: number + returnType: T? + typeParameters: + - T + - comment: Sorts list elements in place + name: sort + parameters: + - name: list + type: '{T}' + - name: comp + optional: true + type: '(a: T, b: T) -> boolean' + returnType: () + typeParameters: + - T + - comment: Packs arguments into a table with length field n + name: pack + parameters: + - type: T + variadic: true + returnType: '{ n: number, [number]: T }' + typeParameters: + - T + - comment: Unpacks table elements as multiple return values + name: unpack + parameters: + - name: list + type: '{T}' + - name: i + optional: true + type: number + - name: j + optional: true + type: number + returnType: '...T' + typeParameters: + - T + - comment: Moves elements from one table to another + name: move + parameters: + - name: a1 + type: '{T}' + - name: f + type: number + - name: e + type: number + - name: t + type: number + - name: a2 + optional: true + type: '{T}' + returnType: '{T}' + typeParameters: + - T + - comment: Creates a new table with pre-allocated array slots + name: create + parameters: + - name: count + type: number + - name: value + optional: true + type: T + returnType: '{T}' + typeParameters: + - T + - comment: Finds the index of a value in an array + name: find + parameters: + - name: t + type: '{T}' + - name: value + type: T + - name: init + optional: true + type: number + returnType: number? + typeParameters: + - T + - comment: Removes all elements from a table + name: clear + parameters: + - name: t + type: '{[any]: any}' + returnType: () + - comment: Makes a table read-only + name: freeze + parameters: + - name: t + type: '{[T]: U}' + returnType: '{[T]: U}' + typeParameters: + - T + - U + - comment: Returns true if a table is frozen + name: isfrozen + parameters: + - name: t + type: '{[any]: any}' + returnType: boolean + - comment: Creates a shallow copy of a table + name: clone + parameters: + - name: t + type: '{[T]: U}' + returnType: '{[T]: U}' + typeParameters: + - T + - U + name: table +- comment: UTF-8 support library + functions: + - comment: Returns a string from UTF-8 codepoints + name: char + parameters: + - type: number + variadic: true + returnType: string + - comment: Returns an iterator for UTF-8 codepoints in a string + name: codes + parameters: + - name: s + type: string + returnType: ((string, number) -> (number, number), string, number) + - comment: Returns the codepoints of characters in a string + name: codepoint + parameters: + - name: s + type: string + - name: i + optional: true + type: number + - name: j + optional: true + type: number + returnType: '...number' + - comment: Returns the number of UTF-8 characters in a string, or nil and error + position + name: len + parameters: + - name: s + type: string + - name: i + optional: true + type: number + - name: j + optional: true + type: number + returnType: (number?, number?) + - comment: Returns the byte position of the n-th character + name: offset + parameters: + - name: s + type: string + - name: n + type: number + - name: i + optional: true + type: number + returnType: number? + name: utf8 + properties: + - comment: Pattern that matches exactly one UTF-8 byte sequence + name: charpattern + type: string +typeAliases: +- comment: '''rotation'' is an alias for ''quaternion''' + definition: + kind: reference + name: quaternion + name: rotation +- definition: + kind: union + types: + - boolean + - number + name: numeric +- definition: + elementType: + kind: union + types: + - string + - number + - vector + - uuid + - quaternion + - boolean + kind: array + name: list +- definition: + kind: literal-union + values: [] + name: LLDetectedEventName +- definition: + kind: literal-union + values: [] + name: LLNonDetectedEventName +- definition: + kind: union + types: + - LLDetectedEventName + - LLNonDetectedEventName + name: LLEventName +- definition: + kind: function + parameters: + - type: any + variadic: true + returnType: () + name: LLEventHandler +- definition: + kind: function + parameters: + - name: detected + type: + elementType: LLDetectedEvent + kind: array + returnType: () + name: LLDetectedEventHandler +- comment: Callback type for LLTimers.every() - receives scheduled time and interval + definition: + kind: function + parameters: + - name: scheduled + type: number + - name: interval + type: number + returnType: () + name: LLTimerEveryCallback +- comment: Callback type for LLTimers.once() - receives scheduled time + definition: + kind: function + parameters: + - name: scheduled + type: number + returnType: () + name: LLTimerOnceCallback +- comment: Union of timer callback types + definition: + kind: union + types: + - LLTimerEveryCallback + - LLTimerOnceCallback + - (...any) -> ...any + name: LLTimerCallback +- comment: Date/time table structure used by os.date and os.time + definition: + kind: table + properties: + - name: year + type: number + - name: month + type: number + - name: day + type: number + - name: hour + optional: true + type: number + - name: min + optional: true + type: number + - name: sec + optional: true + type: number + - name: wday + optional: true + type: number + - name: yday + optional: true + type: number + - name: isdst + optional: true + type: boolean + name: OsDateTime +version: 1.0.0 From 9e4ca929e30b7d7b34f9cc1e5f7d15a796760254 Mon Sep 17 00:00:00 2001 From: tapple Date: Wed, 14 Jan 2026 05:49:24 -0800 Subject: [PATCH 005/102] put the new fields in a consistent order --- lsl_definitions.yaml | 175 ++++++++++++++++++++---------------------- slua_definitions.yaml | 42 ++++------ 2 files changed, 96 insertions(+), 121 deletions(-) diff --git a/lsl_definitions.yaml b/lsl_definitions.yaml index d7c0f31..0b09698 100644 --- a/lsl_definitions.yaml +++ b/lsl_definitions.yaml @@ -629,10 +629,10 @@ constants: type: integer value: 2147483646 COMBAT_LOG_ID: - luaType: uuid tooltip: Messages from the region to the COMBAT_CHANNEL will all be from this ID.\n Scripts may filter llListen calls on this ID to receive only system generated combat log messages. type: string + luaType: uuid value: "45e0fcfa-2268-4490-a51c-3e51bdfe80d1" CONTENT_TYPE_ATOM: tooltip: '"application/atom+xml"' @@ -1140,59 +1140,59 @@ constants: type: integer value: 3 IMG_USE_BAKED_AUX1: - luaType: uuid tooltip: '' type: string + luaType: uuid value: "9742065b-19b5-297c-858a-29711d539043" IMG_USE_BAKED_AUX2: - luaType: uuid tooltip: '' type: string + luaType: uuid value: "03642e83-2bd1-4eb9-34b4-4c47ed586d2d" IMG_USE_BAKED_AUX3: - luaType: uuid tooltip: '' type: string + luaType: uuid value: "edd51b77-fc10-ce7a-4b3d-011dfc349e4f" IMG_USE_BAKED_EYES: - luaType: uuid tooltip: '' type: string + luaType: uuid value: "52cc6bb6-2ee5-e632-d3ad-50197b1dcb8a" IMG_USE_BAKED_HAIR: - luaType: uuid tooltip: '' type: string + luaType: uuid value: "09aac1fb-6bce-0bee-7d44-caac6dbb6c63" IMG_USE_BAKED_HEAD: - luaType: uuid tooltip: '' type: string + luaType: uuid value: "5a9f4a74-30f2-821c-b88d-70499d3e7183" IMG_USE_BAKED_LEFTARM: - luaType: uuid tooltip: '' type: string + luaType: uuid value: "ff62763f-d60a-9855-890b-0c96f8f8cd98" IMG_USE_BAKED_LEFTLEG: - luaType: uuid tooltip: '' type: string + luaType: uuid value: "8e915e25-31d1-cc95-ae08-d58a47488251" IMG_USE_BAKED_LOWER: - luaType: uuid tooltip: '' type: string + luaType: uuid value: "24daea5f-0539-cfcf-047f-fbc40b2786ba" IMG_USE_BAKED_SKIRT: - luaType: uuid tooltip: '' type: string + luaType: uuid value: "43529ce8-7faa-ad92-165a-bc4078371687" IMG_USE_BAKED_UPPER: - luaType: uuid tooltip: '' type: string + luaType: uuid value: "ae2de45c-d252-50b8-5c6e-19f39ce79317" INVENTORY_ALL: tooltip: '' @@ -1524,9 +1524,9 @@ constants: type: integer value: 2 NULL_KEY: - luaType: uuid tooltip: '' type: string + luaType: uuid value: "00000000-0000-0000-0000-000000000000" OBJECT_ACCOUNT_LEVEL: tooltip: Retrieves the account level of an avatar.\nReturns 0 when the avatar @@ -3907,29 +3907,29 @@ constants: type: integer value: 11 TEXTURE_BLANK: - luaType: uuid tooltip: '' type: string + luaType: uuid value: "5748decc-f629-461c-9a36-a35a221fe21f" TEXTURE_DEFAULT: - luaType: uuid tooltip: '' type: string + luaType: uuid value: "89556747-24cb-43ed-920b-47caed15465f" TEXTURE_MEDIA: - luaType: uuid tooltip: '' type: string + luaType: uuid value: "8b5fec65-8d8d-9dc5-cda8-8fdf2716e361" TEXTURE_PLYWOOD: - luaType: uuid tooltip: '' type: string + luaType: uuid value: "89556747-24cb-43ed-920b-47caed15465f" TEXTURE_TRANSPARENT: - luaType: uuid tooltip: '' type: string + luaType: uuid value: "8dcd4a48-2d37-4909-9f78-f7a9eb4ef903" TOUCH_INVALID_FACE: tooltip: '' @@ -4921,9 +4921,9 @@ functions: llAllowInventoryDrop: arguments: - Flag: - luaType: numeric tooltip: Boolean, If TRUE allows anyone to drop inventory on prim, FALSE revokes. type: integer + luaType: numeric bool-semantics: true energy: 10.0 func-id: 176 @@ -4951,10 +4951,10 @@ functions: tooltip: Amount of impulse force to apply. type: vector - Local: - luaType: numeric tooltip: Boolean, if TRUE, force is treated as a local directional vector instead of region directional vector. type: integer + luaType: numeric bool-semantics: true energy: 10.0 func-id: 72 @@ -4969,9 +4969,9 @@ functions: tooltip: Amount of impulse force to apply. type: vector - Local: - luaType: numeric tooltip: Boolean, if TRUE, uses local axis, if FALSE, uses region axis. type: integer + luaType: numeric bool-semantics: true energy: 10.0 func-id: 73 @@ -5136,10 +5136,10 @@ functions: tooltip: '' type: string energy: 10.0 - luaReturn: '{string}' func-id: 196 pure: true return: list + luaReturn: '{string}' sleep: 0.0 tooltip: Create a list from a string of comma separated values specified in Text. llCastRay: @@ -5453,11 +5453,12 @@ functions: \ case the second item will be the value associated with the key.\n \ \ " llDeleteSubList: + typeParameters: [T] arguments: - Source: - luaType: '{T}' tooltip: '' type: list + luaType: '{T}' - Start: index-semantics: true tooltip: '' @@ -5467,11 +5468,11 @@ functions: tooltip: '' type: integer energy: 10.0 - luaReturn: '{T}' func-id: 193 native: true pure: true return: list + luaReturn: '{T}' sleep: 0.0 tooltip: Removes the slice from start to end and returns the remainder of the list.\nRemove a slice from the list and return the remainder, start and end @@ -5479,8 +5480,6 @@ functions: to count backwards from the length of the list, so 0, -1 would delete the entire list.\nIf Start is larger than End the list deleted is the exclusion of the entries; so 6, 4 would delete the entire list except for the 5th list entry. - typeParameters: - - T llDeleteSubString: arguments: - Source: @@ -6026,11 +6025,11 @@ functions: llForceMouselook: arguments: - Enable: - luaType: numeric tooltip: Boolean, if TRUE when an avatar sits on the prim, the avatar will be forced into mouse-look mode.\nFALSE is the default setting and will undo a previously set TRUE or do nothing. type: integer + luaType: numeric bool-semantics: true energy: 10.0 func-id: 294 @@ -6223,8 +6222,8 @@ functions: type: list energy: 10.0 func-id: 518 - luaReturn: '{uuid}' return: list + luaReturn: '{uuid}' sleep: 0.0 tooltip: Retrieves a list of attachments on an avatar. must-use: true @@ -6235,8 +6234,8 @@ functions: type: key energy: 10.0 func-id: 277 - luaReturn: '{vector}' return: list + luaReturn: '{vector}' sleep: 0.0 tooltip: Returns the bounding box around the object (including any linked prims) relative to its root prim, as a list in the format [ (vector) min_corner, (vector) @@ -7103,11 +7102,11 @@ functions: tooltip: Region coordinates (z is ignored) of parcel. type: vector - SimWide: - luaType: numeric tooltip: Boolean. If FALSE then the return is the maximum prims supported by the parcel. If TRUE then it is the combined number of prims on all parcels in the region owned by the specified parcel's owner. type: integer + luaType: numeric bool-semantics: true energy: 10.0 func-id: 326 @@ -7135,11 +7134,11 @@ functions: tooltip: A PARCEL_COUNT_* flag. type: integer - SimWide: - luaType: numeric tooltip: Boolean. If FALSE then the return is the maximum prims supported by the parcel. If TRUE then it is the combined number of prims on all parcels in the region owned by the specified parcel's owner. type: integer + luaType: numeric bool-semantics: true energy: 10.0 func-id: 325 @@ -7814,9 +7813,9 @@ functions: tooltip: Distance above the ground. type: float - Water: - luaType: numeric tooltip: Boolean, if TRUE then hover above water too. type: integer + luaType: numeric bool-semantics: true - Tau: tooltip: Seconds to critically damp in. @@ -8172,10 +8171,10 @@ functions: flag' type: integer - QueueEnable: - luaType: numeric tooltip: 'Boolean, sound queuing for the linked prim: TRUE enables, FALSE disables (default).' type: integer + luaType: numeric bool-semantics: true energy: 10.0 func-id: 537 @@ -8471,11 +8470,12 @@ functions: specified list. If Index describes a location not in the list, or the value cannot be type-cast to a key, then null string is returned. llList2List: + typeParameters: [T] arguments: - ListVariable: - luaType: '{T}' tooltip: '' type: list + luaType: '{T}' - Start: index-semantics: true tooltip: '' @@ -8485,25 +8485,24 @@ functions: tooltip: '' type: integer energy: 10.0 - luaReturn: '{T}' func-id: 192 native: true pure: true return: list + luaReturn: '{T}' sleep: 0.0 tooltip: Returns a subset of entries from ListVariable, in a range specified by the Start and End indicies (inclusive).\nUsing negative numbers for Start and/or End causes the index to count backwards from the length of the string, so 0, -1 would capture the entire string.\nIf Start is greater than End, the sub string is the exclusion of the entries. - typeParameters: - - T llList2ListSlice: + typeParameters: [T] arguments: - ListVariable: - luaType: '{T}' tooltip: '' type: list + luaType: '{T}' - Start: index-semantics: true tooltip: '' @@ -8521,8 +8520,8 @@ functions: type: integer energy: 10.0 func-id: 801 - luaReturn: '{T}' return: list + luaReturn: '{T}' sleep: 0.0 tooltip: Returns a subset of entries from ListVariable, in a range specified by Start and End indices (inclusive) return the slice_index element of each stride.\n @@ -8533,14 +8532,13 @@ functions: falls outside range of stride, an empty list is returned. slice_index is zero-based. (e.g. A stride of 2 has valid indices 0,1) must-use: true - typeParameters: - - T llList2ListStrided: + typeParameters: [T] arguments: - ListVariable: - luaType: '{T}' tooltip: '' type: list + luaType: '{T}' - Start: index-semantics: true tooltip: '' @@ -8553,15 +8551,13 @@ functions: tooltip: '' type: integer energy: 10.0 - luaReturn: '{T}' func-id: 198 return: list + luaReturn: '{T}' sleep: 0.0 tooltip: Copies the strided slice of the list from Start to End.\nReturns a copy of the strided slice of the specified list from Start to End. must-use: true - typeParameters: - - T llList2Rot: arguments: - ListVariable: @@ -8683,62 +8679,61 @@ functions: ListVariable by stride. Returns -1 if not found. must-use: true llListInsertList: + typeParameters: [T] arguments: - Target: - luaType: '{T}' tooltip: '' type: list - - ListVariable: luaType: '{T}' + - ListVariable: tooltip: '' type: list + luaType: '{T}' - Position: index-semantics: true tooltip: '' type: integer energy: 10.0 - luaReturn: '{T}' func-id: 200 native: true pure: true return: list + luaReturn: '{T}' sleep: 0.0 tooltip: Returns a list that contains all the elements from Target but with the elements from ListVariable inserted at Position start.\nReturns a new list, created by inserting ListVariable into the Target list at Position. Note this does not alter the Target. - typeParameters: - - T llListRandomize: + typeParameters: [T] arguments: - ListVariable: - luaType: '{T}' tooltip: '' type: list + luaType: '{T}' - Stride: tooltip: '' type: integer energy: 10.0 func-id: 197 - luaReturn: '{T}' return: list + luaReturn: '{T}' sleep: 0.0 tooltip: Returns a version of the input ListVariable which has been randomized by blocks of size Stride.\nIf the remainder from the length of the list, divided by the stride is non-zero, this function does not randomize the list. must-use: true - typeParameters: - - T llListReplaceList: + typeParameters: [T] arguments: - Target: - luaType: '{T}' tooltip: '' type: list - - ListVariable: luaType: '{T}' + - ListVariable: tooltip: '' type: list + luaType: '{T}' - Start: tooltip: '' type: integer @@ -8748,51 +8743,49 @@ functions: type: integer index-semantics: true energy: 10.0 - luaReturn: '{T}' func-id: 296 native: true pure: true return: list + luaReturn: '{T}' sleep: 0.0 tooltip: Returns a list that is Target with Start through End removed and ListVariable inserted at Start.\nReturns a list replacing the slice of the Target list from Start to End with the specified ListVariable. Start and End are inclusive, so 0, 1 would replace the first two entries and 0, 0 would replace only the first list entry. - typeParameters: - - T llListSort: + typeParameters: [T] arguments: - ListVariable: - luaType: '{T}' tooltip: List to sort. type: list + luaType: '{T}' - Stride: tooltip: Stride length. type: integer - Ascending: - luaType: numeric tooltip: Boolean. TRUE = result in ascending order, FALSE = result in descending order. type: integer + luaType: numeric bool-semantics: true energy: 10.0 - luaReturn: '{T}' func-id: 184 return: list + luaReturn: '{T}' sleep: 0.0 tooltip: Returns the specified list, sorted into blocks of stride in ascending order (if Ascending is TRUE, otherwise descending). Note that sort only works if the first entry of each block is the same datatype. must-use: true - typeParameters: - - T llListSortStrided: + typeParameters: [T] arguments: - ListVariable: - luaType: '{T}' tooltip: List to sort. type: list + luaType: '{T}' - Stride: tooltip: Stride length. type: integer @@ -8801,22 +8794,20 @@ functions: type: integer index-semantics: true - Ascending: - luaType: numeric tooltip: Boolean. TRUE = result in ascending order, FALSE = result in descending order. type: integer + luaType: numeric bool-semantics: true energy: 10.0 - luaReturn: '{T}' func-id: 802 return: list + luaReturn: '{T}' sleep: 0.0 tooltip: Returns the specified list, sorted by the specified element into blocks of stride in ascending order (if Ascending is TRUE, otherwise descending). Note that sort only works if the first entry of each block is the same datatype. must-use: true - typeParameters: - - T llListStatistics: arguments: - Operation: @@ -9218,13 +9209,13 @@ functions: tooltip: '' type: integer - Text: - luaType: string | uuid tooltip: '' type: string - - ID: luaType: string | uuid + - ID: tooltip: '' type: key + luaType: string | uuid energy: 10.0 func-id: 164 return: void @@ -9431,18 +9422,18 @@ functions: tooltip: '' type: string - Separators: - luaType: '{string}' tooltip: '' type: list - - Spacers: luaType: '{string}' + - Spacers: tooltip: '' type: list + luaType: '{string}' energy: 10.0 - luaReturn: '{string}' func-id: 214 pure: true return: list + luaReturn: '{string}' sleep: 0.0 tooltip: Converts Text into a list, discarding Separators, keeping Spacers (Separators and Spacers must be lists of strings, maximum of 8 each).\nSeparators and Spacers @@ -9453,18 +9444,18 @@ functions: tooltip: '' type: string - Separators: - luaType: '{string}' tooltip: '' type: list - - Spacers: luaType: '{string}' + - Spacers: tooltip: '' type: list + luaType: '{string}' energy: 10.0 - luaReturn: '{string}' func-id: 285 pure: true return: list + luaReturn: '{string}' sleep: 0.0 tooltip: Breaks Text into a list, discarding separators, keeping spacers, keeping any null values generated. (separators and spacers must be lists of strings, @@ -9486,9 +9477,9 @@ functions: llPassCollisions: arguments: - Pass: - luaType: numeric tooltip: Boolean, if TRUE, collisions are passed from children on to parents. type: integer + luaType: numeric bool-semantics: true energy: 10.0 func-id: 166 @@ -9501,9 +9492,9 @@ functions: llPassTouches: arguments: - Pass: - luaType: numeric tooltip: Boolean, if TRUE, touches are passed from children on to parents. type: integer + luaType: numeric bool-semantics: true energy: 10.0 func-id: 154 @@ -9789,9 +9780,9 @@ functions: tooltip: Integer set on target prim as a Personal Information Number code. type: integer - Running: - luaType: numeric tooltip: If the script should be set running in the target prim. type: integer + luaType: numeric bool-semantics: true - StartParameter: tooltip: Integer. Parameter passed to the script if set to be running. @@ -10766,9 +10757,9 @@ functions: tooltip: Directional force. type: vector - Local: - luaType: numeric tooltip: Boolean, if TRUE uses local axis, if FALSE uses region axis. type: integer + luaType: numeric bool-semantics: true energy: 10.0 func-id: 64 @@ -10785,9 +10776,9 @@ functions: tooltip: Torque force. type: vector - Local: - luaType: numeric tooltip: Boolean, if TRUE uses local axis, if FALSE uses region axis. type: integer + luaType: numeric bool-semantics: true energy: 10.0 func-id: 76 @@ -10812,9 +10803,9 @@ functions: tooltip: Distance above the ground. type: float - Water: - luaType: numeric tooltip: Boolean, if TRUE then hover above water too. type: integer + luaType: numeric bool-semantics: true - Tau: tooltip: Seconds to critically damp in. @@ -11137,9 +11128,9 @@ functions: llSetParcelForSale: arguments: - ForSale: - luaType: numeric tooltip: If TRUE, the parcel is put up for sale. type: integer + luaType: numeric bool-semantics: true - Options: tooltip: A list of options to set for the sale. @@ -11331,9 +11322,9 @@ functions: tooltip: '' type: string - Running: - luaType: numeric tooltip: '' type: integer + luaType: numeric bool-semantics: true energy: 10.0 func-id: 148 @@ -11353,9 +11344,9 @@ functions: llSetSoundQueueing: arguments: - QueueEnable: - luaType: numeric tooltip: 'Boolean, sound queuing: TRUE enables, FALSE disables (default).' type: integer + luaType: numeric bool-semantics: true energy: 10.0 func-id: 208 @@ -11382,10 +11373,10 @@ functions: tooltip: '' type: integer - Value: - luaType: numeric tooltip: '' type: integer - boolean-semantics: true + luaType: numeric + bool-semantics: true energy: 10.0 func-id: 45 return: void @@ -11471,9 +11462,9 @@ functions: tooltip: Torque force. type: vector - Local: - luaType: numeric tooltip: Boolean, if TRUE uses local axis, if FALSE uses region axis. type: integer + luaType: numeric bool-semantics: true energy: 10.0 func-id: 74 @@ -11863,14 +11854,14 @@ functions: tooltip: Bit-field of CONTROL_* flags. type: integer - Accept: - luaType: numeric tooltip: Boolean, determines whether control events are generated. type: integer + luaType: numeric bool-semantics: true - PassOn: - luaType: numeric tooltip: Boolean, determines whether controls are disabled. type: integer + luaType: numeric bool-semantics: true energy: 10.0 func-id: 111 @@ -12256,9 +12247,9 @@ functions: llVolumeDetect: arguments: - DetectEnabled: - luaType: numeric tooltip: TRUE enables, FALSE disables. type: integer + luaType: numeric bool-semantics: true energy: 10.0 func-id: 248 diff --git a/slua_definitions.yaml b/slua_definitions.yaml index 7538a8d..4677e6f 100644 --- a/slua_definitions.yaml +++ b/slua_definitions.yaml @@ -1565,25 +1565,22 @@ modules: returnType: string - comment: Iterates over table key-value pairs (deprecated) name: foreach + typeParameters: [T, U] parameters: - name: t type: '{[T]: U}' - name: f type: '(key: T, value: T) -> any' returnType: any? - typeParameters: - - T - - U - comment: Iterates over array indices (deprecated) name: foreachi + typeParameters: [T] parameters: - name: t type: '{T}' - name: f type: '(index: number, value: T) -> any' returnType: any? - typeParameters: - - T - comment: 'Returns the length of a table (deprecated, use # operator)' name: getn parameters: @@ -1600,6 +1597,7 @@ modules: name: insert overloads: - comment: Inserts an element at a specific position + typeParameters: [T] parameters: - name: list type: '{T}' @@ -1608,18 +1606,16 @@ modules: - name: value type: T returnType: () - typeParameters: - - T + typeParameters: [T] parameters: - name: list type: '{T}' - name: value type: T returnType: () - typeParameters: - - T - comment: Removes and returns an element from a list name: remove + typeParameters: [T] parameters: - name: list type: '{T}' @@ -1627,10 +1623,9 @@ modules: optional: true type: number returnType: T? - typeParameters: - - T - comment: Sorts list elements in place name: sort + typeParameters: [T] parameters: - name: list type: '{T}' @@ -1638,18 +1633,16 @@ modules: optional: true type: '(a: T, b: T) -> boolean' returnType: () - typeParameters: - - T - comment: Packs arguments into a table with length field n name: pack + typeParameters: [T] parameters: - type: T variadic: true returnType: '{ n: number, [number]: T }' - typeParameters: - - T - comment: Unpacks table elements as multiple return values name: unpack + typeParameters: [T] parameters: - name: list type: '{T}' @@ -1660,10 +1653,9 @@ modules: optional: true type: number returnType: '...T' - typeParameters: - - T - comment: Moves elements from one table to another name: move + typeParameters: [T] parameters: - name: a1 type: '{T}' @@ -1677,10 +1669,9 @@ modules: optional: true type: '{T}' returnType: '{T}' - typeParameters: - - T - comment: Creates a new table with pre-allocated array slots name: create + typeParameters: [T] parameters: - name: count type: number @@ -1688,10 +1679,9 @@ modules: optional: true type: T returnType: '{T}' - typeParameters: - - T - comment: Finds the index of a value in an array name: find + typeParameters: [T] parameters: - name: t type: '{T}' @@ -1701,8 +1691,6 @@ modules: optional: true type: number returnType: number? - typeParameters: - - T - comment: Removes all elements from a table name: clear parameters: @@ -1711,13 +1699,11 @@ modules: returnType: () - comment: Makes a table read-only name: freeze + typeParameters: [T, U] parameters: - name: t type: '{[T]: U}' returnType: '{[T]: U}' - typeParameters: - - T - - U - comment: Returns true if a table is frozen name: isfrozen parameters: @@ -1726,13 +1712,11 @@ modules: returnType: boolean - comment: Creates a shallow copy of a table name: clone + typeParameters: [T, U] parameters: - name: t type: '{[T]: U}' returnType: '{[T]: U}' - typeParameters: - - T - - U name: table - comment: UTF-8 support library functions: From 54d1b196cf51f72923622960b7e8b3cc4f7f9bd9 Mon Sep 17 00:00:00 2001 From: tapple Date: Wed, 14 Jan 2026 05:56:45 -0800 Subject: [PATCH 006/102] make the new fields in lsl_defs naming-consistent --- lsl_definitions.yaml | 174 +++++++++++++++++++++---------------------- 1 file changed, 87 insertions(+), 87 deletions(-) diff --git a/lsl_definitions.yaml b/lsl_definitions.yaml index 0b09698..9e5402e 100644 --- a/lsl_definitions.yaml +++ b/lsl_definitions.yaml @@ -632,7 +632,7 @@ constants: tooltip: Messages from the region to the COMBAT_CHANNEL will all be from this ID.\n Scripts may filter llListen calls on this ID to receive only system generated combat log messages. type: string - luaType: uuid + slua-type: uuid value: "45e0fcfa-2268-4490-a51c-3e51bdfe80d1" CONTENT_TYPE_ATOM: tooltip: '"application/atom+xml"' @@ -1142,57 +1142,57 @@ constants: IMG_USE_BAKED_AUX1: tooltip: '' type: string - luaType: uuid + slua-type: uuid value: "9742065b-19b5-297c-858a-29711d539043" IMG_USE_BAKED_AUX2: tooltip: '' type: string - luaType: uuid + slua-type: uuid value: "03642e83-2bd1-4eb9-34b4-4c47ed586d2d" IMG_USE_BAKED_AUX3: tooltip: '' type: string - luaType: uuid + slua-type: uuid value: "edd51b77-fc10-ce7a-4b3d-011dfc349e4f" IMG_USE_BAKED_EYES: tooltip: '' type: string - luaType: uuid + slua-type: uuid value: "52cc6bb6-2ee5-e632-d3ad-50197b1dcb8a" IMG_USE_BAKED_HAIR: tooltip: '' type: string - luaType: uuid + slua-type: uuid value: "09aac1fb-6bce-0bee-7d44-caac6dbb6c63" IMG_USE_BAKED_HEAD: tooltip: '' type: string - luaType: uuid + slua-type: uuid value: "5a9f4a74-30f2-821c-b88d-70499d3e7183" IMG_USE_BAKED_LEFTARM: tooltip: '' type: string - luaType: uuid + slua-type: uuid value: "ff62763f-d60a-9855-890b-0c96f8f8cd98" IMG_USE_BAKED_LEFTLEG: tooltip: '' type: string - luaType: uuid + slua-type: uuid value: "8e915e25-31d1-cc95-ae08-d58a47488251" IMG_USE_BAKED_LOWER: tooltip: '' type: string - luaType: uuid + slua-type: uuid value: "24daea5f-0539-cfcf-047f-fbc40b2786ba" IMG_USE_BAKED_SKIRT: tooltip: '' type: string - luaType: uuid + slua-type: uuid value: "43529ce8-7faa-ad92-165a-bc4078371687" IMG_USE_BAKED_UPPER: tooltip: '' type: string - luaType: uuid + slua-type: uuid value: "ae2de45c-d252-50b8-5c6e-19f39ce79317" INVENTORY_ALL: tooltip: '' @@ -1526,7 +1526,7 @@ constants: NULL_KEY: tooltip: '' type: string - luaType: uuid + slua-type: uuid value: "00000000-0000-0000-0000-000000000000" OBJECT_ACCOUNT_LEVEL: tooltip: Retrieves the account level of an avatar.\nReturns 0 when the avatar @@ -3909,27 +3909,27 @@ constants: TEXTURE_BLANK: tooltip: '' type: string - luaType: uuid + slua-type: uuid value: "5748decc-f629-461c-9a36-a35a221fe21f" TEXTURE_DEFAULT: tooltip: '' type: string - luaType: uuid + slua-type: uuid value: "89556747-24cb-43ed-920b-47caed15465f" TEXTURE_MEDIA: tooltip: '' type: string - luaType: uuid + slua-type: uuid value: "8b5fec65-8d8d-9dc5-cda8-8fdf2716e361" TEXTURE_PLYWOOD: tooltip: '' type: string - luaType: uuid + slua-type: uuid value: "89556747-24cb-43ed-920b-47caed15465f" TEXTURE_TRANSPARENT: tooltip: '' type: string - luaType: uuid + slua-type: uuid value: "8dcd4a48-2d37-4909-9f78-f7a9eb4ef903" TOUCH_INVALID_FACE: tooltip: '' @@ -4607,7 +4607,7 @@ events: - ID: tooltip: '' type: key - luaType: string + slua-type: string tooltip: Triggered when object receives a link message via llMessageLinked function call. linkset_data: @@ -4806,9 +4806,9 @@ functions: # sleep: Additional sleep time imposed by the script after this function completes. # mono-sleep: Sleep in the mono script runtime # return: Return type of the function. -# lua-return: More specific return type for lua type-checking. -# lua-type: More specific argument type for lua type-checking. -# type-arguments: An array of strings naming the type variables used for generic type-checking this function. +# slua-return: More specific return type for slua type-checking. +# slua-type: More specific argument type for slua type-checking. +# type-arguments: An array of strings naming the type variables used for generic type-checking this slua function. # arguments: An array of maps of maps describing the parameters to this function. # tooltip: A brief description of this function. Map of maps is used to retain ordering. # func-id: The LSO function identifier, (See comment at the top of this file.) @@ -4923,7 +4923,7 @@ functions: - Flag: tooltip: Boolean, If TRUE allows anyone to drop inventory on prim, FALSE revokes. type: integer - luaType: numeric + slua-type: numeric bool-semantics: true energy: 10.0 func-id: 176 @@ -4954,7 +4954,7 @@ functions: tooltip: Boolean, if TRUE, force is treated as a local directional vector instead of region directional vector. type: integer - luaType: numeric + slua-type: numeric bool-semantics: true energy: 10.0 func-id: 72 @@ -4971,7 +4971,7 @@ functions: - Local: tooltip: Boolean, if TRUE, uses local axis, if FALSE, uses region axis. type: integer - luaType: numeric + slua-type: numeric bool-semantics: true energy: 10.0 func-id: 73 @@ -5139,7 +5139,7 @@ functions: func-id: 196 pure: true return: list - luaReturn: '{string}' + slua-return: '{string}' sleep: 0.0 tooltip: Create a list from a string of comma separated values specified in Text. llCastRay: @@ -5453,12 +5453,12 @@ functions: \ case the second item will be the value associated with the key.\n \ \ " llDeleteSubList: - typeParameters: [T] + type-arguments: [T] arguments: - Source: tooltip: '' type: list - luaType: '{T}' + slua-type: '{T}' - Start: index-semantics: true tooltip: '' @@ -5472,7 +5472,7 @@ functions: native: true pure: true return: list - luaReturn: '{T}' + slua-return: '{T}' sleep: 0.0 tooltip: Removes the slice from start to end and returns the remainder of the list.\nRemove a slice from the list and return the remainder, start and end @@ -6029,7 +6029,7 @@ functions: be forced into mouse-look mode.\nFALSE is the default setting and will undo a previously set TRUE or do nothing. type: integer - luaType: numeric + slua-type: numeric bool-semantics: true energy: 10.0 func-id: 294 @@ -6207,7 +6207,7 @@ functions: energy: 10.0 func-id: 523 return: list - luaReturn: '{uuid}' + slua-return: '{uuid}' sleep: 0.0 tooltip: Returns a list of keys of all visible (not HUD) attachments on the avatar identified by the ID argument @@ -6223,7 +6223,7 @@ functions: energy: 10.0 func-id: 518 return: list - luaReturn: '{uuid}' + slua-return: '{uuid}' sleep: 0.0 tooltip: Retrieves a list of attachments on an avatar. must-use: true @@ -6235,7 +6235,7 @@ functions: energy: 10.0 func-id: 277 return: list - luaReturn: '{vector}' + slua-return: '{vector}' sleep: 0.0 tooltip: Returns the bounding box around the object (including any linked prims) relative to its root prim, as a list in the format [ (vector) min_corner, (vector) @@ -7106,7 +7106,7 @@ functions: by the parcel. If TRUE then it is the combined number of prims on all parcels in the region owned by the specified parcel's owner. type: integer - luaType: numeric + slua-type: numeric bool-semantics: true energy: 10.0 func-id: 326 @@ -7138,7 +7138,7 @@ functions: by the parcel. If TRUE then it is the combined number of prims on all parcels in the region owned by the specified parcel's owner. type: integer - luaType: numeric + slua-type: numeric bool-semantics: true energy: 10.0 func-id: 325 @@ -7815,7 +7815,7 @@ functions: - Water: tooltip: Boolean, if TRUE then hover above water too. type: integer - luaType: numeric + slua-type: numeric bool-semantics: true - Tau: tooltip: Seconds to critically damp in. @@ -8174,7 +8174,7 @@ functions: tooltip: 'Boolean, sound queuing for the linked prim: TRUE enables, FALSE disables (default).' type: integer - luaType: numeric + slua-type: numeric bool-semantics: true energy: 10.0 func-id: 537 @@ -8470,12 +8470,12 @@ functions: specified list. If Index describes a location not in the list, or the value cannot be type-cast to a key, then null string is returned. llList2List: - typeParameters: [T] + type-arguments: [T] arguments: - ListVariable: tooltip: '' type: list - luaType: '{T}' + slua-type: '{T}' - Start: index-semantics: true tooltip: '' @@ -8489,7 +8489,7 @@ functions: native: true pure: true return: list - luaReturn: '{T}' + slua-return: '{T}' sleep: 0.0 tooltip: Returns a subset of entries from ListVariable, in a range specified by the Start and End indicies (inclusive).\nUsing negative numbers for Start and/or @@ -8497,12 +8497,12 @@ functions: -1 would capture the entire string.\nIf Start is greater than End, the sub string is the exclusion of the entries. llList2ListSlice: - typeParameters: [T] + type-arguments: [T] arguments: - ListVariable: tooltip: '' type: list - luaType: '{T}' + slua-type: '{T}' - Start: index-semantics: true tooltip: '' @@ -8521,7 +8521,7 @@ functions: energy: 10.0 func-id: 801 return: list - luaReturn: '{T}' + slua-return: '{T}' sleep: 0.0 tooltip: Returns a subset of entries from ListVariable, in a range specified by Start and End indices (inclusive) return the slice_index element of each stride.\n @@ -8533,12 +8533,12 @@ functions: (e.g. A stride of 2 has valid indices 0,1) must-use: true llList2ListStrided: - typeParameters: [T] + type-arguments: [T] arguments: - ListVariable: tooltip: '' type: list - luaType: '{T}' + slua-type: '{T}' - Start: index-semantics: true tooltip: '' @@ -8553,7 +8553,7 @@ functions: energy: 10.0 func-id: 198 return: list - luaReturn: '{T}' + slua-return: '{T}' sleep: 0.0 tooltip: Copies the strided slice of the list from Start to End.\nReturns a copy of the strided slice of the specified list from Start to End. @@ -8679,16 +8679,16 @@ functions: ListVariable by stride. Returns -1 if not found. must-use: true llListInsertList: - typeParameters: [T] + type-arguments: [T] arguments: - Target: tooltip: '' type: list - luaType: '{T}' + slua-type: '{T}' - ListVariable: tooltip: '' type: list - luaType: '{T}' + slua-type: '{T}' - Position: index-semantics: true tooltip: '' @@ -8698,42 +8698,42 @@ functions: native: true pure: true return: list - luaReturn: '{T}' + slua-return: '{T}' sleep: 0.0 tooltip: Returns a list that contains all the elements from Target but with the elements from ListVariable inserted at Position start.\nReturns a new list, created by inserting ListVariable into the Target list at Position. Note this does not alter the Target. llListRandomize: - typeParameters: [T] + type-arguments: [T] arguments: - ListVariable: tooltip: '' type: list - luaType: '{T}' + slua-type: '{T}' - Stride: tooltip: '' type: integer energy: 10.0 func-id: 197 return: list - luaReturn: '{T}' + slua-return: '{T}' sleep: 0.0 tooltip: Returns a version of the input ListVariable which has been randomized by blocks of size Stride.\nIf the remainder from the length of the list, divided by the stride is non-zero, this function does not randomize the list. must-use: true llListReplaceList: - typeParameters: [T] + type-arguments: [T] arguments: - Target: tooltip: '' type: list - luaType: '{T}' + slua-type: '{T}' - ListVariable: tooltip: '' type: list - luaType: '{T}' + slua-type: '{T}' - Start: tooltip: '' type: integer @@ -8747,7 +8747,7 @@ functions: native: true pure: true return: list - luaReturn: '{T}' + slua-return: '{T}' sleep: 0.0 tooltip: Returns a list that is Target with Start through End removed and ListVariable inserted at Start.\nReturns a list replacing the slice of the Target list from @@ -8755,12 +8755,12 @@ functions: 0, 1 would replace the first two entries and 0, 0 would replace only the first list entry. llListSort: - typeParameters: [T] + type-arguments: [T] arguments: - ListVariable: tooltip: List to sort. type: list - luaType: '{T}' + slua-type: '{T}' - Stride: tooltip: Stride length. type: integer @@ -8768,24 +8768,24 @@ functions: tooltip: Boolean. TRUE = result in ascending order, FALSE = result in descending order. type: integer - luaType: numeric + slua-type: numeric bool-semantics: true energy: 10.0 func-id: 184 return: list - luaReturn: '{T}' + slua-return: '{T}' sleep: 0.0 tooltip: Returns the specified list, sorted into blocks of stride in ascending order (if Ascending is TRUE, otherwise descending). Note that sort only works if the first entry of each block is the same datatype. must-use: true llListSortStrided: - typeParameters: [T] + type-arguments: [T] arguments: - ListVariable: tooltip: List to sort. type: list - luaType: '{T}' + slua-type: '{T}' - Stride: tooltip: Stride length. type: integer @@ -8797,12 +8797,12 @@ functions: tooltip: Boolean. TRUE = result in ascending order, FALSE = result in descending order. type: integer - luaType: numeric + slua-type: numeric bool-semantics: true energy: 10.0 func-id: 802 return: list - luaReturn: '{T}' + slua-return: '{T}' sleep: 0.0 tooltip: Returns the specified list, sorted by the specified element into blocks of stride in ascending order (if Ascending is TRUE, otherwise descending). Note @@ -9211,11 +9211,11 @@ functions: - Text: tooltip: '' type: string - luaType: string | uuid + slua-type: string | uuid - ID: tooltip: '' type: key - luaType: string | uuid + slua-type: string | uuid energy: 10.0 func-id: 164 return: void @@ -9424,16 +9424,16 @@ functions: - Separators: tooltip: '' type: list - luaType: '{string}' + slua-type: '{string}' - Spacers: tooltip: '' type: list - luaType: '{string}' + slua-type: '{string}' energy: 10.0 func-id: 214 pure: true return: list - luaReturn: '{string}' + slua-return: '{string}' sleep: 0.0 tooltip: Converts Text into a list, discarding Separators, keeping Spacers (Separators and Spacers must be lists of strings, maximum of 8 each).\nSeparators and Spacers @@ -9446,16 +9446,16 @@ functions: - Separators: tooltip: '' type: list - luaType: '{string}' + slua-type: '{string}' - Spacers: tooltip: '' type: list - luaType: '{string}' + slua-type: '{string}' energy: 10.0 func-id: 285 pure: true return: list - luaReturn: '{string}' + slua-return: '{string}' sleep: 0.0 tooltip: Breaks Text into a list, discarding separators, keeping spacers, keeping any null values generated. (separators and spacers must be lists of strings, @@ -9479,7 +9479,7 @@ functions: - Pass: tooltip: Boolean, if TRUE, collisions are passed from children on to parents. type: integer - luaType: numeric + slua-type: numeric bool-semantics: true energy: 10.0 func-id: 166 @@ -9494,7 +9494,7 @@ functions: - Pass: tooltip: Boolean, if TRUE, touches are passed from children on to parents. type: integer - luaType: numeric + slua-type: numeric bool-semantics: true energy: 10.0 func-id: 154 @@ -9782,7 +9782,7 @@ functions: - Running: tooltip: If the script should be set running in the target prim. type: integer - luaType: numeric + slua-type: numeric bool-semantics: true - StartParameter: tooltip: Integer. Parameter passed to the script if set to be running. @@ -10759,7 +10759,7 @@ functions: - Local: tooltip: Boolean, if TRUE uses local axis, if FALSE uses region axis. type: integer - luaType: numeric + slua-type: numeric bool-semantics: true energy: 10.0 func-id: 64 @@ -10778,7 +10778,7 @@ functions: - Local: tooltip: Boolean, if TRUE uses local axis, if FALSE uses region axis. type: integer - luaType: numeric + slua-type: numeric bool-semantics: true energy: 10.0 func-id: 76 @@ -10805,7 +10805,7 @@ functions: - Water: tooltip: Boolean, if TRUE then hover above water too. type: integer - luaType: numeric + slua-type: numeric bool-semantics: true - Tau: tooltip: Seconds to critically damp in. @@ -11130,7 +11130,7 @@ functions: - ForSale: tooltip: If TRUE, the parcel is put up for sale. type: integer - luaType: numeric + slua-type: numeric bool-semantics: true - Options: tooltip: A list of options to set for the sale. @@ -11324,7 +11324,7 @@ functions: - Running: tooltip: '' type: integer - luaType: numeric + slua-type: numeric bool-semantics: true energy: 10.0 func-id: 148 @@ -11346,7 +11346,7 @@ functions: - QueueEnable: tooltip: 'Boolean, sound queuing: TRUE enables, FALSE disables (default).' type: integer - luaType: numeric + slua-type: numeric bool-semantics: true energy: 10.0 func-id: 208 @@ -11375,7 +11375,7 @@ functions: - Value: tooltip: '' type: integer - luaType: numeric + slua-type: numeric bool-semantics: true energy: 10.0 func-id: 45 @@ -11464,7 +11464,7 @@ functions: - Local: tooltip: Boolean, if TRUE uses local axis, if FALSE uses region axis. type: integer - luaType: numeric + slua-type: numeric bool-semantics: true energy: 10.0 func-id: 74 @@ -11856,12 +11856,12 @@ functions: - Accept: tooltip: Boolean, determines whether control events are generated. type: integer - luaType: numeric + slua-type: numeric bool-semantics: true - PassOn: tooltip: Boolean, determines whether controls are disabled. type: integer - luaType: numeric + slua-type: numeric bool-semantics: true energy: 10.0 func-id: 111 @@ -12249,7 +12249,7 @@ functions: - DetectEnabled: tooltip: TRUE enables, FALSE disables. type: integer - luaType: numeric + slua-type: numeric bool-semantics: true energy: 10.0 func-id: 248 From e82156115e60647b6ed19a4bc866a117ae97d9b3 Mon Sep 17 00:00:00 2001 From: tapple Date: Wed, 14 Jan 2026 05:58:32 -0800 Subject: [PATCH 007/102] slua-type: numeric is redundant with bool-semantics --- lsl_definitions.yaml | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/lsl_definitions.yaml b/lsl_definitions.yaml index 9e5402e..f7f4a0f 100644 --- a/lsl_definitions.yaml +++ b/lsl_definitions.yaml @@ -4923,7 +4923,6 @@ functions: - Flag: tooltip: Boolean, If TRUE allows anyone to drop inventory on prim, FALSE revokes. type: integer - slua-type: numeric bool-semantics: true energy: 10.0 func-id: 176 @@ -4954,7 +4953,6 @@ functions: tooltip: Boolean, if TRUE, force is treated as a local directional vector instead of region directional vector. type: integer - slua-type: numeric bool-semantics: true energy: 10.0 func-id: 72 @@ -4971,7 +4969,6 @@ functions: - Local: tooltip: Boolean, if TRUE, uses local axis, if FALSE, uses region axis. type: integer - slua-type: numeric bool-semantics: true energy: 10.0 func-id: 73 @@ -6029,7 +6026,6 @@ functions: be forced into mouse-look mode.\nFALSE is the default setting and will undo a previously set TRUE or do nothing. type: integer - slua-type: numeric bool-semantics: true energy: 10.0 func-id: 294 @@ -7106,7 +7102,6 @@ functions: by the parcel. If TRUE then it is the combined number of prims on all parcels in the region owned by the specified parcel's owner. type: integer - slua-type: numeric bool-semantics: true energy: 10.0 func-id: 326 @@ -7138,7 +7133,6 @@ functions: by the parcel. If TRUE then it is the combined number of prims on all parcels in the region owned by the specified parcel's owner. type: integer - slua-type: numeric bool-semantics: true energy: 10.0 func-id: 325 @@ -7815,7 +7809,6 @@ functions: - Water: tooltip: Boolean, if TRUE then hover above water too. type: integer - slua-type: numeric bool-semantics: true - Tau: tooltip: Seconds to critically damp in. @@ -8174,7 +8167,6 @@ functions: tooltip: 'Boolean, sound queuing for the linked prim: TRUE enables, FALSE disables (default).' type: integer - slua-type: numeric bool-semantics: true energy: 10.0 func-id: 537 @@ -8768,7 +8760,6 @@ functions: tooltip: Boolean. TRUE = result in ascending order, FALSE = result in descending order. type: integer - slua-type: numeric bool-semantics: true energy: 10.0 func-id: 184 @@ -8797,7 +8788,6 @@ functions: tooltip: Boolean. TRUE = result in ascending order, FALSE = result in descending order. type: integer - slua-type: numeric bool-semantics: true energy: 10.0 func-id: 802 @@ -9479,7 +9469,6 @@ functions: - Pass: tooltip: Boolean, if TRUE, collisions are passed from children on to parents. type: integer - slua-type: numeric bool-semantics: true energy: 10.0 func-id: 166 @@ -9494,7 +9483,6 @@ functions: - Pass: tooltip: Boolean, if TRUE, touches are passed from children on to parents. type: integer - slua-type: numeric bool-semantics: true energy: 10.0 func-id: 154 @@ -9782,7 +9770,6 @@ functions: - Running: tooltip: If the script should be set running in the target prim. type: integer - slua-type: numeric bool-semantics: true - StartParameter: tooltip: Integer. Parameter passed to the script if set to be running. @@ -10759,7 +10746,6 @@ functions: - Local: tooltip: Boolean, if TRUE uses local axis, if FALSE uses region axis. type: integer - slua-type: numeric bool-semantics: true energy: 10.0 func-id: 64 @@ -10778,7 +10764,6 @@ functions: - Local: tooltip: Boolean, if TRUE uses local axis, if FALSE uses region axis. type: integer - slua-type: numeric bool-semantics: true energy: 10.0 func-id: 76 @@ -10805,7 +10790,6 @@ functions: - Water: tooltip: Boolean, if TRUE then hover above water too. type: integer - slua-type: numeric bool-semantics: true - Tau: tooltip: Seconds to critically damp in. @@ -11130,7 +11114,6 @@ functions: - ForSale: tooltip: If TRUE, the parcel is put up for sale. type: integer - slua-type: numeric bool-semantics: true - Options: tooltip: A list of options to set for the sale. @@ -11324,7 +11307,6 @@ functions: - Running: tooltip: '' type: integer - slua-type: numeric bool-semantics: true energy: 10.0 func-id: 148 @@ -11346,7 +11328,6 @@ functions: - QueueEnable: tooltip: 'Boolean, sound queuing: TRUE enables, FALSE disables (default).' type: integer - slua-type: numeric bool-semantics: true energy: 10.0 func-id: 208 @@ -11375,7 +11356,6 @@ functions: - Value: tooltip: '' type: integer - slua-type: numeric bool-semantics: true energy: 10.0 func-id: 45 @@ -11464,7 +11444,6 @@ functions: - Local: tooltip: Boolean, if TRUE uses local axis, if FALSE uses region axis. type: integer - slua-type: numeric bool-semantics: true energy: 10.0 func-id: 74 @@ -11856,12 +11835,10 @@ functions: - Accept: tooltip: Boolean, determines whether control events are generated. type: integer - slua-type: numeric bool-semantics: true - PassOn: tooltip: Boolean, determines whether controls are disabled. type: integer - slua-type: numeric bool-semantics: true energy: 10.0 func-id: 111 @@ -12249,7 +12226,6 @@ functions: - DetectEnabled: tooltip: TRUE enables, FALSE disables. type: integer - slua-type: numeric bool-semantics: true energy: 10.0 func-id: 248 From 742433d9cf9bf1434e305b08256bf9c9150146f4 Mon Sep 17 00:00:00 2001 From: tapple Date: Wed, 14 Jan 2026 06:27:46 -0800 Subject: [PATCH 008/102] consistently put bool/index-semantics and slua-type after type --- lsl_definitions.yaml | 128 +++++++++++++++++++++---------------------- 1 file changed, 64 insertions(+), 64 deletions(-) diff --git a/lsl_definitions.yaml b/lsl_definitions.yaml index f7f4a0f..3c8f825 100644 --- a/lsl_definitions.yaml +++ b/lsl_definitions.yaml @@ -4882,9 +4882,9 @@ functions: llAdjustDamage: arguments: - Number: - index-semantics: true tooltip: Damage event index to modify. type: integer + index-semantics: true - Damage: tooltip: New damage amount to apply on this event. type: float @@ -4909,11 +4909,11 @@ functions: - AgentID: tooltip: '' type: key - bool-semantics: true energy: 10.0 experience: true func-id: 392 return: integer + bool-semantics: true sleep: 0.0 tooltip: "\n Returns TRUE if the agent is in the Experience\ \ and the Experience can run in the current location.\n " @@ -5457,13 +5457,13 @@ functions: type: list slua-type: '{T}' - Start: - index-semantics: true tooltip: '' type: integer - - End: index-semantics: true + - End: tooltip: '' type: integer + index-semantics: true energy: 10.0 func-id: 193 native: true @@ -5483,13 +5483,13 @@ functions: tooltip: '' type: string - Start: - index-semantics: true tooltip: '' type: integer - - End: index-semantics: true + - End: tooltip: '' type: integer + index-semantics: true energy: 10.0 func-id: 95 pure: true @@ -5508,10 +5508,10 @@ functions: - flags: tooltip: Flags for derez behavior. type: integer - bool-semantics: true energy: 10.0 func-id: 509 return: integer + bool-semantics: true sleep: 0.0 tooltip: Derezzes an object previously rezzed by a script in this region. Returns TRUE on success or FALSE if the object could not be derezzed. @@ -5525,9 +5525,9 @@ functions: llDetectedDamage: arguments: - Number: - index-semantics: true tooltip: '' type: integer + index-semantics: true energy: 10.0 func-id: 554 return: list @@ -5538,9 +5538,9 @@ functions: llDetectedGrab: arguments: - Number: - index-semantics: true tooltip: '' type: integer + index-semantics: true energy: 10.0 func-id: 37 return: vector @@ -5551,9 +5551,9 @@ functions: llDetectedGroup: arguments: - Number: - index-semantics: true tooltip: '' type: integer + index-semantics: true energy: 10.0 func-id: 39 return: integer @@ -5566,9 +5566,9 @@ functions: llDetectedKey: arguments: - Number: - index-semantics: true tooltip: '' type: integer + index-semantics: true energy: 10.0 func-id: 32 return: key @@ -5579,9 +5579,9 @@ functions: llDetectedLinkNumber: arguments: - Number: - index-semantics: true tooltip: '' type: integer + index-semantics: true energy: 10.0 func-id: 40 # Note that the return does NOT have index semantics, link numbers are already one-indexed (sort of) @@ -5594,9 +5594,9 @@ functions: llDetectedName: arguments: - Number: - index-semantics: true tooltip: '' type: integer + index-semantics: true energy: 10.0 func-id: 31 return: string @@ -5607,9 +5607,9 @@ functions: llDetectedOwner: arguments: - Number: - index-semantics: true tooltip: '' type: integer + index-semantics: true energy: 10.0 func-id: 33 return: key @@ -5620,9 +5620,9 @@ functions: llDetectedPos: arguments: - Number: - index-semantics: true tooltip: '' type: integer + index-semantics: true energy: 10.0 func-id: 35 return: vector @@ -5633,9 +5633,9 @@ functions: llDetectedRezzer: arguments: - Number: - index-semantics: true tooltip: '' type: integer + index-semantics: true energy: 10.0 func-id: 553 return: key @@ -5645,9 +5645,9 @@ functions: llDetectedRot: arguments: - Number: - index-semantics: true tooltip: '' type: integer + index-semantics: true energy: 10.0 func-id: 38 return: rotation @@ -5658,9 +5658,9 @@ functions: llDetectedTouchBinormal: arguments: - Index: - index-semantics: true tooltip: Index of detection information type: integer + index-semantics: true energy: 10.0 func-id: 341 return: vector @@ -5672,9 +5672,9 @@ functions: llDetectedTouchFace: arguments: - Index: - index-semantics: true tooltip: Index of detection information type: integer + index-semantics: true energy: 10.0 func-id: 338 # NOTE: We can't change face number indexing easily because it's part of the viewer, so no index semantics for ret... @@ -5686,9 +5686,9 @@ functions: llDetectedTouchNormal: arguments: - Index: - index-semantics: true tooltip: Index of detection information type: integer + index-semantics: true energy: 10.0 func-id: 340 return: vector @@ -5700,9 +5700,9 @@ functions: llDetectedTouchPos: arguments: - Index: - index-semantics: true tooltip: Index of detected information type: integer + index-semantics: true energy: 10.0 func-id: 339 return: vector @@ -5714,9 +5714,9 @@ functions: llDetectedTouchST: arguments: - Index: - index-semantics: true tooltip: Index of detection information type: integer + index-semantics: true energy: 10.0 func-id: 342 return: vector @@ -5730,9 +5730,9 @@ functions: llDetectedTouchUV: arguments: - Index: - index-semantics: true tooltip: Index of detection information type: integer + index-semantics: true energy: 10.0 func-id: 337 return: vector @@ -5745,9 +5745,9 @@ functions: llDetectedType: arguments: - Number: - index-semantics: true tooltip: '' type: integer + index-semantics: true energy: 10.0 func-id: 34 return: integer @@ -5760,9 +5760,9 @@ functions: llDetectedVel: arguments: - Number: - index-semantics: true tooltip: '' type: integer + index-semantics: true energy: 10.0 func-id: 36 return: vector @@ -5834,10 +5834,10 @@ functions: - Direction: tooltip: '' type: vector - bool-semantics: true energy: 10.0 func-id: 205 return: integer + bool-semantics: true sleep: 0.0 tooltip: Checks to see whether the border hit by Direction from Position is the edge of the world (has no neighboring region).\nReturns TRUE if the line along @@ -6569,9 +6569,9 @@ functions: tooltip: Inventory item type type: integer - Index: - index-semantics: true tooltip: Index number of inventory item. type: integer + index-semantics: true energy: 10.0 func-id: 147 return: string @@ -6746,9 +6746,9 @@ functions: tooltip: '' type: list - Index: - index-semantics: true tooltip: '' type: integer + index-semantics: true energy: 10.0 func-id: 194 native: true @@ -6876,9 +6876,9 @@ functions: tooltip: '' type: string - LineNumber: - index-semantics: true tooltip: '' type: integer + index-semantics: true energy: 10.0 func-id: 217 return: key @@ -6894,9 +6894,9 @@ functions: tooltip: '' type: string - LineNumber: - index-semantics: true tooltip: '' type: integer + index-semantics: true energy: 10.0 func-id: 549 return: string @@ -7415,10 +7415,10 @@ functions: - ScriptName: tooltip: '' type: string - bool-semantics: true energy: 10.0 func-id: 250 return: integer + bool-semantics: true sleep: 0.0 tooltip: Returns TRUE if the script named is running.\nReturns TRUE if ScriptName is running. @@ -7492,8 +7492,8 @@ functions: type: integer energy: 10.0 func-id: 46 - bool-semantics: true return: integer + bool-semantics: true sleep: 0.0 tooltip: Returns boolean value of the specified status (e.g. STATUS_PHANTOM) of the object the script is attached to. @@ -7504,13 +7504,13 @@ functions: tooltip: '' type: string - Start: - index-semantics: true tooltip: '' type: integer - - End: index-semantics: true + - End: tooltip: '' type: integer + index-semantics: true energy: 10.0 func-id: 94 pure: true @@ -7908,9 +7908,9 @@ functions: tooltip: '' type: string - Position: - index-semantics: true tooltip: '' type: integer + index-semantics: true - SourceVariable: tooltip: '' type: string @@ -7953,10 +7953,10 @@ functions: - agent_id: tooltip: Agent ID of another agent in the region. type: key - bool-semantics: true energy: 10.0 func-id: 542 return: integer + bool-semantics: true sleep: 0.0 tooltip: Returns TRUE if avatar ID is a friend of the script owner. must-use: true @@ -8064,9 +8064,9 @@ functions: llKeysKeyValue: arguments: - First: - index-semantics: true tooltip: Index of the first key to return. type: integer + index-semantics: true - Count: tooltip: The number of keys to return. type: integer @@ -8398,9 +8398,9 @@ functions: tooltip: '' type: list - Index: - index-semantics: true tooltip: '' type: integer + index-semantics: true energy: 10.0 func-id: 187 native: true @@ -8416,9 +8416,9 @@ functions: tooltip: '' type: list - Index: - index-semantics: true tooltip: '' type: integer + index-semantics: true energy: 10.0 func-id: 186 native: true @@ -8449,9 +8449,9 @@ functions: tooltip: '' type: list - Index: - index-semantics: true tooltip: '' type: integer + index-semantics: true energy: 10.0 func-id: 189 native: true @@ -8469,13 +8469,13 @@ functions: type: list slua-type: '{T}' - Start: - index-semantics: true tooltip: '' type: integer - - End: index-semantics: true + - End: tooltip: '' type: integer + index-semantics: true energy: 10.0 func-id: 192 native: true @@ -8496,20 +8496,20 @@ functions: type: list slua-type: '{T}' - Start: - index-semantics: true tooltip: '' type: integer - - End: index-semantics: true + - End: tooltip: '' type: integer + index-semantics: true - Stride: tooltip: '' type: integer - slice_index: - index-semantics: true tooltip: '' type: integer + index-semantics: true energy: 10.0 func-id: 801 return: list @@ -8532,13 +8532,13 @@ functions: type: list slua-type: '{T}' - Start: - index-semantics: true tooltip: '' type: integer - - End: index-semantics: true + - End: tooltip: '' type: integer + index-semantics: true - Stride: tooltip: '' type: integer @@ -8556,9 +8556,9 @@ functions: tooltip: '' type: list - Index: - index-semantics: true tooltip: '' type: integer + index-semantics: true energy: 10.0 func-id: 191 native: true @@ -8574,9 +8574,9 @@ functions: tooltip: '' type: list - Index: - index-semantics: true tooltip: '' type: integer + index-semantics: true energy: 10.0 func-id: 188 native: true @@ -8592,9 +8592,9 @@ functions: tooltip: '' type: list - Index: - index-semantics: true tooltip: '' type: integer + index-semantics: true energy: 10.0 func-id: 190 native: true @@ -8614,8 +8614,8 @@ functions: type: list energy: 10.0 func-id: 201 - index-semantics: true return: integer + index-semantics: true sleep: 0.0 tooltip: Returns the index of the first instance of Find in ListVariable. Returns -1 if not found.\nReturns the position of the first instance of the Find list @@ -8630,13 +8630,13 @@ functions: tooltip: '' type: list - Instance: - index-semantics: true tooltip: '' type: integer + index-semantics: true energy: 10.0 func-id: 803 - index-semantics: true return: integer + index-semantics: true sleep: 0.0 tooltip: Returns the index of the nth instance of Find in ListVariable. Returns -1 if not found. @@ -8650,20 +8650,20 @@ functions: tooltip: '' type: list - Start: - index-semantics: true tooltip: '' type: integer - - End: index-semantics: true + - End: tooltip: '' type: integer + index-semantics: true - Stride: tooltip: '' type: integer energy: 10.0 func-id: 800 - index-semantics: true return: integer + index-semantics: true sleep: 0.0 tooltip: Returns the index of the first instance of Find in ListVariable. Returns -1 if not found.\nReturns the position of the first instance of the Find list @@ -8682,9 +8682,9 @@ functions: type: list slua-type: '{T}' - Position: - index-semantics: true tooltip: '' type: integer + index-semantics: true energy: 10.0 func-id: 200 native: true @@ -9361,10 +9361,10 @@ functions: - ID: tooltip: '' type: key - bool-semantics: true energy: 10.0 func-id: 215 return: integer + bool-semantics: true sleep: 0.0 tooltip: Returns TRUE if id ID over land owned by the script owner, otherwise FALSE.\nReturns TRUE if key ID is over land owned by the object owner, FALSE @@ -10365,10 +10365,10 @@ functions: - ID: tooltip: '' type: key - bool-semantics: true energy: 10.0 func-id: 219 return: integer + bool-semantics: true sleep: 0.0 tooltip: Returns TRUE if avatar ID is in the same region and has the same active group, otherwise FALSE.\nReturns TRUE if the object or agent identified is in @@ -10430,10 +10430,10 @@ functions: - Position: tooltip: '' type: vector - bool-semantics: true energy: 10.0 func-id: 246 return: integer + bool-semantics: true sleep: 0.0 tooltip: Returns TRUE if Position is over public land, sandbox land, land that doesn't allow everyone to edit and build, or land that doesn't allow outside @@ -11065,10 +11065,10 @@ functions: tooltip: The amount to reserve, which must be less than the allowed maximum (currently 64KB) and not already have been exceeded. type: integer - bool-semantics: true energy: 10.0 func-id: 369 return: integer + bool-semantics: true sleep: 0.0 tooltip: Requests Limit bytes to be reserved for this script.\nReturns TRUE or FALSE indicating whether the limit was set successfully.\nThis function has @@ -11118,9 +11118,9 @@ functions: - Options: tooltip: A list of options to set for the sale. type: list - bool-semantics: true energy: 10.0 return: integer + bool-semantics: true sleep: 0.0 tooltip: Sets the parcel the object is on for sale.\nForSale is a boolean, if TRUE the parcel is put up for sale. Options is a list of options to set for @@ -11810,9 +11810,9 @@ functions: type: string energy: 10.0 func-id: 181 - index-semantics: true pure: true return: integer + index-semantics: true sleep: 0.0 tooltip: Returns an integer that is the index in Text where string pattern Sequence first appears. Returns -1 if not found. @@ -12213,10 +12213,10 @@ functions: - Algorithm: tooltip: 'The digest algorithm: sha1, sha224, sha256, sha384, sha512.' type: string - bool-semantics: true energy: 10.0 func-id: 540 return: integer + bool-semantics: true sleep: 0.0 tooltip: Returns TRUE if PublicKey, Message, and Algorithm produce the same base64-formatted Signature. From 82b14014bca852b8fa6aad348dc13f2c0be49a35 Mon Sep 17 00:00:00 2001 From: tapple Date: Wed, 14 Jan 2026 06:57:15 -0800 Subject: [PATCH 009/102] consistentl put name first in top-level dicts --- slua_definitions.yaml | 160 +++++++++++++++++++++--------------------- 1 file changed, 80 insertions(+), 80 deletions(-) diff --git a/slua_definitions.yaml b/slua_definitions.yaml index 4677e6f..e7641c8 100644 --- a/slua_definitions.yaml +++ b/slua_definitions.yaml @@ -1,5 +1,6 @@ classes: -- comment: 'Luau Type Definition for LSL UserData Type: quaternion' +- name: quaternion + comment: 'Luau Type Definition for LSL UserData Type: quaternion' methods: - name: __add parameters: @@ -39,7 +40,6 @@ classes: parameters: - name: self returnType: string - name: quaternion properties: - name: x type: number @@ -49,13 +49,13 @@ classes: type: number - name: s type: number -- comment: 'Luau Type Definition for LSL UserData Type: uuid' +- name: uuid + comment: 'Luau Type Definition for LSL UserData Type: uuid' methods: - name: __tostring parameters: - name: self returnType: string - name: uuid properties: - comment: Returns true if the UUID is not the null UUID (all zeros) name: istruthy @@ -64,7 +64,8 @@ classes: is not in a compressed state name: bytes type: string? -- comment: 'Luau Type Definition for LSL UserData Type: vector' +- name: vector + comment: 'Luau Type Definition for LSL UserData Type: vector' methods: - comment: Native component-wise addition name: __add @@ -113,7 +114,6 @@ classes: parameters: - name: self returnType: string - name: vector properties: - name: x type: number @@ -121,9 +121,9 @@ classes: type: number - name: z type: number -- comment: Event detection class providing access to detected object/avatar information +- name: LLDetectedEvent + comment: Event detection class providing access to detected object/avatar information methods: [] - name: LLDetectedEvent properties: - name: index type: number @@ -131,7 +131,8 @@ classes: type: boolean - name: canAdjustDamage type: boolean -- comment: Event registration and management class for Second Life events +- name: LLEvents + comment: Event registration and management class for Second Life events methods: - comment: Registers a callback for an event. Returns the callback. name: 'on' @@ -172,8 +173,8 @@ classes: parameters: - name: self returnType: '{string}' - name: LLEvents -- comment: Timer management class for scheduling periodic and one-time callbacks +- name: LLTimers + comment: Timer management class for scheduling periodic and one-time callbacks methods: - comment: Registers a callback to be called every N seconds. Returns the callback. name: every @@ -201,42 +202,41 @@ classes: - name: callback type: LLTimerCallback returnType: boolean - name: LLTimers constants: [] globalFunctions: -- comment: Dangerously executes a required module function - name: dangerouslyexecuterequiredmodule +- name: dangerouslyexecuterequiredmodule + comment: Dangerously executes a required module function parameters: - name: f type: (...any) -> ...any returnType: '...any' -- comment: Converts a string, buffer, or uuid to a uuid, returns nil if invalid - name: touuid +- name: touuid + comment: Converts a string, buffer, or uuid to a uuid, returns nil if invalid parameters: - name: val type: string | buffer | uuid returnType: uuid? -- comment: Converts a value to a vector, returns nil if invalid - name: tovector +- name: tovector + comment: Converts a value to a vector, returns nil if invalid parameters: - name: val type: any returnType: vector? -- comment: Converts a value to a quaternion, returns nil if invalid - name: toquaternion +- name: toquaternion + comment: Converts a value to a quaternion, returns nil if invalid parameters: - name: val type: any returnType: quaternion? -- comment: Converts a value to a rotation (quaternion), returns nil if invalid - name: torotation +- name: torotation + comment: Converts a value to a rotation (quaternion), returns nil if invalid parameters: - name: val type: any returnType: quaternion? globalVariables: -- comment: Global 'quaternion' library table with callable metatable - name: quaternion +- name: quaternion + comment: Global 'quaternion' library table with callable metatable type: callSignature: parameters: @@ -339,13 +339,13 @@ globalVariables: - name: q type: quaternion returnType: vector -- comment: '''rotation'' global is an alias to the ''quaternion'' library' - name: rotation +- name: rotation + comment: '''rotation'' global is an alias to the ''quaternion'' library' type: kind: typeof target: quaternion -- comment: Global 'uuid' library table - name: uuid +- name: uuid + comment: Global 'uuid' library table type: kind: table properties: @@ -379,8 +379,8 @@ globalVariables: - buffer - uuid returnType: uuid? -- comment: Global 'vector' library table - name: vector +- name: vector + comment: Global 'vector' library table type: kind: table properties: @@ -544,17 +544,18 @@ globalVariables: optional: true type: number returnType: vector -- comment: loadstring is removed in SLua - name: loadstring +- name: loadstring + comment: loadstring is removed in SLua type: nil -- comment: getfenv is removed in SLua - name: getfenv +- name: getfenv + comment: getfenv is removed in SLua type: nil -- comment: setfenv is removed in SLua - name: setfenv +- name: setfenv + comment: setfenv is removed in SLua type: nil modules: -- comment: Bitwise operations library +- name: bit32 + comment: Bitwise operations library functions: - comment: Arithmetic right shift name: arshift @@ -668,8 +669,8 @@ modules: - name: n type: number returnType: number - name: bit32 -- comment: Buffer manipulation library for binary data +- name: buffer + comment: Buffer manipulation library for binary data functions: - comment: Creates a new buffer of the specified size name: create @@ -913,8 +914,8 @@ modules: - name: value type: number returnType: () - name: buffer -- comment: Coroutine manipulation library +- name: coroutine + comment: Coroutine manipulation library functions: - comment: Creates a new coroutine from a function name: create @@ -962,8 +963,8 @@ modules: - name: co type: thread returnType: (boolean, string?) - name: coroutine -- comment: Debug library for introspection +- name: debug + comment: Debug library for introspection functions: - comment: Returns information about a function or stack level name: info @@ -1012,8 +1013,8 @@ modules: optional: true type: number returnType: string - name: debug -- comment: Base64 encoding/decoding library +- name: llbase64 + comment: Base64 encoding/decoding library functions: - comment: Encodes a string or buffer to base64 name: encode @@ -1036,8 +1037,8 @@ modules: - name: data type: string returnType: string - name: llbase64 -- comment: JSON encoding/decoding library for Second Life +- name: lljson + comment: JSON encoding/decoding library for Second Life functions: - comment: Encodes a Lua value as JSON name: encode @@ -1067,7 +1068,6 @@ modules: - name: json type: string returnType: any - name: lljson properties: - comment: A constant to pass for null to json encode name: 'null' @@ -1087,7 +1087,8 @@ modules: - comment: Version of the lljson library name: _VERSION type: string -- comment: Mathematical functions library +- name: math + comment: Mathematical functions library functions: - comment: Returns the absolute value of x name: abs @@ -1353,7 +1354,6 @@ modules: - name: x type: number returnType: boolean - name: math properties: - comment: The value of pi name: pi @@ -1361,7 +1361,8 @@ modules: - comment: A value larger than any other numeric value (infinity) name: huge type: number -- comment: Operating system facilities library +- name: os + comment: Operating system facilities library functions: - comment: Returns CPU time used by the program in seconds name: clock @@ -1393,8 +1394,8 @@ modules: optional: true type: OsDateTime returnType: number? - name: os -- comment: String manipulation library +- name: string + comment: String manipulation library functions: - comment: Returns the internal numeric codes of the characters name: byte @@ -1545,8 +1546,8 @@ modules: - name: s type: string returnType: string - name: string -- comment: Table manipulation library +- name: table + comment: Table manipulation library functions: - comment: Concatenates table elements into a string name: concat @@ -1717,8 +1718,8 @@ modules: - name: t type: '{[T]: U}' returnType: '{[T]: U}' - name: table -- comment: UTF-8 support library +- name: utf8 + comment: UTF-8 support library functions: - comment: Returns a string from UTF-8 codepoints name: char @@ -1768,24 +1769,24 @@ modules: optional: true type: number returnType: number? - name: utf8 properties: - comment: Pattern that matches exactly one UTF-8 byte sequence name: charpattern type: string typeAliases: -- comment: '''rotation'' is an alias for ''quaternion''' +- name: rotation + comment: '''rotation'' is an alias for ''quaternion''' definition: kind: reference name: quaternion - name: rotation -- definition: +- name: numeric + definition: kind: union types: - boolean - number - name: numeric -- definition: +- name: list + definition: elementType: kind: union types: @@ -1796,28 +1797,27 @@ typeAliases: - quaternion - boolean kind: array - name: list -- definition: +- name: LLDetectedEventName + definition: kind: literal-union values: [] - name: LLDetectedEventName -- definition: +- name: LLNonDetectedEventName + definition: kind: literal-union values: [] - name: LLNonDetectedEventName -- definition: +- name: LLEventName + definition: kind: union types: - LLDetectedEventName - LLNonDetectedEventName - name: LLEventName -- definition: +- name: LLEventHandler + definition: kind: function parameters: - type: any variadic: true returnType: () - name: LLEventHandler - definition: kind: function parameters: @@ -1827,7 +1827,8 @@ typeAliases: kind: array returnType: () name: LLDetectedEventHandler -- comment: Callback type for LLTimers.every() - receives scheduled time and interval +- name: LLTimerEveryCallback + comment: Callback type for LLTimers.every() - receives scheduled time and interval definition: kind: function parameters: @@ -1836,24 +1837,24 @@ typeAliases: - name: interval type: number returnType: () - name: LLTimerEveryCallback -- comment: Callback type for LLTimers.once() - receives scheduled time +- name: LLTimerOnceCallback + comment: Callback type for LLTimers.once() - receives scheduled time definition: kind: function parameters: - name: scheduled type: number returnType: () - name: LLTimerOnceCallback -- comment: Union of timer callback types +- name: LLTimerCallback + comment: Union of timer callback types definition: kind: union types: - LLTimerEveryCallback - LLTimerOnceCallback - (...any) -> ...any - name: LLTimerCallback -- comment: Date/time table structure used by os.date and os.time +- name: OsDateTime + comment: Date/time table structure used by os.date and os.time definition: kind: table properties: @@ -1881,5 +1882,4 @@ typeAliases: - name: isdst optional: true type: boolean - name: OsDateTime version: 1.0.0 From 885bb72b2530bbab400e9cd355fbbb52465a7181 Mon Sep 17 00:00:00 2001 From: tapple Date: Wed, 14 Jan 2026 07:13:04 -0800 Subject: [PATCH 010/102] consistently put name first in second-level dicts --- slua_definitions.yaml | 650 +++++++++++++++++++++--------------------- 1 file changed, 325 insertions(+), 325 deletions(-) diff --git a/slua_definitions.yaml b/slua_definitions.yaml index e7641c8..715afe9 100644 --- a/slua_definitions.yaml +++ b/slua_definitions.yaml @@ -57,54 +57,54 @@ classes: - name: self returnType: string properties: - - comment: Returns true if the UUID is not the null UUID (all zeros) - name: istruthy + - name: istruthy + comment: Returns true if the UUID is not the null UUID (all zeros) type: boolean - - comment: Returns the raw 16-byte binary string of the UUID, or nil if the UUID + - name: bytes + comment: Returns the raw 16-byte binary string of the UUID, or nil if the UUID is not in a compressed state - name: bytes type: string? - name: vector comment: 'Luau Type Definition for LSL UserData Type: vector' methods: - - comment: Native component-wise addition - name: __add + - name: __add + comment: Native component-wise addition parameters: - name: self - name: other type: vector returnType: vector - - comment: Native component-wise subtraction - name: __sub + - name: __sub + comment: Native component-wise subtraction parameters: - name: self - name: other type: vector returnType: vector - - comment: Unary negation - name: __unm + - name: __unm + comment: Unary negation parameters: - name: self returnType: vector - - comment: 'Multiplication: vector * vector / number -> vector (Scale), vector + - name: __mul + comment: 'Multiplication: vector * vector / number -> vector (Scale), vector * quaternion -> vector (Rotation)' luaReturnType: vector - name: __mul parameters: - name: self - name: other type: number | vector | quaternion returnType: vector - - comment: 'Division: vector / number -> vector (Scale), vector / quaternion -> + - name: __div + comment: 'Division: vector / number -> vector (Scale), vector / quaternion -> vector (Rotation by inverse)' - name: __div parameters: - name: self - name: other type: number | vector | quaternion returnType: vector - - comment: 'LSL-style modulo: vector % vector -> vector (Cross Product)' - name: __mod + - name: __mod + comment: 'LSL-style modulo: vector % vector -> vector (Cross Product)' parameters: - name: self - name: other @@ -134,8 +134,8 @@ classes: - name: LLEvents comment: Event registration and management class for Second Life events methods: - - comment: Registers a callback for an event. Returns the callback. - name: 'on' + - name: 'on' + comment: Registers a callback for an event. Returns the callback. parameters: - name: self - name: event @@ -143,8 +143,8 @@ classes: - name: callback type: LLEventHandler returnType: LLEventHandler - - comment: Unregisters a callback. Returns true if found and removed. - name: 'off' + - name: 'off' + comment: Unregisters a callback. Returns true if found and removed. parameters: - name: self - name: event @@ -152,8 +152,8 @@ classes: - name: callback type: LLEventHandler returnType: boolean - - comment: Registers a one-time callback. Returns the wrapper function. - name: once + - name: once + comment: Registers a one-time callback. Returns the wrapper function. parameters: - name: self - name: event @@ -161,23 +161,23 @@ classes: - name: callback type: LLEventHandler returnType: LLEventHandler - - comment: Returns a list of all listeners for a specific event. - name: listeners + - name: listeners + comment: Returns a list of all listeners for a specific event. parameters: - name: self - name: event type: LLEventName returnType: '{LLEventHandler}' - - comment: Returns a list of all event names that have listeners. - name: eventNames + - name: eventNames + comment: Returns a list of all event names that have listeners. parameters: - name: self returnType: '{string}' - name: LLTimers comment: Timer management class for scheduling periodic and one-time callbacks methods: - - comment: Registers a callback to be called every N seconds. Returns the callback. - name: every + - name: every + comment: Registers a callback to be called every N seconds. Returns the callback. parameters: - name: self - name: seconds @@ -185,9 +185,9 @@ classes: - name: callback type: LLTimerEveryCallback returnType: LLTimerCallback - - comment: Registers a callback to be called once after N seconds. Returns the + - name: once + comment: Registers a callback to be called once after N seconds. Returns the callback. - name: once parameters: - name: self - name: seconds @@ -195,8 +195,8 @@ classes: - name: callback type: LLTimerOnceCallback returnType: LLTimerCallback - - comment: Unregisters a timer callback. Returns true if found and removed. - name: 'off' + - name: 'off' + comment: Unregisters a timer callback. Returns true if found and removed. parameters: - name: self - name: callback @@ -557,46 +557,46 @@ modules: - name: bit32 comment: Bitwise operations library functions: - - comment: Arithmetic right shift - name: arshift + - name: arshift + comment: Arithmetic right shift parameters: - name: x type: number - name: disp type: number returnType: number - - comment: Bitwise AND of all arguments - name: band + - name: band + comment: Bitwise AND of all arguments parameters: - type: number variadic: true returnType: number - - comment: Bitwise NOT - name: bnot + - name: bnot + comment: Bitwise NOT parameters: - name: x type: number returnType: number - - comment: Bitwise OR of all arguments - name: bor + - name: bor + comment: Bitwise OR of all arguments parameters: - type: number variadic: true returnType: number - - comment: Bitwise XOR of all arguments - name: bxor + - name: bxor + comment: Bitwise XOR of all arguments parameters: - type: number variadic: true returnType: number - - comment: Returns true if bitwise AND of all arguments is not zero - name: btest + - name: btest + comment: Returns true if bitwise AND of all arguments is not zero parameters: - type: number variadic: true returnType: boolean - - comment: Extracts bits from n at position field with width - name: extract + - name: extract + comment: Extracts bits from n at position field with width parameters: - name: n type: number @@ -606,24 +606,24 @@ modules: optional: true type: number returnType: number - - comment: Left rotate - name: lrotate + - name: lrotate + comment: Left rotate parameters: - name: x type: number - name: disp type: number returnType: number - - comment: Left shift - name: lshift + - name: lshift + comment: Left shift parameters: - name: x type: number - name: disp type: number returnType: number - - comment: Replaces bits in n at position field with width using value v - name: replace + - name: replace + comment: Replaces bits in n at position field with width using value v parameters: - name: n type: number @@ -635,36 +635,36 @@ modules: optional: true type: number returnType: number - - comment: Right rotate - name: rrotate + - name: rrotate + comment: Right rotate parameters: - name: x type: number - name: disp type: number returnType: number - - comment: Right shift - name: rshift + - name: rshift + comment: Right shift parameters: - name: x type: number - name: disp type: number returnType: number - - comment: Count leading zeros - name: countlz + - name: countlz + comment: Count leading zeros parameters: - name: n type: number returnType: number - - comment: Count trailing zeros - name: countrz + - name: countrz + comment: Count trailing zeros parameters: - name: n type: number returnType: number - - comment: Swap byte order - name: byteswap + - name: byteswap + comment: Swap byte order parameters: - name: n type: number @@ -672,90 +672,90 @@ modules: - name: buffer comment: Buffer manipulation library for binary data functions: - - comment: Creates a new buffer of the specified size - name: create + - name: create + comment: Creates a new buffer of the specified size parameters: - name: size type: number returnType: buffer - - comment: Creates a buffer from a string - name: fromstring + - name: fromstring + comment: Creates a buffer from a string parameters: - name: str type: string returnType: buffer - - comment: Converts buffer to string - name: tostring + - name: tostring + comment: Converts buffer to string parameters: - name: b type: buffer returnType: string - - comment: Read signed 8-bit integer - name: readi8 + - name: readi8 + comment: Read signed 8-bit integer parameters: - name: b type: buffer - name: offset type: number returnType: number - - comment: Read unsigned 8-bit integer - name: readu8 + - name: readu8 + comment: Read unsigned 8-bit integer parameters: - name: b type: buffer - name: offset type: number returnType: number - - comment: Read signed 16-bit integer - name: readi16 + - name: readi16 + comment: Read signed 16-bit integer parameters: - name: b type: buffer - name: offset type: number returnType: number - - comment: Read unsigned 16-bit integer - name: readu16 + - name: readu16 + comment: Read unsigned 16-bit integer parameters: - name: b type: buffer - name: offset type: number returnType: number - - comment: Read signed 32-bit integer - name: readi32 + - name: readi32 + comment: Read signed 32-bit integer parameters: - name: b type: buffer - name: offset type: number returnType: number - - comment: Read unsigned 32-bit integer - name: readu32 + - name: readu32 + comment: Read unsigned 32-bit integer parameters: - name: b type: buffer - name: offset type: number returnType: number - - comment: Read 32-bit float - name: readf32 + - name: readf32 + comment: Read 32-bit float parameters: - name: b type: buffer - name: offset type: number returnType: number - - comment: Read 64-bit float - name: readf64 + - name: readf64 + comment: Read 64-bit float parameters: - name: b type: buffer - name: offset type: number returnType: number - - comment: Write signed 8-bit integer - name: writei8 + - name: writei8 + comment: Write signed 8-bit integer parameters: - name: b type: buffer @@ -764,8 +764,8 @@ modules: - name: value type: number returnType: () - - comment: Write unsigned 8-bit integer - name: writeu8 + - name: writeu8 + comment: Write unsigned 8-bit integer parameters: - name: b type: buffer @@ -774,8 +774,8 @@ modules: - name: value type: number returnType: () - - comment: Write signed 16-bit integer - name: writei16 + - name: writei16 + comment: Write signed 16-bit integer parameters: - name: b type: buffer @@ -784,8 +784,8 @@ modules: - name: value type: number returnType: () - - comment: Write unsigned 16-bit integer - name: writeu16 + - name: writeu16 + comment: Write unsigned 16-bit integer parameters: - name: b type: buffer @@ -794,8 +794,8 @@ modules: - name: value type: number returnType: () - - comment: Write signed 32-bit integer - name: writei32 + - name: writei32 + comment: Write signed 32-bit integer parameters: - name: b type: buffer @@ -804,8 +804,8 @@ modules: - name: value type: number returnType: () - - comment: Write unsigned 32-bit integer - name: writeu32 + - name: writeu32 + comment: Write unsigned 32-bit integer parameters: - name: b type: buffer @@ -814,8 +814,8 @@ modules: - name: value type: number returnType: () - - comment: Write 32-bit float - name: writef32 + - name: writef32 + comment: Write 32-bit float parameters: - name: b type: buffer @@ -824,8 +824,8 @@ modules: - name: value type: number returnType: () - - comment: Write 64-bit float - name: writef64 + - name: writef64 + comment: Write 64-bit float parameters: - name: b type: buffer @@ -834,8 +834,8 @@ modules: - name: value type: number returnType: () - - comment: Read string from buffer - name: readstring + - name: readstring + comment: Read string from buffer parameters: - name: b type: buffer @@ -844,8 +844,8 @@ modules: - name: count type: number returnType: string - - comment: Write string to buffer - name: writestring + - name: writestring + comment: Write string to buffer parameters: - name: b type: buffer @@ -857,14 +857,14 @@ modules: optional: true type: number returnType: () - - comment: Returns the length of the buffer - name: len + - name: len + comment: Returns the length of the buffer parameters: - name: b type: buffer returnType: number - - comment: Copy data from source buffer to target buffer - name: copy + - name: copy + comment: Copy data from source buffer to target buffer parameters: - name: target type: buffer @@ -879,8 +879,8 @@ modules: optional: true type: number returnType: () - - comment: Fill buffer with a value - name: fill + - name: fill + comment: Fill buffer with a value parameters: - name: b type: buffer @@ -892,8 +892,8 @@ modules: optional: true type: number returnType: () - - comment: Read bits from buffer - name: readbits + - name: readbits + comment: Read bits from buffer parameters: - name: b type: buffer @@ -902,8 +902,8 @@ modules: - name: bitCount type: number returnType: number - - comment: Write bits to buffer - name: writebits + - name: writebits + comment: Write bits to buffer parameters: - name: b type: buffer @@ -917,48 +917,48 @@ modules: - name: coroutine comment: Coroutine manipulation library functions: - - comment: Creates a new coroutine from a function - name: create + - name: create + comment: Creates a new coroutine from a function parameters: - name: f type: (...any) -> ...any returnType: thread - - comment: Resumes a coroutine, returns success and results - name: resume + - name: resume + comment: Resumes a coroutine, returns success and results parameters: - name: co type: thread - type: any variadic: true returnType: (boolean, ...any) - - comment: Returns the running coroutine, or nil if called from main thread - name: running + - name: running + comment: Returns the running coroutine, or nil if called from main thread parameters: [] returnType: thread? - - comment: Returns the status of a coroutine - name: status + - name: status + comment: Returns the status of a coroutine parameters: - name: co type: thread returnType: '"running" | "suspended" | "normal" | "dead"' - - comment: Creates a coroutine and returns a function that resumes it - name: wrap + - name: wrap + comment: Creates a coroutine and returns a function that resumes it parameters: - name: f type: (...any) -> ...any returnType: (...any) -> ...any - - comment: Suspends the coroutine and returns values to resume - name: yield + - name: yield + comment: Suspends the coroutine and returns values to resume parameters: - type: any variadic: true returnType: '...any' - - comment: Returns true if the coroutine can yield - name: isyieldable + - name: isyieldable + comment: Returns true if the coroutine can yield parameters: [] returnType: boolean - - comment: Closes a coroutine, returns success and optional error message - name: close + - name: close + comment: Closes a coroutine, returns success and optional error message parameters: - name: co type: thread @@ -966,8 +966,8 @@ modules: - name: debug comment: Debug library for introspection functions: - - comment: Returns information about a function or stack level - name: info + - name: info + comment: Returns information about a function or stack level overloads: - comment: Returns information about a stack level parameters: @@ -991,8 +991,8 @@ modules: - name: options type: string returnType: '...any' - - comment: Returns a string with a traceback of the call stack - name: traceback + - name: traceback + comment: Returns a string with a traceback of the call stack overloads: - comment: Returns a string with a traceback of the current call stack parameters: @@ -1016,14 +1016,14 @@ modules: - name: llbase64 comment: Base64 encoding/decoding library functions: - - comment: Encodes a string or buffer to base64 - name: encode + - name: encode + comment: Encodes a string or buffer to base64 parameters: - name: data type: string | buffer returnType: string - - comment: Decodes a base64 string to a string - name: decode + - name: decode + comment: Decodes a base64 string to a string overloads: - comment: Decodes a base64 string to a string or buffer parameters: @@ -1040,21 +1040,21 @@ modules: - name: lljson comment: JSON encoding/decoding library for Second Life functions: - - comment: Encodes a Lua value as JSON - name: encode + - name: encode + comment: Encodes a Lua value as JSON parameters: - name: value type: any returnType: string - - comment: Decodes a JSON string to a Lua value - name: decode + - name: decode + comment: Decodes a JSON string to a Lua value parameters: - name: json type: string returnType: any - - comment: Encodes a Lua value as JSON preserving SL types. Use tight to encode + - name: slencode + comment: Encodes a Lua value as JSON preserving SL types. Use tight to encode more compactly. - name: slencode parameters: - name: value type: any @@ -1062,75 +1062,75 @@ modules: optional: true type: boolean returnType: string - - comment: Decodes a JSON string to a Lua value preserving SL types - name: sldecode + - name: sldecode + comment: Decodes a JSON string to a Lua value preserving SL types parameters: - name: json type: string returnType: any properties: - - comment: A constant to pass for null to json encode - name: 'null' + - name: 'null' + comment: A constant to pass for null to json encode type: any - - comment: Metatable for declaring table as an empty array for json encode - name: empty_array_mt + - name: empty_array_mt + comment: Metatable for declaring table as an empty array for json encode type: '{ [any]: any }' - - comment: Metatable for declaring table as an array for json encode - name: array_mt + - name: array_mt + comment: Metatable for declaring table as an array for json encode type: '{ [any]: any }' - - comment: A constant to pass for an empty array to json encode - name: empty_array + - name: empty_array + comment: A constant to pass for an empty array to json encode type: any - - comment: Name of the lljson library - name: _NAME + - name: _NAME + comment: Name of the lljson library type: string - - comment: Version of the lljson library - name: _VERSION + - name: _VERSION + comment: Version of the lljson library type: string - name: math comment: Mathematical functions library functions: - - comment: Returns the absolute value of x - name: abs + - name: abs + comment: Returns the absolute value of x parameters: - name: x type: number returnType: number - - comment: Returns the arc cosine of x (in radians) - name: acos + - name: acos + comment: Returns the arc cosine of x (in radians) parameters: - name: x type: number returnType: number - - comment: Returns the arc sine of x (in radians) - name: asin + - name: asin + comment: Returns the arc sine of x (in radians) parameters: - name: x type: number returnType: number - - comment: Returns the arc tangent of x (in radians) - name: atan + - name: atan + comment: Returns the arc tangent of x (in radians) parameters: - name: x type: number returnType: number - - comment: Returns the arc tangent of y/x (in radians), using the signs to determine + - name: atan2 + comment: Returns the arc tangent of y/x (in radians), using the signs to determine the quadrant - name: atan2 parameters: - name: y type: number - name: x type: number returnType: number - - comment: Returns the smallest integer larger than or equal to x - name: ceil + - name: ceil + comment: Returns the smallest integer larger than or equal to x parameters: - name: x type: number returnType: number - - comment: Returns n clamped between min and max - name: clamp + - name: clamp + comment: Returns n clamped between min and max parameters: - name: n type: number @@ -1139,60 +1139,60 @@ modules: - name: max type: number returnType: number - - comment: Returns the cosine of x (x in radians) - name: cos + - name: cos + comment: Returns the cosine of x (x in radians) parameters: - name: x type: number returnType: number - - comment: Returns the hyperbolic cosine of x - name: cosh + - name: cosh + comment: Returns the hyperbolic cosine of x parameters: - name: x type: number returnType: number - - comment: Converts x from radians to degrees - name: deg + - name: deg + comment: Converts x from radians to degrees parameters: - name: x type: number returnType: number - - comment: Returns e^x - name: exp + - name: exp + comment: Returns e^x parameters: - name: x type: number returnType: number - - comment: Returns the largest integer smaller than or equal to x - name: floor + - name: floor + comment: Returns the largest integer smaller than or equal to x parameters: - name: x type: number returnType: number - - comment: Returns the remainder of x/y that rounds towards zero - name: fmod + - name: fmod + comment: Returns the remainder of x/y that rounds towards zero parameters: - name: x type: number - name: y type: number returnType: number - - comment: Returns m and e such that x = m * 2^e - name: frexp + - name: frexp + comment: Returns m and e such that x = m * 2^e parameters: - name: x type: number returnType: (number, number) - - comment: Returns m * 2^e - name: ldexp + - name: ldexp + comment: Returns m * 2^e parameters: - name: m type: number - name: e type: number returnType: number - - comment: Linear interpolation between a and b by t - name: lerp + - name: lerp + comment: Linear interpolation between a and b by t parameters: - name: a type: number @@ -1201,8 +1201,8 @@ modules: - name: t type: number returnType: number - - comment: Returns the logarithm of x in the given base (default e) - name: log + - name: log + comment: Returns the logarithm of x in the given base (default e) parameters: - name: x type: number @@ -1210,14 +1210,14 @@ modules: optional: true type: number returnType: number - - comment: Returns the base-10 logarithm of x - name: log10 + - name: log10 + comment: Returns the base-10 logarithm of x parameters: - name: x type: number returnType: number - - comment: Maps x from input range to output range - name: map + - name: map + comment: Maps x from input range to output range parameters: - name: x type: number @@ -1230,30 +1230,30 @@ modules: - name: outMax type: number returnType: number - - comment: Returns the maximum value among the arguments - name: max + - name: max + comment: Returns the maximum value among the arguments parameters: - name: x type: number - type: number variadic: true returnType: number - - comment: Returns the minimum value among the arguments - name: min + - name: min + comment: Returns the minimum value among the arguments parameters: - name: x type: number - type: number variadic: true returnType: number - - comment: Returns the integer and fractional parts of x - name: modf + - name: modf + comment: Returns the integer and fractional parts of x parameters: - name: x type: number returnType: (number, number) - - comment: Returns Perlin noise value for the given coordinates - name: noise + - name: noise + comment: Returns Perlin noise value for the given coordinates parameters: - name: x type: number @@ -1264,22 +1264,22 @@ modules: optional: true type: number returnType: number - - comment: Returns base^exponent - name: pow + - name: pow + comment: Returns base^exponent parameters: - name: base type: number - name: exponent type: number returnType: number - - comment: Converts x from degrees to radians - name: rad + - name: rad + comment: Converts x from degrees to radians parameters: - name: x type: number returnType: number - - comment: Returns a pseudo-random number - name: random + - name: random + comment: Returns a pseudo-random number parameters: - name: m optional: true @@ -1288,88 +1288,88 @@ modules: optional: true type: number returnType: number - - comment: Sets the seed for the pseudo-random generator - name: randomseed + - name: randomseed + comment: Sets the seed for the pseudo-random generator parameters: - name: seed type: number returnType: () - - comment: Returns x rounded to the nearest integer - name: round + - name: round + comment: Returns x rounded to the nearest integer parameters: - name: x type: number returnType: number - - comment: Returns -1, 0, or 1 depending on the sign of x - name: sign + - name: sign + comment: Returns -1, 0, or 1 depending on the sign of x parameters: - name: x type: number returnType: number - - comment: Returns the sine of x (x in radians) - name: sin + - name: sin + comment: Returns the sine of x (x in radians) parameters: - name: x type: number returnType: number - - comment: Returns the hyperbolic sine of x - name: sinh + - name: sinh + comment: Returns the hyperbolic sine of x parameters: - name: x type: number returnType: number - - comment: Returns the square root of x - name: sqrt + - name: sqrt + comment: Returns the square root of x parameters: - name: x type: number returnType: number - - comment: Returns the tangent of x (x in radians) - name: tan + - name: tan + comment: Returns the tangent of x (x in radians) parameters: - name: x type: number returnType: number - - comment: Returns the hyperbolic tangent of x - name: tanh + - name: tanh + comment: Returns the hyperbolic tangent of x parameters: - name: x type: number returnType: number - - comment: Returns true if x is NaN - name: isnan + - name: isnan + comment: Returns true if x is NaN parameters: - name: x type: number returnType: boolean - - comment: Returns true if x is infinite - name: isinf + - name: isinf + comment: Returns true if x is infinite parameters: - name: x type: number returnType: boolean - - comment: Returns true if x is finite - name: isfinite + - name: isfinite + comment: Returns true if x is finite parameters: - name: x type: number returnType: boolean properties: - - comment: The value of pi - name: pi + - name: pi + comment: The value of pi type: number - - comment: A value larger than any other numeric value (infinity) - name: huge + - name: huge + comment: A value larger than any other numeric value (infinity) type: number - name: os comment: Operating system facilities library functions: - - comment: Returns CPU time used by the program in seconds - name: clock + - name: clock + comment: Returns CPU time used by the program in seconds parameters: [] returnType: number - - comment: Returns a string or table containing date and time - name: date + - name: date + comment: Returns a string or table containing date and time parameters: - name: format optional: true @@ -1378,8 +1378,8 @@ modules: optional: true type: number returnType: string | OsDateTime | nil - - comment: Returns the difference in seconds between two times - name: difftime + - name: difftime + comment: Returns the difference in seconds between two times parameters: - name: t2 type: number @@ -1387,8 +1387,8 @@ modules: optional: true type: number returnType: number - - comment: Returns the current time or converts a table to time - name: time + - name: time + comment: Returns the current time or converts a table to time parameters: - name: time optional: true @@ -1397,8 +1397,8 @@ modules: - name: string comment: String manipulation library functions: - - comment: Returns the internal numeric codes of the characters - name: byte + - name: byte + comment: Returns the internal numeric codes of the characters parameters: - name: s type: string @@ -1409,14 +1409,14 @@ modules: optional: true type: number returnType: '...number' - - comment: Returns a string from character codes - name: char + - name: char + comment: Returns a string from character codes parameters: - type: number variadic: true returnType: string - - comment: Finds first match of pattern in string - name: find + - name: find + comment: Finds first match of pattern in string parameters: - name: s type: string @@ -1429,24 +1429,24 @@ modules: optional: true type: boolean returnType: (number?, number?, ...string) - - comment: Returns a formatted string - name: format + - name: format + comment: Returns a formatted string parameters: - name: formatstring type: string - type: any variadic: true returnType: string - - comment: Returns an iterator function for pattern matches - name: gmatch + - name: gmatch + comment: Returns an iterator function for pattern matches parameters: - name: s type: string - name: pattern type: string returnType: () -> ...string - - comment: Global substitution of pattern matches - name: gsub + - name: gsub + comment: Global substitution of pattern matches parameters: - name: s type: string @@ -1458,20 +1458,20 @@ modules: optional: true type: number returnType: (string, number) - - comment: Returns the length of the string - name: len + - name: len + comment: Returns the length of the string parameters: - name: s type: string returnType: number - - comment: Converts string to lowercase - name: lower + - name: lower + comment: Converts string to lowercase parameters: - name: s type: string returnType: string - - comment: Returns captures from pattern match - name: match + - name: match + comment: Returns captures from pattern match parameters: - name: s type: string @@ -1481,36 +1481,36 @@ modules: optional: true type: number returnType: '...string' - - comment: Packs values into a binary string - name: pack + - name: pack + comment: Packs values into a binary string parameters: - name: fmt type: string - type: any variadic: true returnType: string - - comment: Returns the size of a packed string for the given format - name: packsize + - name: packsize + comment: Returns the size of a packed string for the given format parameters: - name: fmt type: string returnType: number - - comment: Returns a string repeated n times - name: rep + - name: rep + comment: Returns a string repeated n times parameters: - name: s type: string - name: n type: number returnType: string - - comment: Reverses a string - name: reverse + - name: reverse + comment: Reverses a string parameters: - name: s type: string returnType: string - - comment: Splits a string by separator - name: split + - name: split + comment: Splits a string by separator parameters: - name: s type: string @@ -1518,8 +1518,8 @@ modules: optional: true type: string returnType: '{string}' - - comment: Returns a substring - name: sub + - name: sub + comment: Returns a substring parameters: - name: s type: string @@ -1529,8 +1529,8 @@ modules: optional: true type: number returnType: string - - comment: Unpacks values from a binary string - name: unpack + - name: unpack + comment: Unpacks values from a binary string parameters: - name: fmt type: string @@ -1540,8 +1540,8 @@ modules: optional: true type: number returnType: '...any' - - comment: Converts string to uppercase - name: upper + - name: upper + comment: Converts string to uppercase parameters: - name: s type: string @@ -1549,8 +1549,8 @@ modules: - name: table comment: Table manipulation library functions: - - comment: Concatenates table elements into a string - name: concat + - name: concat + comment: Concatenates table elements into a string parameters: - name: list type: '{string}' @@ -1564,8 +1564,8 @@ modules: optional: true type: number returnType: string - - comment: Iterates over table key-value pairs (deprecated) - name: foreach + - name: foreach + comment: Iterates over table key-value pairs (deprecated) typeParameters: [T, U] parameters: - name: t @@ -1573,8 +1573,8 @@ modules: - name: f type: '(key: T, value: T) -> any' returnType: any? - - comment: Iterates over array indices (deprecated) - name: foreachi + - name: foreachi + comment: Iterates over array indices (deprecated) typeParameters: [T] parameters: - name: t @@ -1582,20 +1582,20 @@ modules: - name: f type: '(index: number, value: T) -> any' returnType: any? - - comment: 'Returns the length of a table (deprecated, use # operator)' - name: getn + - name: getn + comment: 'Returns the length of a table (deprecated, use # operator)' parameters: - name: t type: '{any}' returnType: number - - comment: Returns the largest positive numeric index - name: maxn + - name: maxn + comment: Returns the largest positive numeric index parameters: - name: t type: '{any}' returnType: number - - comment: Inserts an element at the end of a list - name: insert + - name: insert + comment: Inserts an element at the end of a list overloads: - comment: Inserts an element at a specific position typeParameters: [T] @@ -1614,8 +1614,8 @@ modules: - name: value type: T returnType: () - - comment: Removes and returns an element from a list - name: remove + - name: remove + comment: Removes and returns an element from a list typeParameters: [T] parameters: - name: list @@ -1624,8 +1624,8 @@ modules: optional: true type: number returnType: T? - - comment: Sorts list elements in place - name: sort + - name: sort + comment: Sorts list elements in place typeParameters: [T] parameters: - name: list @@ -1634,15 +1634,15 @@ modules: optional: true type: '(a: T, b: T) -> boolean' returnType: () - - comment: Packs arguments into a table with length field n - name: pack + - name: pack + comment: Packs arguments into a table with length field n typeParameters: [T] parameters: - type: T variadic: true returnType: '{ n: number, [number]: T }' - - comment: Unpacks table elements as multiple return values - name: unpack + - name: unpack + comment: Unpacks table elements as multiple return values typeParameters: [T] parameters: - name: list @@ -1654,8 +1654,8 @@ modules: optional: true type: number returnType: '...T' - - comment: Moves elements from one table to another - name: move + - name: move + comment: Moves elements from one table to another typeParameters: [T] parameters: - name: a1 @@ -1670,8 +1670,8 @@ modules: optional: true type: '{T}' returnType: '{T}' - - comment: Creates a new table with pre-allocated array slots - name: create + - name: create + comment: Creates a new table with pre-allocated array slots typeParameters: [T] parameters: - name: count @@ -1680,8 +1680,8 @@ modules: optional: true type: T returnType: '{T}' - - comment: Finds the index of a value in an array - name: find + - name: find + comment: Finds the index of a value in an array typeParameters: [T] parameters: - name: t @@ -1692,27 +1692,27 @@ modules: optional: true type: number returnType: number? - - comment: Removes all elements from a table - name: clear + - name: clear + comment: Removes all elements from a table parameters: - name: t type: '{[any]: any}' returnType: () - - comment: Makes a table read-only - name: freeze + - name: freeze + comment: Makes a table read-only typeParameters: [T, U] parameters: - name: t type: '{[T]: U}' returnType: '{[T]: U}' - - comment: Returns true if a table is frozen - name: isfrozen + - name: isfrozen + comment: Returns true if a table is frozen parameters: - name: t type: '{[any]: any}' returnType: boolean - - comment: Creates a shallow copy of a table - name: clone + - name: clone + comment: Creates a shallow copy of a table typeParameters: [T, U] parameters: - name: t @@ -1721,20 +1721,20 @@ modules: - name: utf8 comment: UTF-8 support library functions: - - comment: Returns a string from UTF-8 codepoints - name: char + - name: char + comment: Returns a string from UTF-8 codepoints parameters: - type: number variadic: true returnType: string - - comment: Returns an iterator for UTF-8 codepoints in a string - name: codes + - name: codes + comment: Returns an iterator for UTF-8 codepoints in a string parameters: - name: s type: string returnType: ((string, number) -> (number, number), string, number) - - comment: Returns the codepoints of characters in a string - name: codepoint + - name: codepoint + comment: Returns the codepoints of characters in a string parameters: - name: s type: string @@ -1745,9 +1745,9 @@ modules: optional: true type: number returnType: '...number' - - comment: Returns the number of UTF-8 characters in a string, or nil and error + - name: len + comment: Returns the number of UTF-8 characters in a string, or nil and error position - name: len parameters: - name: s type: string @@ -1758,8 +1758,8 @@ modules: optional: true type: number returnType: (number?, number?) - - comment: Returns the byte position of the n-th character - name: offset + - name: offset + comment: Returns the byte position of the n-th character parameters: - name: s type: string @@ -1770,15 +1770,15 @@ modules: type: number returnType: number? properties: - - comment: Pattern that matches exactly one UTF-8 byte sequence - name: charpattern + - name: charpattern + comment: Pattern that matches exactly one UTF-8 byte sequence type: string typeAliases: - name: rotation comment: '''rotation'' is an alias for ''quaternion''' definition: - kind: reference name: quaternion + kind: reference - name: numeric definition: kind: union From a202f566244f9621994e30a1b96982d1a0321334 Mon Sep 17 00:00:00 2001 From: tapple Date: Wed, 14 Jan 2026 07:17:16 -0800 Subject: [PATCH 011/102] consistently put name first in third-level dicts --- slua_definitions.yaml | 76 +++++++++++++++++++++---------------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/slua_definitions.yaml b/slua_definitions.yaml index 715afe9..f082fe2 100644 --- a/slua_definitions.yaml +++ b/slua_definitions.yaml @@ -349,10 +349,10 @@ globalVariables: type: kind: table properties: - - comment: Creates a new uuid from a string, buffer, or existing uuid. Returns + - name: create + comment: Creates a new uuid from a string, buffer, or existing uuid. Returns nil if the string is not a valid UUID. Throws an error if the buffer is shorter than 16 bytes. - name: create type: kind: function parameters: @@ -364,8 +364,8 @@ globalVariables: - buffer - uuid returnType: uuid? - - comment: Allows calling uuid() as a constructor - name: __call + - name: __call + comment: Allows calling uuid() as a constructor type: kind: function parameters: @@ -384,8 +384,8 @@ globalVariables: type: kind: table properties: - - comment: Creates a new vector with the given component values - name: create + - name: create + comment: Creates a new vector with the given component values type: kind: function parameters: @@ -397,24 +397,24 @@ globalVariables: optional: true type: number returnType: vector - - comment: Calculates the magnitude of a given vector - name: magnitude + - name: magnitude + comment: Calculates the magnitude of a given vector type: kind: function parameters: - name: v type: vector returnType: number - - comment: Computes the normalized version (unit vector) of a given vector - name: normalize + - name: normalize + comment: Computes the normalized version (unit vector) of a given vector type: kind: function parameters: - name: v type: vector returnType: vector - - comment: Computes the cross product of two vectors - name: cross + - name: cross + comment: Computes the cross product of two vectors type: kind: function parameters: @@ -423,8 +423,8 @@ globalVariables: - name: b type: vector returnType: vector - - comment: Computes the dot product of two vectors - name: dot + - name: dot + comment: Computes the dot product of two vectors type: kind: function parameters: @@ -433,9 +433,9 @@ globalVariables: - name: b type: vector returnType: number - - comment: Computes the angle between two vectors in radians. The axis, if specified, + - name: angle + comment: Computes the angle between two vectors in radians. The axis, if specified, is used to determine the sign of the angle. - name: angle type: kind: function parameters: @@ -447,40 +447,40 @@ globalVariables: optional: true type: vector returnType: number - - comment: Applies math.floor to every component of the input vector - name: floor + - name: floor + comment: Applies math.floor to every component of the input vector type: kind: function parameters: - name: v type: vector returnType: vector - - comment: Applies math.ceil to every component of the input vector - name: ceil + - name: ceil + comment: Applies math.ceil to every component of the input vector type: kind: function parameters: - name: v type: vector returnType: vector - - comment: Applies math.abs to every component of the input vector - name: abs + - name: abs + comment: Applies math.abs to every component of the input vector type: kind: function parameters: - name: v type: vector returnType: vector - - comment: Applies math.sign to every component of the input vector - name: sign + - name: sign + comment: Applies math.sign to every component of the input vector type: kind: function parameters: - name: v type: vector returnType: vector - - comment: Applies math.clamp to every component of the input vector - name: clamp + - name: clamp + comment: Applies math.clamp to every component of the input vector type: kind: function parameters: @@ -491,8 +491,8 @@ globalVariables: - name: max type: vector returnType: vector - - comment: Applies math.max to the corresponding components of the input vectors - name: max + - name: max + comment: Applies math.max to the corresponding components of the input vectors type: kind: function parameters: @@ -501,8 +501,8 @@ globalVariables: - type: vector variadic: true returnType: vector - - comment: Applies math.min to the corresponding components of the input vectors - name: min + - name: min + comment: Applies math.min to the corresponding components of the input vectors type: kind: function parameters: @@ -511,8 +511,8 @@ globalVariables: - type: vector variadic: true returnType: vector - - comment: Linear interpolation between two vectors - name: lerp + - name: lerp + comment: Linear interpolation between two vectors type: kind: function parameters: @@ -523,14 +523,14 @@ globalVariables: - name: t type: number returnType: vector - - comment: A zero vector <0,0,0> - name: zero + - name: zero + comment: A zero vector <0,0,0> type: vector - - comment: A one vector <1,1,1> - name: one + - name: one + comment: A one vector <1,1,1> type: vector - - comment: 'Constructor call: vector(x, y, z)' - name: __call + - name: __call + comment: 'Constructor call: vector(x, y, z)' type: kind: function parameters: From 8f50050a6db3d03219772e4bf664d47bdff1a540 Mon Sep 17 00:00:00 2001 From: tapple Date: Wed, 14 Jan 2026 07:19:34 -0800 Subject: [PATCH 012/102] consistently put name first in fourth-level dicts --- slua_definitions.yaml | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/slua_definitions.yaml b/slua_definitions.yaml index f082fe2..898ca45 100644 --- a/slua_definitions.yaml +++ b/slua_definitions.yaml @@ -252,8 +252,8 @@ globalVariables: kind: callable-table tableType: properties: - - comment: Constructor - name: create + - name: create + comment: Constructor type: kind: function parameters: @@ -266,27 +266,27 @@ globalVariables: - name: s type: number returnType: quaternion - - comment: Identity quaternion constant - name: identity + - name: identity + comment: Identity quaternion constant type: quaternion - - comment: Returns normalized quaternion - name: normalize + - name: normalize + comment: Returns normalized quaternion type: kind: function parameters: - name: q type: quaternion returnType: quaternion - - comment: Returns magnitude of quaternion - name: magnitude + - name: magnitude + comment: Returns magnitude of quaternion type: kind: function parameters: - name: q type: quaternion returnType: number - - comment: Dot product of two quaternions - name: dot + - name: dot + comment: Dot product of two quaternions type: kind: function parameters: @@ -295,8 +295,8 @@ globalVariables: - name: b type: quaternion returnType: number - - comment: Spherical linear interpolation - name: slerp + - name: slerp + comment: Spherical linear interpolation type: kind: function parameters: @@ -307,32 +307,32 @@ globalVariables: - name: t type: number returnType: quaternion - - comment: Returns conjugate of quaternion - name: conjugate + - name: conjugate + comment: Returns conjugate of quaternion type: kind: function parameters: - name: q type: quaternion returnType: quaternion - - comment: Returns forward vector from quaternion rotation - name: tofwd + - name: tofwd + comment: Returns forward vector from quaternion rotation type: kind: function parameters: - name: q type: quaternion returnType: vector - - comment: Returns left vector from quaternion rotation - name: toleft + - name: toleft + comment: Returns left vector from quaternion rotation type: kind: function parameters: - name: q type: quaternion returnType: vector - - comment: Returns up vector from quaternion rotation - name: toup + - name: toup + comment: Returns up vector from quaternion rotation type: kind: function parameters: From 561ed4dfac735c5633d112d9d6e5a81720f71fba Mon Sep 17 00:00:00 2001 From: tapple Date: Wed, 14 Jan 2026 07:27:10 -0800 Subject: [PATCH 013/102] consistently put optional after type --- slua_definitions.yaml | 108 +++++++++++++++++++++--------------------- 1 file changed, 54 insertions(+), 54 deletions(-) diff --git a/slua_definitions.yaml b/slua_definitions.yaml index 898ca45..b2e6de8 100644 --- a/slua_definitions.yaml +++ b/slua_definitions.yaml @@ -394,8 +394,8 @@ globalVariables: - name: y type: number - name: z - optional: true type: number + optional: true returnType: vector - name: magnitude comment: Calculates the magnitude of a given vector @@ -444,8 +444,8 @@ globalVariables: - name: b type: vector - name: axis - optional: true type: vector + optional: true returnType: number - name: floor comment: Applies math.floor to every component of the input vector @@ -541,8 +541,8 @@ globalVariables: - name: y type: number - name: z - optional: true type: number + optional: true returnType: vector - name: loadstring comment: loadstring is removed in SLua @@ -603,8 +603,8 @@ modules: - name: field type: number - name: width - optional: true type: number + optional: true returnType: number - name: lrotate comment: Left rotate @@ -632,8 +632,8 @@ modules: - name: field type: number - name: width - optional: true type: number + optional: true returnType: number - name: rrotate comment: Right rotate @@ -854,8 +854,8 @@ modules: - name: value type: string - name: count - optional: true type: number + optional: true returnType: () - name: len comment: Returns the length of the buffer @@ -873,11 +873,11 @@ modules: - name: source type: buffer - name: sourceOffset - optional: true type: number - - name: count optional: true + - name: count type: number + optional: true returnType: () - name: fill comment: Fill buffer with a value @@ -889,8 +889,8 @@ modules: - name: value type: number - name: count - optional: true type: number + optional: true returnType: () - name: readbits comment: Read bits from buffer @@ -997,21 +997,21 @@ modules: - comment: Returns a string with a traceback of the current call stack parameters: - name: message - optional: true type: string - - name: level optional: true + - name: level type: number + optional: true returnType: string parameters: - name: thread type: thread - name: message - optional: true type: string - - name: level optional: true + - name: level type: number + optional: true returnType: string - name: llbase64 comment: Base64 encoding/decoding library @@ -1030,8 +1030,8 @@ modules: - name: data type: string - name: asBuffer - optional: true type: boolean + optional: true returnType: string | buffer parameters: - name: data @@ -1059,8 +1059,8 @@ modules: - name: value type: any - name: tight - optional: true type: boolean + optional: true returnType: string - name: sldecode comment: Decodes a JSON string to a Lua value preserving SL types @@ -1207,8 +1207,8 @@ modules: - name: x type: number - name: base - optional: true type: number + optional: true returnType: number - name: log10 comment: Returns the base-10 logarithm of x @@ -1258,11 +1258,11 @@ modules: - name: x type: number - name: y - optional: true type: number - - name: z optional: true + - name: z type: number + optional: true returnType: number - name: pow comment: Returns base^exponent @@ -1282,11 +1282,11 @@ modules: comment: Returns a pseudo-random number parameters: - name: m - optional: true type: number - - name: n optional: true + - name: n type: number + optional: true returnType: number - name: randomseed comment: Sets the seed for the pseudo-random generator @@ -1372,11 +1372,11 @@ modules: comment: Returns a string or table containing date and time parameters: - name: format - optional: true type: string - - name: time optional: true + - name: time type: number + optional: true returnType: string | OsDateTime | nil - name: difftime comment: Returns the difference in seconds between two times @@ -1384,15 +1384,15 @@ modules: - name: t2 type: number - name: t1 - optional: true type: number + optional: true returnType: number - name: time comment: Returns the current time or converts a table to time parameters: - name: time - optional: true type: OsDateTime + optional: true returnType: number? - name: string comment: String manipulation library @@ -1403,11 +1403,11 @@ modules: - name: s type: string - name: i - optional: true type: number - - name: j optional: true + - name: j type: number + optional: true returnType: '...number' - name: char comment: Returns a string from character codes @@ -1423,11 +1423,11 @@ modules: - name: pattern type: string - name: init - optional: true type: number - - name: plain optional: true + - name: plain type: boolean + optional: true returnType: (number?, number?, ...string) - name: format comment: Returns a formatted string @@ -1455,8 +1455,8 @@ modules: - name: repl type: 'string | { [string]: string } | (...string) -> string' - name: n - optional: true type: number + optional: true returnType: (string, number) - name: len comment: Returns the length of the string @@ -1478,8 +1478,8 @@ modules: - name: pattern type: string - name: init - optional: true type: number + optional: true returnType: '...string' - name: pack comment: Packs values into a binary string @@ -1515,8 +1515,8 @@ modules: - name: s type: string - name: separator - optional: true type: string + optional: true returnType: '{string}' - name: sub comment: Returns a substring @@ -1526,8 +1526,8 @@ modules: - name: i type: number - name: j - optional: true type: number + optional: true returnType: string - name: unpack comment: Unpacks values from a binary string @@ -1537,8 +1537,8 @@ modules: - name: s type: string - name: pos - optional: true type: number + optional: true returnType: '...any' - name: upper comment: Converts string to uppercase @@ -1555,14 +1555,14 @@ modules: - name: list type: '{string}' - name: sep - optional: true type: string - - name: i optional: true + - name: i type: number - - name: j optional: true + - name: j type: number + optional: true returnType: string - name: foreach comment: Iterates over table key-value pairs (deprecated) @@ -1621,8 +1621,8 @@ modules: - name: list type: '{T}' - name: pos - optional: true type: number + optional: true returnType: T? - name: sort comment: Sorts list elements in place @@ -1631,8 +1631,8 @@ modules: - name: list type: '{T}' - name: comp - optional: true type: '(a: T, b: T) -> boolean' + optional: true returnType: () - name: pack comment: Packs arguments into a table with length field n @@ -1648,11 +1648,11 @@ modules: - name: list type: '{T}' - name: i - optional: true type: number - - name: j optional: true + - name: j type: number + optional: true returnType: '...T' - name: move comment: Moves elements from one table to another @@ -1667,8 +1667,8 @@ modules: - name: t type: number - name: a2 - optional: true type: '{T}' + optional: true returnType: '{T}' - name: create comment: Creates a new table with pre-allocated array slots @@ -1677,8 +1677,8 @@ modules: - name: count type: number - name: value - optional: true type: T + optional: true returnType: '{T}' - name: find comment: Finds the index of a value in an array @@ -1689,8 +1689,8 @@ modules: - name: value type: T - name: init - optional: true type: number + optional: true returnType: number? - name: clear comment: Removes all elements from a table @@ -1739,11 +1739,11 @@ modules: - name: s type: string - name: i - optional: true type: number - - name: j optional: true + - name: j type: number + optional: true returnType: '...number' - name: len comment: Returns the number of UTF-8 characters in a string, or nil and error @@ -1752,11 +1752,11 @@ modules: - name: s type: string - name: i - optional: true type: number - - name: j optional: true + - name: j type: number + optional: true returnType: (number?, number?) - name: offset comment: Returns the byte position of the n-th character @@ -1766,8 +1766,8 @@ modules: - name: n type: number - name: i - optional: true type: number + optional: true returnType: number? properties: - name: charpattern @@ -1865,21 +1865,21 @@ typeAliases: - name: day type: number - name: hour - optional: true type: number - - name: min optional: true + - name: min type: number - - name: sec optional: true + - name: sec type: number - - name: wday optional: true + - name: wday type: number - - name: yday optional: true + - name: yday type: number - - name: isdst optional: true + - name: isdst type: boolean + optional: true version: 1.0.0 From 7ce80d3e8b60f14b821593e87655792cf17ea3be Mon Sep 17 00:00:00 2001 From: tapple Date: Wed, 14 Jan 2026 09:37:19 -0800 Subject: [PATCH 014/102] add the new fields to the schema --- lsl_definitions.schema.json | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/lsl_definitions.schema.json b/lsl_definitions.schema.json index f061882..580d352 100644 --- a/lsl_definitions.schema.json +++ b/lsl_definitions.schema.json @@ -228,15 +228,35 @@ "^ll[A-Zs](?:[A-Z0-9]*[a-z]*)+$": { "additionalProperties": false, "properties": { + "type-arguments": { + "items": { + "additionalProperties": false, + "patternProperties": { + "^(?:[A-Za-z]+)$": { + "markdownDescription": "A type variable name for slua typechecking." + } + }, + "type": "string" + }, + "markdownDescription": "An array of type variable names for slua typechecking.", + "type": "array", + "uniqueItems": true + }, "arguments": { "items": { "additionalProperties": false, "patternProperties": { "^(?:[A-Za-z]+(?:[A-z0-9-_]+)*)$": { + "additionalProperties": false, "properties": { "bool-semantics": { "const": true, - "markdownDescription": "The function arguments integer value represents a boolean value.", + "markdownDescription": "This function argument's integer value represents a boolean value.", + "type": "boolean" + }, + "index-semantics": { + "const": true, + "markdownDescription": "This function argument's integer value represents a zero-based index.", "type": "boolean" }, "tooltip": { @@ -292,6 +312,10 @@ { "const": "string" }, { "const": "vector" } ] + }, + "slua-type": { + "markdownDescription": "A more specific argument type for slua type-checking.", + "type": "string" } }, "required": [ @@ -425,6 +449,10 @@ { "const": "void" } ] }, + "slua-return": { + "markdownDescription": "A more specific return type for slua type-checking.", + "type": "string" + }, "sleep": { "$ref": "#/definitions/nonNegativeNumber", "markdownDescription": "Additional sleep time imposed by the script after this function completes." From fa208df23df7bc0f74d1da826a1145ad40de9ab9 Mon Sep 17 00:00:00 2001 From: tapple Date: Thu, 15 Jan 2026 08:07:25 -0800 Subject: [PATCH 015/102] Verified bit-identicality of generated syntax against keywords_lsl_78aaa42a-9d1f-b7bb-ac9a-856a2de7b3da.llsd.xml - re-ordered and re-formatted fields to match the sim capability - added sort_keywords_expat.py to sort the entries of the sim capabilities --- gen_definitions.py | 36 ++++++++---- sort_keywords_expat.py | 126 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 150 insertions(+), 12 deletions(-) create mode 100644 sort_keywords_expat.py diff --git a/gen_definitions.py b/gen_definitions.py index 0a41c6f..a7c2355 100644 --- a/gen_definitions.py +++ b/gen_definitions.py @@ -147,11 +147,11 @@ class LSLConstant(NamedTuple): def to_dict(self) -> dict: return _remove_worthless( { - "tooltip": self.tooltip, # Will always use a node, but that's fine for our purposes. # That's already the case for vector and hex int constants, anyway. "value": _escape_python(self.value), "type": str(self.type), + "tooltip": self.tooltip, "deprecated": self.deprecated, } ) @@ -176,8 +176,6 @@ class LSLEvent: def to_dict(self) -> dict: return _remove_worthless( { - "tooltip": self.tooltip, - "deprecated": self.deprecated, "arguments": [ { a.name: { @@ -187,6 +185,8 @@ def to_dict(self) -> dict: } for a in self.arguments ], + "tooltip": self.tooltip, + "deprecated": self.deprecated, } ) @@ -239,11 +239,8 @@ class LSLFunction: def to_dict(self, include_internal: bool = False) -> dict: return _remove_worthless( { - "deprecated": self.deprecated, - "god-mode": self.god_mode, "energy": self.energy, - "sleep": self.sleep, - "return": str(self.ret_type), + "bool_semantics": self.bool_semantics, "arguments": [ { a.name: { @@ -253,7 +250,11 @@ def to_dict(self, include_internal: bool = False) -> dict: } for a in self.arguments ], + "return": str(self.ret_type), + "god-mode": self.god_mode, "tooltip": self.tooltip, + "deprecated": self.deprecated, + "sleep": self.sleep, **( {} if not include_internal @@ -533,6 +534,11 @@ def dump_syntax(definitions: LSLDefinitions) -> bytes: continue syntax["functions"][func.name] = func.to_dict() + for const in sorted(definitions.constants.values(), key=lambda x: x.name): + if const.private: + continue + syntax["constants"][const.name] = const.to_dict() + # This one's a little weird because it's not a "real" constant, but it's expected to be in the # constants section even though it has no value or type. It allows default to have a tooltip # and a distinct color. @@ -541,12 +547,18 @@ def dump_syntax(definitions: LSLDefinitions) -> bytes: "If another state is defined before the default state, the compiler will report a syntax error." } - for const in sorted(definitions.constants.values(), key=lambda x: x.name): - if const.private: - continue - syntax["constants"][const.name] = const.to_dict() + class KeywordsXMLFormatter(llsd.LLSDXMLFormatter): + """ customized to be bit-identical to the sim capability """ + def _BOOLEAN(self, v): + self.stream.writelines([b'', str(int(v)).encode('utf-8'), b'', self._eol]) + def _REAL(self, v): + if int(v) == v: + s = str(int(v)) + else: + s = f"{v:.25g}" + self.stream.writelines([b'', s.encode('utf-8'), b'', self._eol]) - return llsd.format_xml(syntax) + return KeywordsXMLFormatter().format(syntax) def _write_if_different(filename: str, data: Union[bytes, str]): diff --git a/sort_keywords_expat.py b/sort_keywords_expat.py new file mode 100644 index 0000000..8c2629a --- /dev/null +++ b/sort_keywords_expat.py @@ -0,0 +1,126 @@ +from __future__ import annotations +import sys +from collections.abc import Callable, Iterator +from dataclasses import dataclass, field +from xml.parsers.expat import ParserCreate, ExpatError, errors + +""" Sort a keywords LLSD XML for diffing.""" + +@dataclass +class RawLLSDXMLMap: + header: bytes = b"" + items: dict[str, bytes | RawLLSDXMLMap] = field(default_factory=dict) + footer: bytes = b"" + + def iter_chunks(self) -> Iterator[bytes]: + yield self.header + for key, value in self.items.items(): + if isinstance(value, RawLLSDXMLMap): + yield from value.iter_chunks() + else: + yield value + yield self.footer + + def sort_items(self): + self.items = dict(sorted(self.items.items(), key=lambda item: item[0])) + + def reorder_items(self, order: list[str]): + self.items = {key: self.items[key] for key in order} + +xml = open(sys.argv[1], "rb").read() + +p = ParserCreate() +map_stack: list[RawLLSDXMLMap] = [] +tag_stack: list[str] = [] +key_stack: list[str] = [] +offset = 0 +closer: Callable[[], None] | None = None + +def run_closer(): + global closer + if closer is not None: + closer() + closer = None + +def chunk() -> bytes: + global offset + chunk = xml[offset : p.CurrentByteIndex] + offset = p.CurrentByteIndex + return chunk + +def map_start(): + map_stack.append(RawLLSDXMLMap(header=chunk())) + key_stack.append("") + +def map_end(): + map = map_stack.pop() + map.footer = chunk() + key_stack.pop() + if key_stack: + map_stack[-1].items[key_stack[-1]] = map + key_stack[-1] = "" + +def key_start(name: str): + pass + +def key_end(): + if key_stack[-1] != "": + map_stack[-1].items[key_stack[-1]] = chunk() + key_stack[-1] = "" + + +def start_element(name, attrs): + tag_stack.append(name) + if "array" in tag_stack: + return + global closer + if name == "map": + run_closer() + closer = map_start + elif name == "key": + run_closer() + key_end() + key_start(name) +def end_element(name): + global closer + tag_stack.pop() + if "array" in tag_stack: + return + if name == "map": + run_closer() + key_end() + closer = map_end +def char_data(data): + if "array" in tag_stack: + return + if tag_stack[-1] == "key": + key_stack[-1] = data + +try: + p.StartElementHandler = start_element + p.EndElementHandler = end_element + p.CharacterDataHandler = char_data + p.Parse(xml) + result = map_stack[0] + run_closer() +except ExpatError as err: + print("Error:", errors.messages[err.code]) + +if "--nosort" not in sys.argv: + for value in result.items.values(): + if isinstance(value, RawLLSDXMLMap): + value.sort_items() + + if "--noreorder" not in sys.argv: + result.reorder_items([ + "llsd-lsl-syntax-version", + "controls", + "types", + "constants", + "events", + "functions", + ]) + +for chunk in result.iter_chunks(): + sys.stdout.buffer.write(chunk) + From 8b958ac41430bf9af98725dfaa9c4a52718c9600 Mon Sep 17 00:00:00 2001 From: tapple Date: Thu, 15 Jan 2026 08:08:01 -0800 Subject: [PATCH 016/102] Revert "Verified bit-identicality of generated syntax against keywords_lsl_78aaa42a-9d1f-b7bb-ac9a-856a2de7b3da.llsd.xml" This reverts commit fa208df23df7bc0f74d1da826a1145ad40de9ab9. --- gen_definitions.py | 36 ++++-------- sort_keywords_expat.py | 126 ----------------------------------------- 2 files changed, 12 insertions(+), 150 deletions(-) delete mode 100644 sort_keywords_expat.py diff --git a/gen_definitions.py b/gen_definitions.py index a7c2355..0a41c6f 100644 --- a/gen_definitions.py +++ b/gen_definitions.py @@ -147,11 +147,11 @@ class LSLConstant(NamedTuple): def to_dict(self) -> dict: return _remove_worthless( { + "tooltip": self.tooltip, # Will always use a node, but that's fine for our purposes. # That's already the case for vector and hex int constants, anyway. "value": _escape_python(self.value), "type": str(self.type), - "tooltip": self.tooltip, "deprecated": self.deprecated, } ) @@ -176,6 +176,8 @@ class LSLEvent: def to_dict(self) -> dict: return _remove_worthless( { + "tooltip": self.tooltip, + "deprecated": self.deprecated, "arguments": [ { a.name: { @@ -185,8 +187,6 @@ def to_dict(self) -> dict: } for a in self.arguments ], - "tooltip": self.tooltip, - "deprecated": self.deprecated, } ) @@ -239,8 +239,11 @@ class LSLFunction: def to_dict(self, include_internal: bool = False) -> dict: return _remove_worthless( { + "deprecated": self.deprecated, + "god-mode": self.god_mode, "energy": self.energy, - "bool_semantics": self.bool_semantics, + "sleep": self.sleep, + "return": str(self.ret_type), "arguments": [ { a.name: { @@ -250,11 +253,7 @@ def to_dict(self, include_internal: bool = False) -> dict: } for a in self.arguments ], - "return": str(self.ret_type), - "god-mode": self.god_mode, "tooltip": self.tooltip, - "deprecated": self.deprecated, - "sleep": self.sleep, **( {} if not include_internal @@ -534,11 +533,6 @@ def dump_syntax(definitions: LSLDefinitions) -> bytes: continue syntax["functions"][func.name] = func.to_dict() - for const in sorted(definitions.constants.values(), key=lambda x: x.name): - if const.private: - continue - syntax["constants"][const.name] = const.to_dict() - # This one's a little weird because it's not a "real" constant, but it's expected to be in the # constants section even though it has no value or type. It allows default to have a tooltip # and a distinct color. @@ -547,18 +541,12 @@ def dump_syntax(definitions: LSLDefinitions) -> bytes: "If another state is defined before the default state, the compiler will report a syntax error." } - class KeywordsXMLFormatter(llsd.LLSDXMLFormatter): - """ customized to be bit-identical to the sim capability """ - def _BOOLEAN(self, v): - self.stream.writelines([b'', str(int(v)).encode('utf-8'), b'', self._eol]) - def _REAL(self, v): - if int(v) == v: - s = str(int(v)) - else: - s = f"{v:.25g}" - self.stream.writelines([b'', s.encode('utf-8'), b'', self._eol]) + for const in sorted(definitions.constants.values(), key=lambda x: x.name): + if const.private: + continue + syntax["constants"][const.name] = const.to_dict() - return KeywordsXMLFormatter().format(syntax) + return llsd.format_xml(syntax) def _write_if_different(filename: str, data: Union[bytes, str]): diff --git a/sort_keywords_expat.py b/sort_keywords_expat.py deleted file mode 100644 index 8c2629a..0000000 --- a/sort_keywords_expat.py +++ /dev/null @@ -1,126 +0,0 @@ -from __future__ import annotations -import sys -from collections.abc import Callable, Iterator -from dataclasses import dataclass, field -from xml.parsers.expat import ParserCreate, ExpatError, errors - -""" Sort a keywords LLSD XML for diffing.""" - -@dataclass -class RawLLSDXMLMap: - header: bytes = b"" - items: dict[str, bytes | RawLLSDXMLMap] = field(default_factory=dict) - footer: bytes = b"" - - def iter_chunks(self) -> Iterator[bytes]: - yield self.header - for key, value in self.items.items(): - if isinstance(value, RawLLSDXMLMap): - yield from value.iter_chunks() - else: - yield value - yield self.footer - - def sort_items(self): - self.items = dict(sorted(self.items.items(), key=lambda item: item[0])) - - def reorder_items(self, order: list[str]): - self.items = {key: self.items[key] for key in order} - -xml = open(sys.argv[1], "rb").read() - -p = ParserCreate() -map_stack: list[RawLLSDXMLMap] = [] -tag_stack: list[str] = [] -key_stack: list[str] = [] -offset = 0 -closer: Callable[[], None] | None = None - -def run_closer(): - global closer - if closer is not None: - closer() - closer = None - -def chunk() -> bytes: - global offset - chunk = xml[offset : p.CurrentByteIndex] - offset = p.CurrentByteIndex - return chunk - -def map_start(): - map_stack.append(RawLLSDXMLMap(header=chunk())) - key_stack.append("") - -def map_end(): - map = map_stack.pop() - map.footer = chunk() - key_stack.pop() - if key_stack: - map_stack[-1].items[key_stack[-1]] = map - key_stack[-1] = "" - -def key_start(name: str): - pass - -def key_end(): - if key_stack[-1] != "": - map_stack[-1].items[key_stack[-1]] = chunk() - key_stack[-1] = "" - - -def start_element(name, attrs): - tag_stack.append(name) - if "array" in tag_stack: - return - global closer - if name == "map": - run_closer() - closer = map_start - elif name == "key": - run_closer() - key_end() - key_start(name) -def end_element(name): - global closer - tag_stack.pop() - if "array" in tag_stack: - return - if name == "map": - run_closer() - key_end() - closer = map_end -def char_data(data): - if "array" in tag_stack: - return - if tag_stack[-1] == "key": - key_stack[-1] = data - -try: - p.StartElementHandler = start_element - p.EndElementHandler = end_element - p.CharacterDataHandler = char_data - p.Parse(xml) - result = map_stack[0] - run_closer() -except ExpatError as err: - print("Error:", errors.messages[err.code]) - -if "--nosort" not in sys.argv: - for value in result.items.values(): - if isinstance(value, RawLLSDXMLMap): - value.sort_items() - - if "--noreorder" not in sys.argv: - result.reorder_items([ - "llsd-lsl-syntax-version", - "controls", - "types", - "constants", - "events", - "functions", - ]) - -for chunk in result.iter_chunks(): - sys.stdout.buffer.write(chunk) - From 0539dcce8631ac49c064cd47ec86c8e296d99761 Mon Sep 17 00:00:00 2001 From: tapple Date: Thu, 15 Jan 2026 11:25:01 -0800 Subject: [PATCH 017/102] added the func-id for llSetParcelForSale --- lsl_definitions.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/lsl_definitions.yaml b/lsl_definitions.yaml index 3c8f825..0f71bba 100644 --- a/lsl_definitions.yaml +++ b/lsl_definitions.yaml @@ -11119,6 +11119,7 @@ functions: tooltip: A list of options to set for the sale. type: list energy: 10.0 + func-id: 561 return: integer bool-semantics: true sleep: 0.0 From 253056e829f55cdd6a83efb809aa6f0db12d4d77 Mon Sep 17 00:00:00 2001 From: tapple Date: Fri, 16 Jan 2026 05:23:43 -0800 Subject: [PATCH 018/102] add a pretty-print option and match the field order of indra/newview/app_settings/keywords_lsl_default.xml --- gen_definitions.py | 44 ++++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/gen_definitions.py b/gen_definitions.py index 0a41c6f..c60fb1e 100644 --- a/gen_definitions.py +++ b/gen_definitions.py @@ -147,12 +147,12 @@ class LSLConstant(NamedTuple): def to_dict(self) -> dict: return _remove_worthless( { - "tooltip": self.tooltip, + "deprecated": self.deprecated, # Will always use a node, but that's fine for our purposes. # That's already the case for vector and hex int constants, anyway. - "value": _escape_python(self.value), + "tooltip": self.tooltip, "type": str(self.type), - "deprecated": self.deprecated, + "value": _escape_python(self.value), } ) @@ -176,17 +176,17 @@ class LSLEvent: def to_dict(self) -> dict: return _remove_worthless( { - "tooltip": self.tooltip, "deprecated": self.deprecated, "arguments": [ { a.name: { - "type": str(a.type), "tooltip": a.tooltip, + "type": str(a.type), } } for a in self.arguments ], + "tooltip": self.tooltip, } ) @@ -239,20 +239,20 @@ class LSLFunction: def to_dict(self, include_internal: bool = False) -> dict: return _remove_worthless( { - "deprecated": self.deprecated, - "god-mode": self.god_mode, - "energy": self.energy, - "sleep": self.sleep, - "return": str(self.ret_type), "arguments": [ { a.name: { - "type": str(a.type), "tooltip": a.tooltip, + "type": str(a.type), } } for a in self.arguments ], + "deprecated": self.deprecated, + "energy": self.energy, + "god-mode": self.god_mode, + "return": str(self.ret_type), + "sleep": self.sleep, "tooltip": self.tooltip, **( {} @@ -513,15 +513,15 @@ def _remove_worthless(val: dict) -> dict: return val -def dump_syntax(definitions: LSLDefinitions) -> bytes: +def dump_syntax(definitions: LSLDefinitions, pretty: bool = False) -> bytes: """Write a syntax file for use by viewers""" syntax = { - "llsd-lsl-syntax-version": 2, "controls": definitions.controls.copy(), "types": definitions.types.copy(), "constants": {}, "events": {}, "functions": {}, + "llsd-lsl-syntax-version": 2, } for event in sorted(definitions.events.values(), key=lambda x: x.name): if event.private: @@ -533,6 +533,11 @@ def dump_syntax(definitions: LSLDefinitions) -> bytes: continue syntax["functions"][func.name] = func.to_dict() + for const in sorted(definitions.constants.values(), key=lambda x: x.name): + if const.private: + continue + syntax["constants"][const.name] = const.to_dict() + # This one's a little weird because it's not a "real" constant, but it's expected to be in the # constants section even though it has no value or type. It allows default to have a tooltip # and a distinct color. @@ -541,12 +546,10 @@ def dump_syntax(definitions: LSLDefinitions) -> bytes: "If another state is defined before the default state, the compiler will report a syntax error." } - for const in sorted(definitions.constants.values(), key=lambda x: x.name): - if const.private: - continue - syntax["constants"][const.name] = const.to_dict() - - return llsd.format_xml(syntax) + if pretty: + return llsd.format_pretty_xml(syntax, indent=3, c_compat=True, sort_maps=False) + else: + return llsd.format_xml(syntax, c_compat=True, sort_maps=True) def _write_if_different(filename: str, data: Union[bytes, str]): @@ -1971,7 +1974,8 @@ def main(): sub = subparsers.add_parser("syntax") sub.add_argument("filename") - sub.set_defaults(func=lambda args, defs: _write_if_different(args.filename, dump_syntax(defs))) + sub.add_argument("--pretty", action="store_true", help="Pretty-print the output") + sub.set_defaults(func=lambda args, defs: _write_if_different(args.filename, dump_syntax(defs, args.pretty))) sub = subparsers.add_parser("gen_constant_lsl_script") sub.set_defaults(func=lambda args, defs: gen_constant_lsl_script(defs)) From 00acc8f5da1cd3094f8fccdbe303ddc34ceee0d5 Mon Sep 17 00:00:00 2001 From: tapple Date: Fri, 16 Jan 2026 09:34:36 -0800 Subject: [PATCH 019/102] Reordering needed to binary-match keywords_lsl_78aaa42a-9d1f-b7bb-ac9a-856a2de7b3da.llsd.xml --- gen_definitions.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/gen_definitions.py b/gen_definitions.py index c60fb1e..e460448 100644 --- a/gen_definitions.py +++ b/gen_definitions.py @@ -147,12 +147,12 @@ class LSLConstant(NamedTuple): def to_dict(self) -> dict: return _remove_worthless( { - "deprecated": self.deprecated, + "value": _escape_python(self.value), # Will always use a node, but that's fine for our purposes. # That's already the case for vector and hex int constants, anyway. - "tooltip": self.tooltip, "type": str(self.type), - "value": _escape_python(self.value), + "tooltip": self.tooltip, + "deprecated": self.deprecated, } ) @@ -176,17 +176,17 @@ class LSLEvent: def to_dict(self) -> dict: return _remove_worthless( { - "deprecated": self.deprecated, "arguments": [ { a.name: { - "tooltip": a.tooltip, "type": str(a.type), + "tooltip": a.tooltip, } } for a in self.arguments ], "tooltip": self.tooltip, + "deprecated": self.deprecated, } ) @@ -239,21 +239,22 @@ class LSLFunction: def to_dict(self, include_internal: bool = False) -> dict: return _remove_worthless( { + "energy": self.energy, + "bool_semantics": self.bool_semantics or False, "arguments": [ { a.name: { - "tooltip": a.tooltip, "type": str(a.type), + "tooltip": a.tooltip, } } for a in self.arguments ], - "deprecated": self.deprecated, - "energy": self.energy, - "god-mode": self.god_mode, "return": str(self.ret_type), - "sleep": self.sleep, + "god-mode": self.god_mode, "tooltip": self.tooltip, + "deprecated": self.deprecated, + "sleep": self.sleep, **( {} if not include_internal @@ -549,7 +550,7 @@ def dump_syntax(definitions: LSLDefinitions, pretty: bool = False) -> bytes: if pretty: return llsd.format_pretty_xml(syntax, indent=3, c_compat=True, sort_maps=False) else: - return llsd.format_xml(syntax, c_compat=True, sort_maps=True) + return llsd.format_xml(syntax, c_compat=True, sort_maps=False) def _write_if_different(filename: str, data: Union[bytes, str]): From 21790b602ef76586512de32caad96561fe9ed54e Mon Sep 17 00:00:00 2001 From: tapple Date: Fri, 16 Jan 2026 09:34:53 -0800 Subject: [PATCH 020/102] Revert "Reordering needed to binary-match keywords_lsl_78aaa42a-9d1f-b7bb-ac9a-856a2de7b3da.llsd.xml" This reverts commit 00acc8f5da1cd3094f8fccdbe303ddc34ceee0d5. --- gen_definitions.py | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/gen_definitions.py b/gen_definitions.py index e460448..c60fb1e 100644 --- a/gen_definitions.py +++ b/gen_definitions.py @@ -147,12 +147,12 @@ class LSLConstant(NamedTuple): def to_dict(self) -> dict: return _remove_worthless( { - "value": _escape_python(self.value), + "deprecated": self.deprecated, # Will always use a node, but that's fine for our purposes. # That's already the case for vector and hex int constants, anyway. - "type": str(self.type), "tooltip": self.tooltip, - "deprecated": self.deprecated, + "type": str(self.type), + "value": _escape_python(self.value), } ) @@ -176,17 +176,17 @@ class LSLEvent: def to_dict(self) -> dict: return _remove_worthless( { + "deprecated": self.deprecated, "arguments": [ { a.name: { - "type": str(a.type), "tooltip": a.tooltip, + "type": str(a.type), } } for a in self.arguments ], "tooltip": self.tooltip, - "deprecated": self.deprecated, } ) @@ -239,22 +239,21 @@ class LSLFunction: def to_dict(self, include_internal: bool = False) -> dict: return _remove_worthless( { - "energy": self.energy, - "bool_semantics": self.bool_semantics or False, "arguments": [ { a.name: { - "type": str(a.type), "tooltip": a.tooltip, + "type": str(a.type), } } for a in self.arguments ], - "return": str(self.ret_type), - "god-mode": self.god_mode, - "tooltip": self.tooltip, "deprecated": self.deprecated, + "energy": self.energy, + "god-mode": self.god_mode, + "return": str(self.ret_type), "sleep": self.sleep, + "tooltip": self.tooltip, **( {} if not include_internal @@ -550,7 +549,7 @@ def dump_syntax(definitions: LSLDefinitions, pretty: bool = False) -> bytes: if pretty: return llsd.format_pretty_xml(syntax, indent=3, c_compat=True, sort_maps=False) else: - return llsd.format_xml(syntax, c_compat=True, sort_maps=False) + return llsd.format_xml(syntax, c_compat=True, sort_maps=True) def _write_if_different(filename: str, data: Union[bytes, str]): From e20083b702517c8d670ee36cdf6f18e320718ee3 Mon Sep 17 00:00:00 2001 From: tapple Date: Fri, 16 Jan 2026 13:13:57 -0800 Subject: [PATCH 021/102] now able to generate the lsl portion of keywords-lua --- gen_definitions.py | 133 +++++++++++++++++++++++++++++++++++- lsl_definitions.schema.json | 6 ++ lsl_definitions.yaml | 2 + 3 files changed, 140 insertions(+), 1 deletion(-) diff --git a/gen_definitions.py b/gen_definitions.py index c60fb1e..76a2764 100644 --- a/gen_definitions.py +++ b/gen_definitions.py @@ -13,7 +13,7 @@ import argparse import uuid import os -from typing import Iterable, NamedTuple, Dict, List, Set, Sequence, TypeVar, Union, Any +from typing import Iterable, NamedTuple, Dict, List, Optional, Set, Sequence, TypeVar, Union, Any import llsd # noqa import yaml @@ -54,6 +54,7 @@ class LSLTypeMeta(NamedTuple): library_abbr: str cs_name: str mono_bind_name: str + slua_name: str _CS_TYPE_MODULE = "[ScriptTypes]LindenLab.SecondLife" @@ -68,6 +69,7 @@ class LSLTypeMeta(NamedTuple): library_abbr="", cs_name="void", mono_bind_name="void", + slua_name="void", ), LSLType.INTEGER: LSLTypeMeta( cil_name="int32", @@ -77,6 +79,7 @@ class LSLTypeMeta(NamedTuple): library_abbr="i", cs_name="int", mono_bind_name="S32", + slua_name="number", ), LSLType.FLOAT: LSLTypeMeta( cil_name="float", @@ -86,6 +89,7 @@ class LSLTypeMeta(NamedTuple): library_abbr="f", cs_name="float", mono_bind_name="F32", + slua_name="number", ), LSLType.STRING: LSLTypeMeta( cil_name="string", @@ -95,6 +99,7 @@ class LSLTypeMeta(NamedTuple): library_abbr="s", cs_name="string", mono_bind_name="MonoStringType", + slua_name="string", ), LSLType.KEY: LSLTypeMeta( cil_name=f"valuetype {_CS_TYPE_MODULE}.Key", @@ -104,6 +109,7 @@ class LSLTypeMeta(NamedTuple): library_abbr="k", cs_name="Key", mono_bind_name="MonoKeyType", + slua_name="uuid", ), LSLType.VECTOR: LSLTypeMeta( cil_name=f"class {_CS_TYPE_MODULE}.Vector", @@ -113,6 +119,7 @@ class LSLTypeMeta(NamedTuple): library_abbr="v", cs_name="Vector", mono_bind_name="MonoVectorType", + slua_name="vector", ), LSLType.ROTATION: LSLTypeMeta( cil_name=f"class {_CS_TYPE_MODULE}.Quaternion", @@ -122,6 +129,7 @@ class LSLTypeMeta(NamedTuple): library_abbr="q", cs_name="Quaternion", mono_bind_name="MonoQuaternionType", + slua_name="rotation", ), LSLType.LIST: LSLTypeMeta( cil_name="class [mscorlib]System.Collections.ArrayList", @@ -131,6 +139,7 @@ class LSLTypeMeta(NamedTuple): library_abbr="l", cs_name="ArrayList", mono_bind_name="MonoListType", + slua_name="list", ), } @@ -138,6 +147,8 @@ class LSLTypeMeta(NamedTuple): class LSLConstant(NamedTuple): name: str type: LSLType + slua_type: Optional[str] + slua_removed: bool value: str tooltip: str deprecated: bool @@ -155,14 +166,35 @@ def to_dict(self) -> dict: "value": _escape_python(self.value), } ) + + def to_slua_dict(self) -> dict: + return _remove_worthless( + { + "deprecated": self.deprecated, + # Will always use a node, but that's fine for our purposes. + # That's already the case for vector and hex int constants, anyway. + "tooltip": self.tooltip, + "type": self.slua_type or str(self.type), + "value": _escape_python(self.value), + } + ) @dataclasses.dataclass class LSLArgument: name: str type: LSLType + slua_type: Optional[str] tooltip: str index_semantics: bool + bool_semantics: bool + + def compute_slua_type(self) -> str: + if self.slua_type is not None: + return self.slua_type + if self.bool_semantics and self.type == LSLType.INTEGER: + return "boolean | number" + return self.type.meta.slua_name @dataclasses.dataclass @@ -190,6 +222,23 @@ def to_dict(self) -> dict: } ) + def to_slua_dict(self) -> dict: + return _remove_worthless( + { + "deprecated": self.deprecated, + "arguments": [ + { + a.name: { + "tooltip": a.tooltip, + "type": a.compute_slua_type(), + } + } + for a in self.arguments + ], + "tooltip": self.tooltip, + } + ) + @dataclasses.dataclass class LSLFunction: @@ -197,9 +246,11 @@ class LSLFunction: energy: float sleep: float ret_type: LSLType + slua_type: Optional[str] god_mode: bool index_semantics: bool bool_semantics: bool + type_arguments: List[str] arguments: List[LSLArgument] tooltip: str private: bool @@ -268,6 +319,40 @@ def to_dict(self, include_internal: bool = False) -> dict: } ) + def compute_slua_name(self) -> str: + if self.name.startswith("ll"): + return self.name[:2] + "." + self.name[2:] + return self.name + + def compute_slua_type(self) -> str: + if self.slua_type is not None: + return self.slua_type + if self.bool_semantics and self.ret_type == LSLType.INTEGER: + return "boolean" + return self.ret_type.meta.slua_name + + def to_slua_dict(self) -> dict: + return _remove_worthless( + { + "type-arguments": self.type_arguments, + "arguments": [ + { + a.name: { + "tooltip": a.tooltip, + "type": a.compute_slua_type(), + } + } + for a in self.arguments + ], + "deprecated": self.deprecated, + "energy": self.energy, + "god-mode": self.god_mode, + "return": self.compute_slua_type(), + "sleep": self.sleep, + "tooltip": self.tooltip, + } + ) + class LSLDefinitions(NamedTuple): events: Dict[str, LSLEvent] @@ -395,6 +480,8 @@ def _handle_function(self, func_name: str, func_data: dict) -> LSLFunction: # 99.9% of the time this won't be specified, if it isn't, just use `sleep`'s value. mono_sleep=float(func_data.get("mono-sleep", func_data.get("sleep")) or "0.0"), ret_type=LSLType(func_data["return"]), + slua_type=func_data.get("slua-return", None), + type_arguments=func_data.get("type-arguments", []), arguments=[ self._handle_argument(func_name, arg) for arg in (func_data.get("arguments") or []) ], @@ -438,7 +525,9 @@ def _handle_argument(func_name: str, arg_dict: dict) -> LSLArgument: arg = LSLArgument( name=arg_name, type=LSLType(arg_data["type"]), + slua_type=arg_data.get("slua-type", None), index_semantics=bool(arg_data.get("index-semantics", False)), + bool_semantics=bool(arg_data.get("bool-semantics", False)), tooltip=arg_data.get("tooltip", ""), ) if arg.index_semantics and arg.type != LSLType.INTEGER: @@ -470,6 +559,8 @@ def _handle_constant(self, const_name: str, const_data: dict) -> LSLConstant: const = LSLConstant( name=const_name, type=LSLType(const_data["type"]), + slua_type=const_data.get("slua-type", None), + slua_removed=const_data.get("slua-removed", False), value=str(self._massage_const_value(const_data["value"])), tooltip=const_data.get("tooltip", ""), private=const_data.get("private", False), @@ -510,6 +601,8 @@ def _remove_worthless(val: dict) -> dict: val.pop("bool-semantics", None) if not val.get("index-semantics"): val.pop("index-semantics", None) + if not val.get("type-arguments"): + val.pop("type-arguments", None) return val @@ -552,6 +645,39 @@ def dump_syntax(definitions: LSLDefinitions, pretty: bool = False) -> bytes: return llsd.format_xml(syntax, c_compat=True, sort_maps=True) +def dump_slua_syntax(definitions: LSLDefinitions, pretty: bool = False) -> bytes: + """Write a syntax file for use by viewers""" + syntax = { + "controls": definitions.controls.copy(), + "types": definitions.types.copy(), + "constants": {}, + "events": {}, + "functions": {}, + "llsd-lsl-syntax-version": 2, + } + for event in sorted(definitions.events.values(), key=lambda x: x.name): + if event.private: + continue + syntax["events"][event.name] = event.to_slua_dict() + + for func in sorted(definitions.functions.values(), key=lambda x: x.name): + if func.private: + continue + syntax["functions"][func.compute_slua_name()] = func.to_slua_dict() + + for const in sorted(definitions.constants.values(), key=lambda x: x.name): + if const.private: + continue + if const.slua_removed: + continue + syntax["constants"][const.name] = const.to_slua_dict() + + if pretty: + return llsd.format_pretty_xml(syntax, indent=3, c_compat=True, sort_maps=False) + else: + return llsd.format_xml(syntax, c_compat=True, sort_maps=True) + + def _write_if_different(filename: str, data: Union[bytes, str]): """ Write, but not if it would change mtime needlessly @@ -1977,6 +2103,11 @@ def main(): sub.add_argument("--pretty", action="store_true", help="Pretty-print the output") sub.set_defaults(func=lambda args, defs: _write_if_different(args.filename, dump_syntax(defs, args.pretty))) + sub = subparsers.add_parser("slua_syntax") + sub.add_argument("filename") + sub.add_argument("--pretty", action="store_true", help="Pretty-print the output") + sub.set_defaults(func=lambda args, defs: _write_if_different(args.filename, dump_slua_syntax(defs, args.pretty))) + sub = subparsers.add_parser("gen_constant_lsl_script") sub.set_defaults(func=lambda args, defs: gen_constant_lsl_script(defs)) diff --git a/lsl_definitions.schema.json b/lsl_definitions.schema.json index 580d352..6a8d638 100644 --- a/lsl_definitions.schema.json +++ b/lsl_definitions.schema.json @@ -33,11 +33,17 @@ "patternProperties": { "^(?:[A-Z]+[0-9]*(?:_(?:[0-9]+|[A-Z]+[0-9]*))*)$": { "properties": { + "additionalProperties": false, "deprecated": { "const": true, "markdownDescription": "This constant has been deprecated.", "type": "boolean" }, + "slua-removed": { + "const": true, + "markdownDescription": "This constant is only present in LSL, not SLua.", + "type": "boolean" + }, "private": { "const": true, "markdownDescription": "This constant should be omitted from the generated documentation.", diff --git a/lsl_definitions.yaml b/lsl_definitions.yaml index 0f71bba..b623a0f 100644 --- a/lsl_definitions.yaml +++ b/lsl_definitions.yaml @@ -933,6 +933,7 @@ constants: 'FALSE': tooltip: An integer constant for boolean comparisons. Has the value '0'. type: integer + slua-removed: true value: 0 FILTER_FLAGS: tooltip: Flags to control returned attachments. @@ -4027,6 +4028,7 @@ constants: 'TRUE': tooltip: An integer constant for boolean comparisons. Has the value '1'. type: integer + slua-removed: true value: 1 TWO_PI: tooltip: 6.28318530 - The radians of a circle. From 00f929113a037978be55dfb259e5bd4c30a05192 Mon Sep 17 00:00:00 2001 From: tapple Date: Fri, 16 Jan 2026 13:48:20 -0800 Subject: [PATCH 022/102] marked the llSetParcelForSale function id as unavailable --- lsl_definitions.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lsl_definitions.yaml b/lsl_definitions.yaml index b623a0f..a703ee3 100644 --- a/lsl_definitions.yaml +++ b/lsl_definitions.yaml @@ -11,7 +11,7 @@ # Select a new ID from the open ranges listed below and update the list. # The following ranges are available for use: # -# 561 - 589, 593 - 599, +# 562 - 589, 593 - 599, # 605 - 649, 663 - 699, 719 - 749, 751 - 759, # 763 - 799, 804 - 1023 # 430 - 499 (appears to be open but use with caution.) From d75a637c0ea62024dd7754eba281fb4556ea1ba4 Mon Sep 17 00:00:00 2001 From: tapple Date: Fri, 16 Jan 2026 15:22:27 -0800 Subject: [PATCH 023/102] re-order slua_definitions to match slua_default.d.luau first, and lsl_definitions.yaml second --- slua_definitions.yaml | 291 +++++++++++++++++++++--------------------- 1 file changed, 149 insertions(+), 142 deletions(-) diff --git a/slua_definitions.yaml b/slua_definitions.yaml index b2e6de8..1c2b71f 100644 --- a/slua_definitions.yaml +++ b/slua_definitions.yaml @@ -1,3 +1,118 @@ +%YAML 1.2 +--- +# yaml-language-server: $schema=http://raw.githubusercontent.com/secondlife/lsl-definitions/refs/heads/main/lsl_definitions.schema.json +# +# increment only when the file format changes, not just the content +version: 1.0.0 +typeAliases: +- name: rotation + comment: '''rotation'' is an alias for ''quaternion''' + definition: + name: quaternion + kind: reference +- name: numeric + definition: + kind: union + types: + - boolean + - number +- name: list + definition: + elementType: + kind: union + types: + - string + - number + - vector + - uuid + - quaternion + - boolean + kind: array +- name: LLDetectedEventName + definition: + kind: literal-union + values: [] +- name: LLNonDetectedEventName + definition: + kind: literal-union + values: [] +- name: LLEventName + definition: + kind: union + types: + - LLDetectedEventName + - LLNonDetectedEventName +- name: LLEventHandler + definition: + kind: function + parameters: + - type: any + variadic: true + returnType: () +- name: LLDetectedEventHandler + definition: + kind: function + parameters: + - name: detected + type: + elementType: LLDetectedEvent + kind: array + returnType: () +- name: LLTimerEveryCallback + comment: Callback type for LLTimers.every() - receives scheduled time and interval + definition: + kind: function + parameters: + - name: scheduled + type: number + - name: interval + type: number + returnType: () +- name: LLTimerOnceCallback + comment: Callback type for LLTimers.once() - receives scheduled time + definition: + kind: function + parameters: + - name: scheduled + type: number + returnType: () +- name: LLTimerCallback + comment: Union of timer callback types + definition: + kind: union + types: + - LLTimerEveryCallback + - LLTimerOnceCallback + - (...any) -> ...any +- name: OsDateTime + comment: Date/time table structure used by os.date and os.time + definition: + kind: table + properties: + - name: year + type: number + - name: month + type: number + - name: day + type: number + - name: hour + type: number + optional: true + - name: min + type: number + optional: true + - name: sec + type: number + optional: true + - name: wday + type: number + optional: true + - name: yday + type: number + optional: true + - name: isdst + type: boolean + optional: true classes: - name: quaternion comment: 'Luau Type Definition for LSL UserData Type: quaternion' @@ -202,38 +317,6 @@ classes: - name: callback type: LLTimerCallback returnType: boolean -constants: [] -globalFunctions: -- name: dangerouslyexecuterequiredmodule - comment: Dangerously executes a required module function - parameters: - - name: f - type: (...any) -> ...any - returnType: '...any' -- name: touuid - comment: Converts a string, buffer, or uuid to a uuid, returns nil if invalid - parameters: - - name: val - type: string | buffer | uuid - returnType: uuid? -- name: tovector - comment: Converts a value to a vector, returns nil if invalid - parameters: - - name: val - type: any - returnType: vector? -- name: toquaternion - comment: Converts a value to a quaternion, returns nil if invalid - parameters: - - name: val - type: any - returnType: quaternion? -- name: torotation - comment: Converts a value to a rotation (quaternion), returns nil if invalid - parameters: - - name: val - type: any - returnType: quaternion? globalVariables: - name: quaternion comment: Global 'quaternion' library table with callable metatable @@ -553,6 +636,37 @@ globalVariables: - name: setfenv comment: setfenv is removed in SLua type: nil +globalFunctions: +- name: dangerouslyexecuterequiredmodule + comment: Dangerously executes a required module function + parameters: + - name: f + type: (...any) -> ...any + returnType: '...any' +- name: touuid + comment: Converts a string, buffer, or uuid to a uuid, returns nil if invalid + parameters: + - name: val + type: string | buffer | uuid + returnType: uuid? +- name: tovector + comment: Converts a value to a vector, returns nil if invalid + parameters: + - name: val + type: any + returnType: vector? +- name: toquaternion + comment: Converts a value to a quaternion, returns nil if invalid + parameters: + - name: val + type: any + returnType: quaternion? +- name: torotation + comment: Converts a value to a rotation (quaternion), returns nil if invalid + parameters: + - name: val + type: any + returnType: quaternion? modules: - name: bit32 comment: Bitwise operations library @@ -1773,113 +1887,6 @@ modules: - name: charpattern comment: Pattern that matches exactly one UTF-8 byte sequence type: string -typeAliases: -- name: rotation - comment: '''rotation'' is an alias for ''quaternion''' - definition: - name: quaternion - kind: reference -- name: numeric - definition: - kind: union - types: - - boolean - - number -- name: list - definition: - elementType: - kind: union - types: - - string - - number - - vector - - uuid - - quaternion - - boolean - kind: array -- name: LLDetectedEventName - definition: - kind: literal-union - values: [] -- name: LLNonDetectedEventName - definition: - kind: literal-union - values: [] -- name: LLEventName - definition: - kind: union - types: - - LLDetectedEventName - - LLNonDetectedEventName -- name: LLEventHandler - definition: - kind: function - parameters: - - type: any - variadic: true - returnType: () -- definition: - kind: function - parameters: - - name: detected - type: - elementType: LLDetectedEvent - kind: array - returnType: () - name: LLDetectedEventHandler -- name: LLTimerEveryCallback - comment: Callback type for LLTimers.every() - receives scheduled time and interval - definition: - kind: function - parameters: - - name: scheduled - type: number - - name: interval - type: number - returnType: () -- name: LLTimerOnceCallback - comment: Callback type for LLTimers.once() - receives scheduled time - definition: - kind: function - parameters: - - name: scheduled - type: number - returnType: () -- name: LLTimerCallback - comment: Union of timer callback types - definition: - kind: union - types: - - LLTimerEveryCallback - - LLTimerOnceCallback - - (...any) -> ...any -- name: OsDateTime - comment: Date/time table structure used by os.date and os.time - definition: - kind: table - properties: - - name: year - type: number - - name: month - type: number - - name: day - type: number - - name: hour - type: number - optional: true - - name: min - type: number - optional: true - - name: sec - type: number - optional: true - - name: wday - type: number - optional: true - - name: yday - type: number - optional: true - - name: isdst - type: boolean - optional: true -version: 1.0.0 +constants: [] +builtinConstants: [] +controls: [] From 5ae792206931f95fa9b21654ab1932c0a16e4bd2 Mon Sep 17 00:00:00 2001 From: tapple Date: Fri, 16 Jan 2026 15:57:31 -0800 Subject: [PATCH 024/102] made a seperate section for baseClasses, to better match slua_defs.d.luau --- slua_definitions.yaml | 222 +++++++++++++++++++++--------------------- 1 file changed, 112 insertions(+), 110 deletions(-) diff --git a/slua_definitions.yaml b/slua_definitions.yaml index 1c2b71f..e2eaacb 100644 --- a/slua_definitions.yaml +++ b/slua_definitions.yaml @@ -4,116 +4,8 @@ # # increment only when the file format changes, not just the content version: 1.0.0 -typeAliases: -- name: rotation - comment: '''rotation'' is an alias for ''quaternion''' - definition: - name: quaternion - kind: reference -- name: numeric - definition: - kind: union - types: - - boolean - - number -- name: list - definition: - elementType: - kind: union - types: - - string - - number - - vector - - uuid - - quaternion - - boolean - kind: array -- name: LLDetectedEventName - definition: - kind: literal-union - values: [] -- name: LLNonDetectedEventName - definition: - kind: literal-union - values: [] -- name: LLEventName - definition: - kind: union - types: - - LLDetectedEventName - - LLNonDetectedEventName -- name: LLEventHandler - definition: - kind: function - parameters: - - type: any - variadic: true - returnType: () -- name: LLDetectedEventHandler - definition: - kind: function - parameters: - - name: detected - type: - elementType: LLDetectedEvent - kind: array - returnType: () -- name: LLTimerEveryCallback - comment: Callback type for LLTimers.every() - receives scheduled time and interval - definition: - kind: function - parameters: - - name: scheduled - type: number - - name: interval - type: number - returnType: () -- name: LLTimerOnceCallback - comment: Callback type for LLTimers.once() - receives scheduled time - definition: - kind: function - parameters: - - name: scheduled - type: number - returnType: () -- name: LLTimerCallback - comment: Union of timer callback types - definition: - kind: union - types: - - LLTimerEveryCallback - - LLTimerOnceCallback - - (...any) -> ...any -- name: OsDateTime - comment: Date/time table structure used by os.date and os.time - definition: - kind: table - properties: - - name: year - type: number - - name: month - type: number - - name: day - type: number - - name: hour - type: number - optional: true - - name: min - type: number - optional: true - - name: sec - type: number - optional: true - - name: wday - type: number - optional: true - - name: yday - type: number - optional: true - - name: isdst - type: boolean - optional: true -classes: +# baseClasses must not depend on anything else in this file (not typeAliases, not classes) +baseClasses: - name: quaternion comment: 'Luau Type Definition for LSL UserData Type: quaternion' methods: @@ -236,6 +128,116 @@ classes: type: number - name: z type: number +typeAliases: +- name: rotation + comment: '''rotation'' is an alias for ''quaternion''' + definition: + name: quaternion + kind: reference +- name: numeric + definition: + kind: union + types: + - boolean + - number +- name: list + definition: + elementType: + kind: union + types: + - string + - number + - vector + - uuid + - quaternion + - boolean + kind: array +- name: LLDetectedEventName + definition: + kind: literal-union + values: [] +- name: LLNonDetectedEventName + definition: + kind: literal-union + values: [] +- name: LLEventName + definition: + kind: union + types: + - LLDetectedEventName + - LLNonDetectedEventName +- name: LLEventHandler + definition: + kind: function + parameters: + - type: any + variadic: true + returnType: () +- name: LLDetectedEventHandler + definition: + kind: function + parameters: + - name: detected + type: + elementType: LLDetectedEvent + kind: array + returnType: () +- name: LLTimerEveryCallback + comment: Callback type for LLTimers.every() - receives scheduled time and interval + definition: + kind: function + parameters: + - name: scheduled + type: number + - name: interval + type: number + returnType: () +- name: LLTimerOnceCallback + comment: Callback type for LLTimers.once() - receives scheduled time + definition: + kind: function + parameters: + - name: scheduled + type: number + returnType: () +- name: LLTimerCallback + comment: Union of timer callback types + definition: + kind: union + types: + - LLTimerEveryCallback + - LLTimerOnceCallback + - (...any) -> ...any +- name: OsDateTime + comment: Date/time table structure used by os.date and os.time + definition: + kind: table + properties: + - name: year + type: number + - name: month + type: number + - name: day + type: number + - name: hour + type: number + optional: true + - name: min + type: number + optional: true + - name: sec + type: number + optional: true + - name: wday + type: number + optional: true + - name: yday + type: number + optional: true + - name: isdst + type: boolean + optional: true +classes: - name: LLDetectedEvent comment: Event detection class providing access to detected object/avatar information methods: [] From 1531cde18c5f39cf82c51545ed8fd32c037f4c3d Mon Sep 17 00:00:00 2001 From: tapple Date: Fri, 16 Jan 2026 17:15:40 -0800 Subject: [PATCH 025/102] keywords_slua sections controls, types, and constants are now generated from yaml --- gen_definitions.py | 196 ++++++++++++++++++++++++++++++++++++++++-- slua_definitions.yaml | 70 ++++++++++++++- 2 files changed, 255 insertions(+), 11 deletions(-) diff --git a/gen_definitions.py b/gen_definitions.py index 76a2764..61589b7 100644 --- a/gen_definitions.py +++ b/gen_definitions.py @@ -384,6 +384,13 @@ class LSLFunctionRanges(enum.IntEnum): SCRIPT_ID_LIST_ADDITIONS = 800 +class SLuaDefinitions(NamedTuple): + definitionSections: Dict[str, Any] + builtinConstants: Dict[str, LSLConstant] + controls: dict + builtinTypes: dict + + def _escape_python(val: str) -> str: """Encode a string with escapes according to repr() rules""" # Syntax files have double-encoded values :( @@ -555,7 +562,6 @@ def _validate_identifier(self, name: str) -> None: raise KeyError(f"{name!r} is a reserved name") def _handle_constant(self, const_name: str, const_data: dict) -> LSLConstant: - self._validate_identifier(const_name) const = LSLConstant( name=const_name, type=LSLType(const_data["type"]), @@ -581,6 +587,175 @@ def _massage_const_value(val: Any) -> Any: return _unescape_python(val) +class SLuaDefinitionParser: + def __init__(self): + self._definitions = SLuaDefinitions({}, {}, {}, {}) + + def parse_file(self, name: str) -> SLuaDefinitions: + if name.endswith(".llsd"): + return self.parse_llsd_file(name) + return self.parse_yaml_file(name) + + def parse_yaml_file(self, name: str): + with open(name, "rb") as f: + return self._parse_dict(yaml.safe_load(f.read())) + + def parse_llsd_file(self, name: str) -> SLuaDefinitions: + with open(name, "rb") as f: + return self.parse_llsd_blob(f.read()) + + def parse_llsd_blob(self, llsd_blob: bytes) -> SLuaDefinitions: + return self._parse_dict(llsd.parse_xml(llsd_blob)) + + def _parse_dict(self, def_dict: dict) -> SLuaDefinitions: + if any(x for x in self._definitions): + raise RuntimeError("Already parsed!") + + # keywords-lua.xml stuff + self._definitions.controls.update(def_dict["controls"]) + self._definitions.builtinTypes.update(def_dict["builtinTypes"]) + for const_name, const_data in def_dict["builtinConstants"].items(): + self._handle_constant(const_name, const_data) + + # slua.d.luau stuff +# for event_name, event_data in def_dict["events"].items(): +# self._handle_event(event_name, event_data) +# for func_name, func_data in def_dict["functions"].items(): +# func = self._handle_function(func_name, func_data) +# if func.func_id in seen_func_ids: +# raise ValueError(f"Func ID {func.func_id} was re-used by {func!r}") +# seen_func_ids.add(func.func_id) + + return self._definitions + + def _handle_constant(self, const_name: str, const_data: dict) -> LSLConstant: + self._validate_identifier(const_name) + const = LSLConstant( + name=const_name, + tooltip=const_data.get("tooltip", ""), + slua_type=const_data["type"], + value=const_name, + type=None, + slua_removed=False, + private=False, + deprecated=False, + ) + self._definitions.builtinConstants[const.name] = const + return const + + def _handle_event(self, event_name: str, event_data: dict) -> LSLEvent: + self._validate_identifier(event_name) + event = LSLEvent( + name=event_name, + tooltip=event_data.get("tooltip", ""), + arguments=[ + self._handle_argument(event_name, arg) + for arg in (event_data.get("arguments") or []) + ], + private=event_data.get("private", False), + deprecated=event_data.get("deprecated", False), + ) + + if event.name in self._definitions.events: + raise KeyError(f"{event.name} is already defined") + self._validate_args(event) + + self._definitions.events[event.name] = event + return event + + def _handle_function(self, func_name: str, func_data: dict) -> LSLFunction: + self._validate_identifier(func_name) + func = LSLFunction( + name=func_name, + tooltip=func_data.get("tooltip", ""), + # These do actually need to be floats. + energy=float(func_data["energy"] or "0.0"), + sleep=float(func_data["sleep"] or "0.0"), + # 99.9% of the time this won't be specified, if it isn't, just use `sleep`'s value. + mono_sleep=float(func_data.get("mono-sleep", func_data.get("sleep")) or "0.0"), + ret_type=LSLType(func_data["return"]), + slua_type=func_data.get("slua-return", None), + type_arguments=func_data.get("type-arguments", []), + arguments=[ + self._handle_argument(func_name, arg) for arg in (func_data.get("arguments") or []) + ], + private=func_data.get("private", False), + god_mode=func_data.get("god-mode", False), + deprecated=func_data.get("deprecated", False), + func_id=func_data["func-id"], + pure=func_data.get("pure", False), + native=func_data.get("native", False), + index_semantics=bool(func_data.get("index-semantics", False)), + bool_semantics=bool(func_data.get("bool-semantics", False)), + ) + + if func.name in self._definitions.functions: + raise KeyError(f"{func.name} is already defined") + + if func.index_semantics and func.ret_type != LSLType.INTEGER: + raise ValueError( + f"{func.name} has ret with index semantics, but ret type is {func.ret_type!r}" + ) + if func.bool_semantics and func.ret_type != LSLType.INTEGER: + raise ValueError( + f"{func.name} has ret with bool semantics, but ret type is {func.ret_type!r}" + ) + + if func.bool_semantics and func.index_semantics: + raise ValueError(f"Can't have both bool and index semantics for {func.name}") + + self._validate_args(func) + + self._definitions.functions[func.name] = func + return func + + @staticmethod + def _handle_argument(func_name: str, arg_dict: dict) -> LSLArgument: + if len(arg_dict) != 1: + # Arguments are meant to be an array of single-element dicts to keep order. + raise ValueError(f"Expected {func_name}'s {arg_dict!r} to only have one element") + + arg_name, arg_data = list(arg_dict.items())[0] + arg = LSLArgument( + name=arg_name, + type=LSLType(arg_data["type"]), + slua_type=arg_data.get("slua-type", None), + index_semantics=bool(arg_data.get("index-semantics", False)), + bool_semantics=bool(arg_data.get("bool-semantics", False)), + tooltip=arg_data.get("tooltip", ""), + ) + if arg.index_semantics and arg.type != LSLType.INTEGER: + raise ValueError( + f"{func_name}'s {arg_name} has index semantics, but type is {arg.type!r}" + ) + return arg + + def _validate_args(self, obj: Union[LSLEvent, LSLFunction]) -> None: + unique_arg_names = set(a.name for a in obj.arguments) + if len(unique_arg_names) != len(obj.arguments): + raise KeyError(f"Duplicate argument names in {obj.name}") + for name in unique_arg_names: + self._validate_identifier(name) + if obj.name.startswith("llDetected"): + if not all(x.index_semantics for x in obj.arguments): + raise ValueError(f"{obj.name} had argument without index semantics") + + _IDENTIFIER_RE = re.compile(r"\A[_a-zA-Z][_a-zA-Z0-9]*\Z") + + def _validate_identifier(self, name: str) -> None: + if not re.match(self._IDENTIFIER_RE, name): + raise KeyError(f"{name!r} is not a valid identifier") + + @staticmethod + def _massage_const_value(val: Any) -> Any: + if not isinstance(val, str): + return val + # Unescape any Python-like string escapes in the code + return _unescape_python(val) + + + + def _to_f32(val: float) -> float: return ctypes.c_float(val).value @@ -645,19 +820,19 @@ def dump_syntax(definitions: LSLDefinitions, pretty: bool = False) -> bytes: return llsd.format_xml(syntax, c_compat=True, sort_maps=True) -def dump_slua_syntax(definitions: LSLDefinitions, pretty: bool = False) -> bytes: +def dump_slua_syntax(definitions: LSLDefinitions, slua_definitions_file: str, pretty: bool = False) -> bytes: """Write a syntax file for use by viewers""" + parser = SLuaDefinitionParser() + slua_definitions = parser.parse_file(slua_definitions_file) syntax = { - "controls": definitions.controls.copy(), - "types": definitions.types.copy(), + "controls": slua_definitions.controls.copy(), + "types": slua_definitions.builtinTypes.copy(), "constants": {}, "events": {}, "functions": {}, "llsd-lsl-syntax-version": 2, } for event in sorted(definitions.events.values(), key=lambda x: x.name): - if event.private: - continue syntax["events"][event.name] = event.to_slua_dict() for func in sorted(definitions.functions.values(), key=lambda x: x.name): @@ -665,6 +840,8 @@ def dump_slua_syntax(definitions: LSLDefinitions, pretty: bool = False) -> bytes continue syntax["functions"][func.compute_slua_name()] = func.to_slua_dict() + for const in slua_definitions.builtinConstants.values(): + syntax["constants"][const.name] = const.to_slua_dict() for const in sorted(definitions.constants.values(), key=lambda x: x.name): if const.private: continue @@ -2100,13 +2277,14 @@ def main(): sub = subparsers.add_parser("syntax") sub.add_argument("filename") - sub.add_argument("--pretty", action="store_true", help="Pretty-print the output") + sub.add_argument("--pretty", action="store_true", help="Pretty-print the XML output") sub.set_defaults(func=lambda args, defs: _write_if_different(args.filename, dump_syntax(defs, args.pretty))) sub = subparsers.add_parser("slua_syntax") + sub.add_argument("slua_definitions", help="Path to the SLua definition yaml") sub.add_argument("filename") - sub.add_argument("--pretty", action="store_true", help="Pretty-print the output") - sub.set_defaults(func=lambda args, defs: _write_if_different(args.filename, dump_slua_syntax(defs, args.pretty))) + sub.add_argument("--pretty", action="store_true", help="Pretty-print the XML output") + sub.set_defaults(func=lambda args, defs: _write_if_different(args.filename, dump_slua_syntax(defs, args.slua_definitions, args.pretty))) sub = subparsers.add_parser("gen_constant_lsl_script") sub.set_defaults(func=lambda args, defs: gen_constant_lsl_script(defs)) diff --git a/slua_definitions.yaml b/slua_definitions.yaml index e2eaacb..29d001f 100644 --- a/slua_definitions.yaml +++ b/slua_definitions.yaml @@ -1890,5 +1890,71 @@ modules: comment: Pattern that matches exactly one UTF-8 byte sequence type: string constants: [] -builtinConstants: [] -controls: [] + +# Everything below here is only for keywords.xml generation, not typechecking +controls: + do: + tooltip: "Lua do block: do ... end" + if: + tooltip: "Lua if statement: if condition then ... end" + then: + tooltip: "Lua then keyword: introduces the block executed when an if condition is true." + else: + tooltip: "Lua else keyword: specifies the alternative block in an if/else statement." + elseif: + tooltip: "Lua elseif keyword: provides an additional conditional branch in an if statement." + end: + tooltip: "Lua end keyword: closes control structures like if, do, while, for, and function." + for: + tooltip: "Lua for loop: for var = start, end, step do ... end" + goto: + tooltip: "Lua goto statement: jumps to a specified label." + return: + tooltip: "Lua return statement: returns a value from a function." + while: + tooltip: "Lua while loop: while condition do ... end" + repeat: + tooltip: "Lua repeat loop: repeat ... until condition" + until: + tooltip: "Lua until keyword: ends a repeat loop by testing a condition." + function: + tooltip: "Lua function keyword: begins a function definition." + break: + tooltip: "Lua break statement: exits the nearest loop." + local: + tooltip: "Lua local keyword: declares a local variable or function." + in: + tooltip: "Lua in keyword: used in generic for loops to iterate over elements." + not: + tooltip: "Lua not operator: performs logical negation." + and: + tooltip: "Lua and operator: performs logical conjunction." + or: + tooltip: "Lua or operator: performs logical disjunction." +builtinTypes: + boolean: + tooltip: "Boolean: represents a true or false value." + number: + tooltip: Double‑precision floating point number. + string: + tooltip: Text data (UTF‑8). + table: + tooltip: Collection of key‑value pairs. + thread: + tooltip: Represents a coroutine. + userdata: + tooltip: Opaque external data. + vector: + tooltip: A vector is a data type that contains a set of three float values.\nVectors are used to represent colors (RGB), positions, and directions/velocities. + uuid: + tooltip: A 128‑bit unique identifier formatted as 36 hexadecimal characters (8‑4‑4‑4‑12), e.g. "A822FF2B-FF02-461D-B45D-DCD10A2DE0C2". +builtinConstants: + nil: + tooltip: "Lua nil: represents the absence of a useful value." + type: nil + 'true': + tooltip: "Lua true: Boolean true value." + type: boolean + 'false': + tooltip: "Lua false: Boolean false value." + type: boolean From bf2c11182dd47e1b39fb733287d25d7af005a554 Mon Sep 17 00:00:00 2001 From: tapple Date: Sat, 17 Jan 2026 08:35:00 -0800 Subject: [PATCH 026/102] Now the builtin functions section is generated --- gen_definitions.py | 122 ++++++++++++++++++++++++- slua_definitions.yaml | 206 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 326 insertions(+), 2 deletions(-) diff --git a/gen_definitions.py b/gen_definitions.py index 61589b7..b6bdf73 100644 --- a/gen_definitions.py +++ b/gen_definitions.py @@ -383,12 +383,119 @@ class LSLFunctionRanges(enum.IntEnum): SCRIPT_ID_GLTF_MATERIALS = 760 SCRIPT_ID_LIST_ADDITIONS = 800 +@dataclasses.dataclass +class SLuaParameter: + """ + Function/method parameter + - Regular parameters require both name and type + - Self parameters only need name (type is implicit) + - Variadic parameters only need type (no name) + """ + name: Optional[str] = None + type: Optional[str] = None + optional: bool = False + variadic: bool = False + tooltip: str = "" + + @classmethod + def from_defs_dict(cls, data: dict) -> "SLuaParameter": + return cls(**data) + + +@dataclasses.dataclass +class SLuaFunctionOverload: + """Function overload signature""" + parameters: List[SLuaParameter] + returnType: str + comment: Optional[str] = None + +@dataclasses.dataclass +class SLuaFunctionSignature: + """Function or method signature with optional overloads""" + name: str + parameters: List[SLuaParameter] + returnType: str + typeParameters: Optional[List[str]] = None + comment: Optional[str] = None + overloads: Optional[List[SLuaFunctionOverload]] = None + + @classmethod + def from_defs_dict(cls, data: dict) -> "SLuaFunctionSignature": + return cls( + name=data["name"], + typeParameters=data.get("typeParameters", []), + parameters=[SLuaParameter.from_defs_dict(p) for p in data.get("parameters", [])], + returnType=data.get("returnType", "void"), + comment=data.get("comment"), + ) + + def to_keywords_dict(self) -> dict: + return _remove_worthless( + { + "type-arguments": self.typeParameters, + "arguments": [ + { + a.name: { + "tooltip": a.tooltip, + "type": a.type, + } + } + for a in self.parameters + ], + "energy": 10.0, + "return": self.returnType, + "sleep": 0.0, + "tooltip": self.comment, + } + ) + + +@dataclasses.dataclass +class SLuaTypeAlias: + """Type alias definition""" + name: str + definition: str + comment: Optional[str] = None + + +@dataclasses.dataclass +class SLuaClassProperty: + """Class property definition""" + name: str + type: str + comment: Optional[str] = None + + +@dataclasses.dataclass +class SLuaClassDeclaration: + """Class declaration with properties and methods""" + name: str + properties: Optional[List[SLuaClassProperty]] = None + methods: Optional[List[SLuaFunctionSignature]] = None + comment: Optional[str] = None + + +@dataclasses.dataclass +class SLuaGlobalVariable: + """Global variable declaration""" + name: str + type: str + comment: Optional[str] = None + class SLuaDefinitions(NamedTuple): - definitionSections: Dict[str, Any] + # for typechecking and keywords + baseClasses: List[SLuaClassDeclaration] + typeAliases: List[SLuaTypeAlias] + classes: List[SLuaClassDeclaration] + globalVariables: List[SLuaGlobalVariable] + globalFunctions: List[SLuaFunctionSignature] + + # for keywords only builtinConstants: Dict[str, LSLConstant] controls: dict builtinTypes: dict + builtinFunctions: List[SLuaFunctionSignature] def _escape_python(val: str) -> str: @@ -589,7 +696,7 @@ def _massage_const_value(val: Any) -> Any: class SLuaDefinitionParser: def __init__(self): - self._definitions = SLuaDefinitions({}, {}, {}, {}) + self._definitions = SLuaDefinitions([], [], [], [], [], {}, {}, {}, []) def parse_file(self, name: str) -> SLuaDefinitions: if name.endswith(".llsd"): @@ -618,6 +725,10 @@ def _parse_dict(self, def_dict: dict) -> SLuaDefinitions: self._handle_constant(const_name, const_data) # slua.d.luau stuff + for func in def_dict["builtinFunctions"]: + self._definitions.builtinFunctions.append(SLuaFunctionSignature.from_defs_dict(func)) + for func in def_dict["globalFunctions"]: + self._definitions.globalFunctions.append(SLuaFunctionSignature.from_defs_dict(func)) # for event_name, event_data in def_dict["events"].items(): # self._handle_event(event_name, event_data) # for func_name, func_data in def_dict["functions"].items(): @@ -778,6 +889,8 @@ def _remove_worthless(val: dict) -> dict: val.pop("index-semantics", None) if not val.get("type-arguments"): val.pop("type-arguments", None) + if not val.get("tooltip"): + val.pop("ooltip", None) return val @@ -835,6 +948,11 @@ def dump_slua_syntax(definitions: LSLDefinitions, slua_definitions_file: str, pr for event in sorted(definitions.events.values(), key=lambda x: x.name): syntax["events"][event.name] = event.to_slua_dict() + #for func in sorted(slua_definitions.globalFunctions, key=lambda x: x.name): + for func in slua_definitions.builtinFunctions: + syntax["functions"][func.name] = func.to_keywords_dict() + for func in sorted(slua_definitions.globalFunctions, key=lambda x: x.name): + syntax["functions"][func.name] = func.to_keywords_dict() for func in sorted(definitions.functions.values(), key=lambda x: x.name): if func.private: continue diff --git a/slua_definitions.yaml b/slua_definitions.yaml index 29d001f..172d472 100644 --- a/slua_definitions.yaml +++ b/slua_definitions.yaml @@ -1958,3 +1958,209 @@ builtinConstants: 'false': tooltip: "Lua false: Boolean false value." type: boolean +builtinFunctions: +- name: assert + comment: Checks if the value is truthy; if not, raises an error with the optional message. + parameters: + - name: value + tooltip: The value to check for truthiness. + type: any + - name: message + tooltip: Optional error message to display if the value is not truthy. + type: string? + returnType: any +- name: error + comment: Raises an error with the specified object and optional call stack level. + parameters: + - name: obj + tooltip: The error object to raise. + type: any + - name: level + tooltip: Optional level to attribute the error to in the call stack. + type: number? + returnType: void +- name: gcinfo + comment: Returns the total heap size in kilobytes. + returnType: number +- name: getfenv + comment: Returns the environment table for the specified function or stack index. + parameters: + - name: target + tooltip: Optional function or stack index to get the environment table for. + type: (function | number)? + returnType: table +- name: getmetatable + comment: Returns the metatable for the specified object. + parameters: + - name: obj + tooltip: The object to get the metatable for. + type: any + returnType: table? +- name: next + comment: Returns the next key-value pair in the table traversal order. + parameters: + - name: t + tooltip: The table to traverse. + type: table + - name: i + tooltip: Optional key to start traversal after. + type: any? + returnType: (any, any)? +- name: newproxy + comment: Creates a new untyped userdata object with an optional metatable. + parameters: + - name: mt + tooltip: Optional boolean to create a modifiable metatable. + type: boolean? + returnType: userdata +- name: print + comment: Prints all arguments to standard output using Tab as a separator. + parameters: + - name: args + tooltip: Arguments to print to standard output. + type: ...any + returnType: void +- name: rawequal + comment: Returns true if a and b have the same type and value. + parameters: + - name: a + tooltip: First object to compare. + type: any + - name: b + tooltip: Second object to compare. + type: any + returnType: boolean +- name: rawget + comment: Performs a table lookup bypassing metatables. + parameters: + - name: t + tooltip: The table to perform the lookup on. + type: table + - name: k + tooltip: The key to look up in the table. + type: any + returnType: any? +- name: rawset + comment: Assigns a value to a table field bypassing metatables. + parameters: + - name: t + tooltip: The table to assign the value to. + type: table + - name: k + tooltip: The key to assign the value to. + type: any + - name: v + tooltip: The value to assign. + type: any + returnType: void +- name: select + comment: Returns a subset of arguments or the number of arguments. + parameters: + - name: i + tooltip: The index or '#' to count arguments. + type: string | number + - name: args + tooltip: The arguments to select from. + type: ...any + returnType: any +- name: setfenv + comment: Changes the environment table for the specified function or stack index. + parameters: + - name: target + tooltip: The function or stack index to set the environment for. + type: function | number + - name: env + tooltip: The environment table to set. + type: table + returnType: void +- name: setmetatable + comment: Changes the metatable for the given table. + parameters: + - name: t + tooltip: The table to set the metatable for. + type: table + - name: mt + tooltip: The metatable to set. + type: table? + returnType: void +- name: tonumber + comment: Converts the input string to a number in the specified base. + parameters: + - name: s + tooltip: The string to convert to a number. + type: string + - name: base + tooltip: Optional base for the conversion. + type: number? + returnType: number? +- name: tostring + comment: Converts the input object to a string. + parameters: + - name: obj + tooltip: The object to convert to a string. + type: any + returnType: string +- name: type + comment: Returns the type of the object as a string. + parameters: + - name: obj + tooltip: The object to get the type of. + type: any + returnType: string +- name: typeof + comment: Returns the type of the object, including custom userdata types. + parameters: + - name: obj + tooltip: The object to get the type of. + type: any + returnType: string +- name: ipairs + comment: Returns an iterator for numeric key-value pairs in the table. + parameters: + - name: t + tooltip: The table to iterate over. + type: table + returnType: iterator +- name: pairs + comment: Returns an iterator for all key-value pairs in the table. + parameters: + - name: t + tooltip: The table to iterate over. + type: table + returnType: iterator +- name: pcall + comment: Calls function f with parameters args, returning success and function results or an error. + parameters: + - name: f + tooltip: A function to be called. + type: function + - name: args + tooltip: Arguments to pass to the function. + type: variadic + returnType: boolean, variadic +- name: xpcall + comment: Calls function f with parameters args, handling errors with e if they occur. + parameters: + - name: f + tooltip: A function to be called. + type: function + - name: e + tooltip: Error handler function. + type: function + - name: args + tooltip: Arguments to pass to the function. + type: variadic + returnType: boolean, variadic +- name: unpack + comment: Returns values from an array in the specified index range. + parameters: + - name: a + tooltip: Array from which to extract values. + type: array + - name: f + tooltip: Starting index (optional, defaults to 1). + type: number + - name: t + tooltip: "Ending index (optional, defaults to #a)." + type: number + returnType: variadic From 198c2b466b9735b7ae0add16a175a7aa9a691e1b Mon Sep 17 00:00:00 2001 From: tapple Date: Sat, 17 Jan 2026 08:48:18 -0800 Subject: [PATCH 027/102] removed getfenv, setfenv --- slua_definitions.yaml | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/slua_definitions.yaml b/slua_definitions.yaml index 172d472..2fcb082 100644 --- a/slua_definitions.yaml +++ b/slua_definitions.yaml @@ -1982,13 +1982,6 @@ builtinFunctions: - name: gcinfo comment: Returns the total heap size in kilobytes. returnType: number -- name: getfenv - comment: Returns the environment table for the specified function or stack index. - parameters: - - name: target - tooltip: Optional function or stack index to get the environment table for. - type: (function | number)? - returnType: table - name: getmetatable comment: Returns the metatable for the specified object. parameters: @@ -2063,16 +2056,6 @@ builtinFunctions: tooltip: The arguments to select from. type: ...any returnType: any -- name: setfenv - comment: Changes the environment table for the specified function or stack index. - parameters: - - name: target - tooltip: The function or stack index to set the environment for. - type: function | number - - name: env - tooltip: The environment table to set. - type: table - returnType: void - name: setmetatable comment: Changes the metatable for the given table. parameters: From a5458ca30870323648d15825e27d699137853fb9 Mon Sep 17 00:00:00 2001 From: tapple Date: Sun, 18 Jan 2026 07:31:52 -0800 Subject: [PATCH 028/102] Add basic validators to the slua_definitions parser: valid id, no dups, declared type --- gen_definitions.py | 384 ++++++++++++++++++++++----------------------- 1 file changed, 192 insertions(+), 192 deletions(-) diff --git a/gen_definitions.py b/gen_definitions.py index b6bdf73..c63e998 100644 --- a/gen_definitions.py +++ b/gen_definitions.py @@ -167,17 +167,20 @@ def to_dict(self) -> dict: } ) - def to_slua_dict(self) -> dict: - return _remove_worthless( - { - "deprecated": self.deprecated, - # Will always use a node, but that's fine for our purposes. - # That's already the case for vector and hex int constants, anyway. - "tooltip": self.tooltip, - "type": self.slua_type or str(self.type), - "value": _escape_python(self.value), - } - ) + def to_slua_dict(self, slua: "SLuaDefinitionParser") -> dict: + try: + return _remove_worthless( + { + "deprecated": self.deprecated, + # Will always use a node, but that's fine for our purposes. + # That's already the case for vector and hex int constants, anyway. + "tooltip": self.tooltip, + "type": slua.validate_type(self.slua_type or self.type.meta.slua_name), + "value": _escape_python(self.value), + } + ) + except ValueError as e: + raise ValueError(f"In constant {self.name}: {e}") from e @dataclasses.dataclass @@ -222,22 +225,25 @@ def to_dict(self) -> dict: } ) - def to_slua_dict(self) -> dict: - return _remove_worthless( - { - "deprecated": self.deprecated, - "arguments": [ - { - a.name: { - "tooltip": a.tooltip, - "type": a.compute_slua_type(), + def to_slua_dict(self, slua: "SLuaDefinitionParser") -> dict: + try: + return _remove_worthless( + { + "deprecated": self.deprecated, + "arguments": [ + { + a.name: { + "tooltip": a.tooltip, + "type": slua.validate_type(a.compute_slua_type()), + } } - } - for a in self.arguments - ], - "tooltip": self.tooltip, - } - ) + for a in self.arguments + ], + "tooltip": self.tooltip, + } + ) + except ValueError as e: + raise ValueError(f"In event {self.name}: {e}") from e @dataclasses.dataclass @@ -331,27 +337,30 @@ def compute_slua_type(self) -> str: return "boolean" return self.ret_type.meta.slua_name - def to_slua_dict(self) -> dict: - return _remove_worthless( - { - "type-arguments": self.type_arguments, - "arguments": [ - { - a.name: { - "tooltip": a.tooltip, - "type": a.compute_slua_type(), + def to_slua_dict(self, slua: "SLuaDefinitionParser") -> dict: + try: + return _remove_worthless( + { + "type-arguments": self.type_arguments, + "arguments": [ + { + a.name: { + "tooltip": a.tooltip, + "type": slua.validate_type(a.compute_slua_type()), + } } - } - for a in self.arguments - ], - "deprecated": self.deprecated, - "energy": self.energy, - "god-mode": self.god_mode, - "return": self.compute_slua_type(), - "sleep": self.sleep, - "tooltip": self.tooltip, - } - ) + for a in self.arguments + ], + "deprecated": self.deprecated, + "energy": self.energy, + "god-mode": self.god_mode, + "return": slua.validate_return_type(self.compute_slua_type()), + "sleep": self.sleep, + "tooltip": self.tooltip, + } + ) + except ValueError as e: + raise ValueError(f"In function {self.name}: {e}") from e class LSLDefinitions(NamedTuple): @@ -383,23 +392,36 @@ class LSLFunctionRanges(enum.IntEnum): SCRIPT_ID_GLTF_MATERIALS = 760 SCRIPT_ID_LIST_ADDITIONS = 800 + +@dataclasses.dataclass +class SLuaProperty: + """ Property definition """ + name: str + type: str + value: str | None = None + comment: str = "" + + def to_keywords_dict(self) -> dict: + return { + "tooltip": self.comment, + "type": self.type, + **({"value": _escape_python(self.value)} + if self.value is not None else {}), + } + + + @dataclasses.dataclass class SLuaParameter: """ Function/method parameter - Regular parameters require both name and type - Self parameters only need name (type is implicit) - - Variadic parameters only need type (no name) + - Variadic parameters need name "..." and type """ - name: Optional[str] = None + name: str type: Optional[str] = None - optional: bool = False - variadic: bool = False - tooltip: str = "" - - @classmethod - def from_defs_dict(cls, data: dict) -> "SLuaParameter": - return cls(**data) + comment: str = "" @dataclasses.dataclass @@ -419,16 +441,6 @@ class SLuaFunctionSignature: comment: Optional[str] = None overloads: Optional[List[SLuaFunctionOverload]] = None - @classmethod - def from_defs_dict(cls, data: dict) -> "SLuaFunctionSignature": - return cls( - name=data["name"], - typeParameters=data.get("typeParameters", []), - parameters=[SLuaParameter.from_defs_dict(p) for p in data.get("parameters", [])], - returnType=data.get("returnType", "void"), - comment=data.get("comment"), - ) - def to_keywords_dict(self) -> dict: return _remove_worthless( { @@ -450,6 +462,16 @@ def to_keywords_dict(self) -> dict: ) +@dataclasses.dataclass +class SLuaModuleDeclaration: + """ Module declaration with properties and functions """ + name: str + properties: List[SLuaProperty] + functions: List[SLuaFunctionSignature] + comment: str + + + @dataclasses.dataclass class SLuaTypeAlias: """Type alias definition""" @@ -484,18 +506,22 @@ class SLuaGlobalVariable: class SLuaDefinitions(NamedTuple): - # for typechecking and keywords + # for best results, load/generate in the same order defined here + + # 1. Luau builtins. Typecheckers already know about these + controls: dict # same structure as LSLDefinitions.controls + builtinTypes: dict # same structure as LSLDefinitions.types + builtinConstants: List[SLuaProperty] + builtinFunctions: List[SLuaFunctionSignature] + + # 2. SLua base classes. These only depend on Luau builtins baseClasses: List[SLuaClassDeclaration] typeAliases: List[SLuaTypeAlias] + + # 3. SLua standard library. Depends on base classes classes: List[SLuaClassDeclaration] - globalVariables: List[SLuaGlobalVariable] globalFunctions: List[SLuaFunctionSignature] - - # for keywords only - builtinConstants: Dict[str, LSLConstant] - controls: dict - builtinTypes: dict - builtinFunctions: List[SLuaFunctionSignature] + globalVariables: List[SLuaGlobalVariable] def _escape_python(val: str) -> str: @@ -696,7 +722,9 @@ def _massage_const_value(val: Any) -> Any: class SLuaDefinitionParser: def __init__(self): - self._definitions = SLuaDefinitions([], [], [], [], [], {}, {}, {}, []) + self.definitions = SLuaDefinitions({}, {}, [], [], [], [], [], [], []) + self.type_names: Set[str] = set() + self.global_scope: Set[str] = set() def parse_file(self, name: str) -> SLuaDefinitions: if name.endswith(".llsd"): @@ -715,20 +743,30 @@ def parse_llsd_blob(self, llsd_blob: bytes) -> SLuaDefinitions: return self._parse_dict(llsd.parse_xml(llsd_blob)) def _parse_dict(self, def_dict: dict) -> SLuaDefinitions: - if any(x for x in self._definitions): + if any(x for x in self.definitions): raise RuntimeError("Already parsed!") - # keywords-lua.xml stuff - self._definitions.controls.update(def_dict["controls"]) - self._definitions.builtinTypes.update(def_dict["builtinTypes"]) - for const_name, const_data in def_dict["builtinConstants"].items(): - self._handle_constant(const_name, const_data) + # 1. Luau builtins. Typecheckers already know about these + self.definitions.builtinTypes.update(def_dict["builtinTypes"]) + self.type_names.update(self.definitions.builtinTypes.keys()) + self.global_scope.update(self.definitions.builtinTypes.keys()) + self.definitions.controls.update(def_dict["controls"]) + self.global_scope.update(self.definitions.controls.keys()) + self.definitions.builtinConstants.extend( + self._validate_property(const, self.global_scope, const=True) + for const in def_dict["builtinConstants"] + ) + self.definitions.builtinFunctions.extend( + self._validate_function(func, self.global_scope) + for func in def_dict["builtinFunctions"] + ) + # 2. SLua base classes. These only depend on Luau builtins - # slua.d.luau stuff - for func in def_dict["builtinFunctions"]: - self._definitions.builtinFunctions.append(SLuaFunctionSignature.from_defs_dict(func)) - for func in def_dict["globalFunctions"]: - self._definitions.globalFunctions.append(SLuaFunctionSignature.from_defs_dict(func)) + # 3. SLua standard library. Depends on base classes + self.definitions.globalFunctions.extend( + self._validate_function(func, self.global_scope) + for func in def_dict["globalFunctions"] + ) # for event_name, event_data in def_dict["events"].items(): # self._handle_event(event_name, event_data) # for func_name, func_data in def_dict["functions"].items(): @@ -737,22 +775,7 @@ def _parse_dict(self, def_dict: dict) -> SLuaDefinitions: # raise ValueError(f"Func ID {func.func_id} was re-used by {func!r}") # seen_func_ids.add(func.func_id) - return self._definitions - - def _handle_constant(self, const_name: str, const_data: dict) -> LSLConstant: - self._validate_identifier(const_name) - const = LSLConstant( - name=const_name, - tooltip=const_data.get("tooltip", ""), - slua_type=const_data["type"], - value=const_name, - type=None, - slua_removed=False, - private=False, - deprecated=False, - ) - self._definitions.builtinConstants[const.name] = const - return const + return self.definitions def _handle_event(self, event_name: str, event_data: dict) -> LSLEvent: self._validate_identifier(event_name) @@ -774,101 +797,78 @@ def _handle_event(self, event_name: str, event_data: dict) -> LSLEvent: self._definitions.events[event.name] = event return event - def _handle_function(self, func_name: str, func_data: dict) -> LSLFunction: - self._validate_identifier(func_name) - func = LSLFunction( - name=func_name, - tooltip=func_data.get("tooltip", ""), - # These do actually need to be floats. - energy=float(func_data["energy"] or "0.0"), - sleep=float(func_data["sleep"] or "0.0"), - # 99.9% of the time this won't be specified, if it isn't, just use `sleep`'s value. - mono_sleep=float(func_data.get("mono-sleep", func_data.get("sleep")) or "0.0"), - ret_type=LSLType(func_data["return"]), - slua_type=func_data.get("slua-return", None), - type_arguments=func_data.get("type-arguments", []), - arguments=[ - self._handle_argument(func_name, arg) for arg in (func_data.get("arguments") or []) - ], - private=func_data.get("private", False), - god_mode=func_data.get("god-mode", False), - deprecated=func_data.get("deprecated", False), - func_id=func_data["func-id"], - pure=func_data.get("pure", False), - native=func_data.get("native", False), - index_semantics=bool(func_data.get("index-semantics", False)), - bool_semantics=bool(func_data.get("bool-semantics", False)), + def _validate_function(self, data: any, scope: Set[str], method: bool = False) -> SLuaFunctionSignature: + func = SLuaFunctionSignature( + name=data["name"], + typeParameters=data.get("typeParameters", []), + parameters=[SLuaParameter(**p) for p in data.get("parameters", [])], + returnType=data.get("returnType", "void"), + comment=data.get("comment"), ) - - if func.name in self._definitions.functions: - raise KeyError(f"{func.name} is already defined") - - if func.index_semantics and func.ret_type != LSLType.INTEGER: - raise ValueError( - f"{func.name} has ret with index semantics, but ret type is {func.ret_type!r}" - ) - if func.bool_semantics and func.ret_type != LSLType.INTEGER: - raise ValueError( - f"{func.name} has ret with bool semantics, but ret type is {func.ret_type!r}" - ) - - if func.bool_semantics and func.index_semantics: - raise ValueError(f"Can't have both bool and index semantics for {func.name}") - - self._validate_args(func) - - self._definitions.functions[func.name] = func + try: + type_params = set(func.typeParameters) + self._validate_identifier(func.name) + self._validate_scope(func.name, scope) + self.validate_return_type(func.returnType, type_params) + params = func.parameters + params_scope = set() + if method: + if not params or params[0].name != "self" or params[0].type is not None: + raise ValueError(f"Method {func.name} missing self parameter") + params_scope.add("self") + params = params[1:] + if params and params[-1].name == "...": + self.validate_type(params[-1].type, type_params) + params = params[:-1] + for param in params: + self._validate_identifier(param.name) + self._validate_scope(param.name, params_scope) + self.validate_type(param.type, type_params) + except ValueError as e: + raise ValueError(f"In function {func.name}: {e}") from e return func - @staticmethod - def _handle_argument(func_name: str, arg_dict: dict) -> LSLArgument: - if len(arg_dict) != 1: - # Arguments are meant to be an array of single-element dicts to keep order. - raise ValueError(f"Expected {func_name}'s {arg_dict!r} to only have one element") - - arg_name, arg_data = list(arg_dict.items())[0] - arg = LSLArgument( - name=arg_name, - type=LSLType(arg_data["type"]), - slua_type=arg_data.get("slua-type", None), - index_semantics=bool(arg_data.get("index-semantics", False)), - bool_semantics=bool(arg_data.get("bool-semantics", False)), - tooltip=arg_data.get("tooltip", ""), - ) - if arg.index_semantics and arg.type != LSLType.INTEGER: - raise ValueError( - f"{func_name}'s {arg_name} has index semantics, but type is {arg.type!r}" - ) - return arg - - def _validate_args(self, obj: Union[LSLEvent, LSLFunction]) -> None: - unique_arg_names = set(a.name for a in obj.arguments) - if len(unique_arg_names) != len(obj.arguments): - raise KeyError(f"Duplicate argument names in {obj.name}") - for name in unique_arg_names: - self._validate_identifier(name) - if obj.name.startswith("llDetected"): - if not all(x.index_semantics for x in obj.arguments): - raise ValueError(f"{obj.name} had argument without index semantics") + def _validate_property(self, data: any, scope: Set[str], const: bool = False) -> LSLConstant: + prop = SLuaProperty(**data) + self._validate_identifier(prop.name) + self._validate_scope(prop.name, scope) + if const and prop.value is None: + raise ValueError(f"Constant {prop.name} must have a value") + if prop.name == "nil" and prop.type == "nil" and scope is self.global_scope: + return prop # only nil is allowed to be nil + self.validate_type(prop.type) + return prop + + _TYPE_OPERATORS_RE = re.compile(r"[ ?&|{}:\[\]]|\.\.\.") + + def validate_type(self, type: str, type_params: set[str] | None = None) -> str: + if not type: + raise ValueError("Type may not be empty") + known_type_names = self.type_names | (type_params or set()) + if type in known_type_names: + return type + subtypes = self._TYPE_OPERATORS_RE.split(type) + unknown_subtypes = set(subtypes) - (known_type_names | {''}) + if not unknown_subtypes: + return + raise ValueError(f"Unknown types: {unknown_subtypes}") + + def validate_return_type(self, type: str, type_params: set[str] | None = None) -> str: + if type == "void": + return type + return self.validate_type(type, type_params) + + def _validate_scope(self, name: str, scope: Set[str]) -> None: + if name in scope: + raise ValueError(f"{name!r} is already defined in this scope") + scope.add(name) _IDENTIFIER_RE = re.compile(r"\A[_a-zA-Z][_a-zA-Z0-9]*\Z") def _validate_identifier(self, name: str) -> None: if not re.match(self._IDENTIFIER_RE, name): - raise KeyError(f"{name!r} is not a valid identifier") - - @staticmethod - def _massage_const_value(val: Any) -> Any: - if not isinstance(val, str): - return val - # Unescape any Python-like string escapes in the code - return _unescape_python(val) - - - + raise ValueError(f"{name!r} is not a valid identifier") -def _to_f32(val: float) -> float: - return ctypes.c_float(val).value def _remove_worthless(val: dict) -> dict: @@ -890,7 +890,7 @@ def _remove_worthless(val: dict) -> dict: if not val.get("type-arguments"): val.pop("type-arguments", None) if not val.get("tooltip"): - val.pop("ooltip", None) + val.pop("tooltip", None) return val @@ -946,7 +946,7 @@ def dump_slua_syntax(definitions: LSLDefinitions, slua_definitions_file: str, pr "llsd-lsl-syntax-version": 2, } for event in sorted(definitions.events.values(), key=lambda x: x.name): - syntax["events"][event.name] = event.to_slua_dict() + syntax["events"][event.name] = event.to_slua_dict(slua_definitions) #for func in sorted(slua_definitions.globalFunctions, key=lambda x: x.name): for func in slua_definitions.builtinFunctions: @@ -956,16 +956,16 @@ def dump_slua_syntax(definitions: LSLDefinitions, slua_definitions_file: str, pr for func in sorted(definitions.functions.values(), key=lambda x: x.name): if func.private: continue - syntax["functions"][func.compute_slua_name()] = func.to_slua_dict() + syntax["functions"][func.compute_slua_name()] = func.to_slua_dict(slua_definitions) for const in slua_definitions.builtinConstants.values(): - syntax["constants"][const.name] = const.to_slua_dict() + syntax["constants"][const.name] = const.to_slua_dict(slua_definitions) for const in sorted(definitions.constants.values(), key=lambda x: x.name): if const.private: continue if const.slua_removed: continue - syntax["constants"][const.name] = const.to_slua_dict() + syntax["constants"][const.name] = const.to_slua_dict(slua_definitions) if pretty: return llsd.format_pretty_xml(syntax, indent=3, c_compat=True, sort_maps=False) From eac9a03a002c9e0cfdabd2ebebb99e021b7cbee0 Mon Sep 17 00:00:00 2001 From: tapple Date: Sun, 18 Jan 2026 09:03:36 -0800 Subject: [PATCH 029/102] fix the builtin function types --- slua_definitions.yaml | 179 +++++++++++++++++++++++++----------------- 1 file changed, 106 insertions(+), 73 deletions(-) diff --git a/slua_definitions.yaml b/slua_definitions.yaml index 2fcb082..a5773f9 100644 --- a/slua_definitions.yaml +++ b/slua_definitions.yaml @@ -1932,8 +1932,12 @@ controls: or: tooltip: "Lua or operator: performs logical disjunction." builtinTypes: + any: + tooltip: The unspecified type. Disables type-checking. Use unknown instead to use type-checking. boolean: tooltip: "Boolean: represents a true or false value." + never: + tooltip: The empty type that contains no values. number: tooltip: Double‑precision floating point number. string: @@ -1946,39 +1950,45 @@ builtinTypes: tooltip: Opaque external data. vector: tooltip: A vector is a data type that contains a set of three float values.\nVectors are used to represent colors (RGB), positions, and directions/velocities. + unknown: + tooltip: The union of every type. Similar to any without disabling type-checking. uuid: tooltip: A 128‑bit unique identifier formatted as 36 hexadecimal characters (8‑4‑4‑4‑12), e.g. "A822FF2B-FF02-461D-B45D-DCD10A2DE0C2". builtinConstants: - nil: - tooltip: "Lua nil: represents the absence of a useful value." + - name: nil + comment: "Lua nil: represents the absence of a useful value." type: nil - 'true': - tooltip: "Lua true: Boolean true value." + value: nil + - name: 'true' + comment: "Lua true: Boolean true value." type: boolean - 'false': - tooltip: "Lua false: Boolean false value." + value: 'true' + - name: 'false' + comment: "Lua false: Boolean false value." type: boolean + value: 'false' builtinFunctions: - name: assert comment: Checks if the value is truthy; if not, raises an error with the optional message. + typeParameters: [T] parameters: - name: value - tooltip: The value to check for truthiness. - type: any + comment: The value to check for truthiness. + type: T? - name: message - tooltip: Optional error message to display if the value is not truthy. + comment: Optional error message to display if the value is not truthy. type: string? - returnType: any + returnType: T - name: error comment: Raises an error with the specified object and optional call stack level. parameters: - name: obj - tooltip: The error object to raise. + comment: The error object to raise. type: any - name: level - tooltip: Optional level to attribute the error to in the call stack. + comment: Optional level to attribute the error to in the call stack. type: number? - returnType: void + returnType: never - name: gcinfo comment: Returns the total heap size in kilobytes. returnType: number @@ -1986,164 +1996,187 @@ builtinFunctions: comment: Returns the metatable for the specified object. parameters: - name: obj - tooltip: The object to get the metatable for. + comment: The object to get the metatable for. type: any - returnType: table? + returnType: "{any}?" - name: next comment: Returns the next key-value pair in the table traversal order. + typeParameters: [K, V] parameters: - name: t - tooltip: The table to traverse. - type: table + comment: The table to traverse. + type: "{[K]: V}" - name: i - tooltip: Optional key to start traversal after. - type: any? - returnType: (any, any)? + comment: Optional key to start traversal after. + type: K? + returnType: (K, V)? - name: newproxy comment: Creates a new untyped userdata object with an optional metatable. parameters: - name: mt - tooltip: Optional boolean to create a modifiable metatable. + comment: Optional boolean to create a modifiable metatable. type: boolean? returnType: userdata - name: print comment: Prints all arguments to standard output using Tab as a separator. parameters: - name: args - tooltip: Arguments to print to standard output. + comment: Arguments to print to standard output. type: ...any returnType: void - name: rawequal comment: Returns true if a and b have the same type and value. parameters: - name: a - tooltip: First object to compare. + comment: First object to compare. type: any - name: b - tooltip: Second object to compare. + comment: Second object to compare. type: any returnType: boolean - name: rawget comment: Performs a table lookup bypassing metatables. + typeParameters: [K, V] parameters: - name: t - tooltip: The table to perform the lookup on. - type: table + comment: The table to perform the lookup on. + type: "{[K]: V}" - name: k - tooltip: The key to look up in the table. - type: any - returnType: any? + comment: The key to look up in the table. + type: K + returnType: V? - name: rawset comment: Assigns a value to a table field bypassing metatables. + typeParameters: [K, V] parameters: - name: t - tooltip: The table to assign the value to. - type: table + comment: The table to assign the value to. + type: "{[K]: V}" - name: k - tooltip: The key to assign the value to. - type: any + comment: The key to assign the value to. + type: K - name: v - tooltip: The value to assign. - type: any - returnType: void + comment: The value to assign. + type: V + returnType: "{[K]: V}" +- name: rawlen + comment: Returns the length of a table or string bypassing metatables. + typeParameters: [K, V] + parameters: + - name: t + comment: The table to assign the value to. + type: "{[any]: any} | string" + returnType: number - name: select comment: Returns a subset of arguments or the number of arguments. parameters: - name: i - tooltip: The index or '#' to count arguments. + comment: The index or '#' to count arguments. type: string | number - - name: args - tooltip: The arguments to select from. + - name: ... + comment: The arguments to select from. type: ...any returnType: any - name: setmetatable comment: Changes the metatable for the given table. parameters: - name: t - tooltip: The table to set the metatable for. + comment: The table to set the metatable for. type: table - name: mt - tooltip: The metatable to set. + comment: The metatable to set. type: table? returnType: void - name: tonumber comment: Converts the input string to a number in the specified base. parameters: - name: s - tooltip: The string to convert to a number. + comment: The string to convert to a number. type: string - name: base - tooltip: Optional base for the conversion. + comment: Optional base for the conversion. type: number? returnType: number? - name: tostring comment: Converts the input object to a string. parameters: - name: obj - tooltip: The object to convert to a string. + comment: The object to convert to a string. type: any returnType: string - name: type comment: Returns the type of the object as a string. parameters: - name: obj - tooltip: The object to get the type of. + comment: The object to get the type of. type: any returnType: string - name: typeof comment: Returns the type of the object, including custom userdata types. parameters: - name: obj - tooltip: The object to get the type of. + comment: The object to get the type of. type: any returnType: string - name: ipairs comment: Returns an iterator for numeric key-value pairs in the table. + typeParameters: [V] parameters: - name: t - tooltip: The table to iterate over. - type: table - returnType: iterator + comment: The table to iterate over. + type: "{V}" + returnType: "(({V}, number) -> (number?, V), {V}, number)" - name: pairs comment: Returns an iterator for all key-value pairs in the table. + typeParameters: [K, V] parameters: - name: t - tooltip: The table to iterate over. - type: table - returnType: iterator + comment: The table to iterate over. + type: "{[K]: V}" + returnType: "(({[K], V}, K) -> (K?, V), {[K], V}, K)" - name: pcall comment: Calls function f with parameters args, returning success and function results or an error. + typeParameters: [A..., R...] parameters: - name: f - tooltip: A function to be called. - type: function - - name: args - tooltip: Arguments to pass to the function. - type: variadic - returnType: boolean, variadic + comment: A function to be called. + type: (A...) -> R... + - name: ... + comment: Arguments to pass to the function. + type: A... + returnType: (boolean, R...) - name: xpcall comment: Calls function f with parameters args, handling errors with e if they occur. + typeParameters: [E, A..., R1..., R2...] parameters: - name: f - tooltip: A function to be called. - type: function + comment: A function to be called. + type: (A...) -> R... - name: e - tooltip: Error handler function. - type: function - - name: args - tooltip: Arguments to pass to the function. - type: variadic - returnType: boolean, variadic + comment: Error handler function. + type: (E) -> R2... + - name: ... + comment: Arguments to pass to the function. + type: A... + returnType: (boolean, R1...) +- name: require + comment: Execute the named external module. + parameters: + - name: target + comment: The name of the external module. + type: string + returnType: any - name: unpack comment: Returns values from an array in the specified index range. + typeParameters: [V] parameters: - name: a - tooltip: Array from which to extract values. - type: array + comment: Array from which to extract values. + type: {V} - name: f - tooltip: Starting index (optional, defaults to 1). - type: number + comment: Starting index (optional, defaults to 1). + type: number? - name: t - tooltip: "Ending index (optional, defaults to #a)." - type: number - returnType: variadic + comment: "Ending index (optional, defaults to #a)." + type: number? + returnType: ...V From f91734acbaad62ca9f74cd53f471617fb2e02dbe Mon Sep 17 00:00:00 2001 From: tapple Date: Sun, 18 Jan 2026 22:34:39 -0800 Subject: [PATCH 030/102] fix validation errors --- gen_definitions.py | 56 +++++++++++++++++++++++++------------------ slua_definitions.yaml | 12 ++++++---- 2 files changed, 41 insertions(+), 27 deletions(-) diff --git a/gen_definitions.py b/gen_definitions.py index c63e998..4e18366 100644 --- a/gen_definitions.py +++ b/gen_definitions.py @@ -129,7 +129,7 @@ class LSLTypeMeta(NamedTuple): library_abbr="q", cs_name="Quaternion", mono_bind_name="MonoQuaternionType", - slua_name="rotation", + slua_name="quaternion", ), LSLType.LIST: LSLTypeMeta( cil_name="class [mscorlib]System.Collections.ArrayList", @@ -179,7 +179,7 @@ def to_slua_dict(self, slua: "SLuaDefinitionParser") -> dict: "value": _escape_python(self.value), } ) - except ValueError as e: + except Exception as e: raise ValueError(f"In constant {self.name}: {e}") from e @@ -242,7 +242,7 @@ def to_slua_dict(self, slua: "SLuaDefinitionParser") -> dict: "tooltip": self.tooltip, } ) - except ValueError as e: + except Exception as e: raise ValueError(f"In event {self.name}: {e}") from e @@ -339,6 +339,7 @@ def compute_slua_type(self) -> str: def to_slua_dict(self, slua: "SLuaDefinitionParser") -> dict: try: + known_types = slua.validate_type_params(self.type_arguments) return _remove_worthless( { "type-arguments": self.type_arguments, @@ -346,7 +347,7 @@ def to_slua_dict(self, slua: "SLuaDefinitionParser") -> dict: { a.name: { "tooltip": a.tooltip, - "type": slua.validate_type(a.compute_slua_type()), + "type": slua.validate_type(a.compute_slua_type(), known_types), } } for a in self.arguments @@ -354,12 +355,12 @@ def to_slua_dict(self, slua: "SLuaDefinitionParser") -> dict: "deprecated": self.deprecated, "energy": self.energy, "god-mode": self.god_mode, - "return": slua.validate_return_type(self.compute_slua_type()), + "return": slua.validate_return_type(self.compute_slua_type(), known_types), "sleep": self.sleep, "tooltip": self.tooltip, } ) - except ValueError as e: + except Exception as e: raise ValueError(f"In function {self.name}: {e}") from e @@ -806,10 +807,10 @@ def _validate_function(self, data: any, scope: Set[str], method: bool = False) - comment=data.get("comment"), ) try: - type_params = set(func.typeParameters) + known_types = self.validate_type_params(func.typeParameters) self._validate_identifier(func.name) self._validate_scope(func.name, scope) - self.validate_return_type(func.returnType, type_params) + self.validate_return_type(func.returnType, known_types) params = func.parameters params_scope = set() if method: @@ -818,13 +819,13 @@ def _validate_function(self, data: any, scope: Set[str], method: bool = False) - params_scope.add("self") params = params[1:] if params and params[-1].name == "...": - self.validate_type(params[-1].type, type_params) + self.validate_type(params[-1].type, known_types) params = params[:-1] for param in params: self._validate_identifier(param.name) self._validate_scope(param.name, params_scope) - self.validate_type(param.type, type_params) - except ValueError as e: + self.validate_type(param.type, known_types) + except Exception as e: raise ValueError(f"In function {func.name}: {e}") from e return func @@ -838,25 +839,34 @@ def _validate_property(self, data: any, scope: Set[str], const: bool = False) -> return prop # only nil is allowed to be nil self.validate_type(prop.type) return prop + + def validate_type_params(self, type_params: List[str]) -> set[str]: + known_types = set(self.type_names) + for type_param in type_params: + type_param = type_param.replace("...", "", 1) + self._validate_identifier(type_param) + self._validate_scope(type_param, known_types) + return known_types - _TYPE_OPERATORS_RE = re.compile(r"[ ?&|{}:\[\]]|\.\.\.") + _TYPE_SEPERATORS_RE = re.compile(r"[ ?&|:,{}\[\]()]|\.\.\.|->") - def validate_type(self, type: str, type_params: set[str] | None = None) -> str: + def validate_type(self, type: str, known_type_names: set[str] | None = None) -> str: if not type: raise ValueError("Type may not be empty") - known_type_names = self.type_names | (type_params or set()) + if known_type_names is None: + known_type_names = self.type_names if type in known_type_names: return type - subtypes = self._TYPE_OPERATORS_RE.split(type) - unknown_subtypes = set(subtypes) - (known_type_names | {''}) + subtypes = self._TYPE_SEPERATORS_RE.split(type) + unknown_subtypes = set(subtypes) - known_type_names - {''} if not unknown_subtypes: - return - raise ValueError(f"Unknown types: {unknown_subtypes}") + return type + raise ValueError(f"Unknown types {unknown_subtypes} in definition {type!r}") - def validate_return_type(self, type: str, type_params: set[str] | None = None) -> str: + def validate_return_type(self, type: str, known_types: set[str] | None = None) -> str: if type == "void": return type - return self.validate_type(type, type_params) + return self.validate_type(type, known_types) def _validate_scope(self, name: str, scope: Set[str]) -> None: if name in scope: @@ -946,7 +956,7 @@ def dump_slua_syntax(definitions: LSLDefinitions, slua_definitions_file: str, pr "llsd-lsl-syntax-version": 2, } for event in sorted(definitions.events.values(), key=lambda x: x.name): - syntax["events"][event.name] = event.to_slua_dict(slua_definitions) + syntax["events"][event.name] = event.to_slua_dict(parser) #for func in sorted(slua_definitions.globalFunctions, key=lambda x: x.name): for func in slua_definitions.builtinFunctions: @@ -959,13 +969,13 @@ def dump_slua_syntax(definitions: LSLDefinitions, slua_definitions_file: str, pr syntax["functions"][func.compute_slua_name()] = func.to_slua_dict(slua_definitions) for const in slua_definitions.builtinConstants.values(): - syntax["constants"][const.name] = const.to_slua_dict(slua_definitions) + syntax["constants"][const.name] = const.to_slua_dict(parser) for const in sorted(definitions.constants.values(), key=lambda x: x.name): if const.private: continue if const.slua_removed: continue - syntax["constants"][const.name] = const.to_slua_dict(slua_definitions) + syntax["constants"][const.name] = const.to_slua_dict(parser) if pretty: return llsd.format_pretty_xml(syntax, indent=3, c_compat=True, sort_maps=False) diff --git a/slua_definitions.yaml b/slua_definitions.yaml index a5773f9..99258c3 100644 --- a/slua_definitions.yaml +++ b/slua_definitions.yaml @@ -1936,12 +1936,16 @@ builtinTypes: tooltip: The unspecified type. Disables type-checking. Use unknown instead to use type-checking. boolean: tooltip: "Boolean: represents a true or false value." + buffer: + tooltip: Read-write binary data. never: tooltip: The empty type that contains no values. number: tooltip: Double‑precision floating point number. + quaternion: + tooltip: A set of four float values. Used to represent rotations and orientations. string: - tooltip: Text data (UTF‑8). + tooltip: Read-only binary data. Usually UTF-8-encoded text. table: tooltip: Collection of key‑value pairs. thread: @@ -1949,7 +1953,7 @@ builtinTypes: userdata: tooltip: Opaque external data. vector: - tooltip: A vector is a data type that contains a set of three float values.\nVectors are used to represent colors (RGB), positions, and directions/velocities. + tooltip: A set of three float values. Used to represent colors (RGB), positions, directions, and velocities. unknown: tooltip: The union of every type. Similar to any without disabling type-checking. uuid: @@ -2151,7 +2155,7 @@ builtinFunctions: parameters: - name: f comment: A function to be called. - type: (A...) -> R... + type: (A...) -> R1... - name: e comment: Error handler function. type: (E) -> R2... @@ -2172,7 +2176,7 @@ builtinFunctions: parameters: - name: a comment: Array from which to extract values. - type: {V} + type: "{V}" - name: f comment: Starting index (optional, defaults to 1). type: number? From 7154828c43d2ccb3ebbd56ddf40fbc5817ab2569 Mon Sep 17 00:00:00 2001 From: tapple Date: Mon, 19 Jan 2026 08:50:03 -0800 Subject: [PATCH 031/102] llSetParcelForSale has more return values than true/false --- lsl_definitions.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/lsl_definitions.yaml b/lsl_definitions.yaml index a703ee3..4269877 100644 --- a/lsl_definitions.yaml +++ b/lsl_definitions.yaml @@ -11123,7 +11123,6 @@ functions: energy: 10.0 func-id: 561 return: integer - bool-semantics: true sleep: 0.0 tooltip: Sets the parcel the object is on for sale.\nForSale is a boolean, if TRUE the parcel is put up for sale. Options is a list of options to set for From 51beabf2c4bb9b737b1d982792a2cccf8b7d825d Mon Sep 17 00:00:00 2001 From: tapple Date: Mon, 19 Jan 2026 12:15:54 -0800 Subject: [PATCH 032/102] add type alias generation --- gen_definitions.py | 51 ++++++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/gen_definitions.py b/gen_definitions.py index 4bc1914..0757ef6 100644 --- a/gen_definitions.py +++ b/gen_definitions.py @@ -470,8 +470,7 @@ class SLuaModuleDeclaration: name: str properties: List[SLuaProperty] functions: List[SLuaFunctionSignature] - comment: str - + comment: str = "" @dataclasses.dataclass @@ -479,32 +478,21 @@ class SLuaTypeAlias: """Type alias definition""" name: str definition: str - comment: Optional[str] = None - + comment: str = "" -@dataclasses.dataclass -class SLuaClassProperty: - """Class property definition""" - name: str - type: str - comment: Optional[str] = None + def to_keywords_dict(self) -> dict: + return { + "tooltip": self.comment + "\n" + self.definition, + } @dataclasses.dataclass class SLuaClassDeclaration: """Class declaration with properties and methods""" name: str - properties: Optional[List[SLuaClassProperty]] = None + properties: Optional[List[SLuaProperty]] = None methods: Optional[List[SLuaFunctionSignature]] = None - comment: Optional[str] = None - - -@dataclasses.dataclass -class SLuaGlobalVariable: - """Global variable declaration""" - name: str - type: str - comment: Optional[str] = None + comment: str = "" class SLuaDefinitions(NamedTuple): @@ -523,7 +511,7 @@ class SLuaDefinitions(NamedTuple): # 3. SLua standard library. Depends on base classes classes: List[SLuaClassDeclaration] globalFunctions: List[SLuaFunctionSignature] - globalVariables: List[SLuaGlobalVariable] + globalVariables: List[SLuaProperty] def _escape_python(val: str) -> str: @@ -763,6 +751,10 @@ def _parse_dict(self, def_dict: dict) -> SLuaDefinitions: for func in def_dict["builtinFunctions"] ) # 2. SLua base classes. These only depend on Luau builtins + self.definitions.typeAliases.extend( + self._validate_type_alias(alias) + for alias in def_dict["typeAliases"] + ) # 3. SLua standard library. Depends on base classes self.definitions.globalFunctions.extend( @@ -830,7 +822,16 @@ def _validate_function(self, data: any, scope: Set[str], method: bool = False) - raise ValueError(f"In function {func.name}: {e}") from e return func - def _validate_property(self, data: any, scope: Set[str], const: bool = False) -> LSLConstant: + def _validate_type_alias(self, data: any) -> SLuaTypeAlias: + alias = SLuaTypeAlias(**data) + self._validate_identifier(alias.name) + self.validate_type(alias.definition) + # add it to scope only after validating type, to ensure it isn't recursive + self._validate_scope(alias.name, self.type_names) + self._validate_scope(alias.name, self.global_scope) + return alias + + def _validate_property(self, data: any, scope: Set[str], const: bool = False) -> SLuaProperty: prop = SLuaProperty(**data) self._validate_identifier(prop.name) self._validate_scope(prop.name, scope) @@ -840,7 +841,7 @@ def _validate_property(self, data: any, scope: Set[str], const: bool = False) -> return prop # only nil is allowed to be nil self.validate_type(prop.type) return prop - + def validate_type_params(self, type_params: List[str]) -> set[str]: known_types = set(self.type_names) for type_param in type_params: @@ -865,7 +866,7 @@ def validate_type(self, type: str, known_type_names: set[str] | None = None) -> raise ValueError(f"Unknown types {unknown_subtypes} in definition {type!r}") def validate_return_type(self, type: str, known_types: set[str] | None = None) -> str: - if type == "void": + if type == LSLType.VOID.meta.slua_name: return type return self.validate_type(type, known_types) @@ -956,6 +957,8 @@ def dump_slua_syntax(definitions: LSLDefinitions, slua_definitions_file: str, pr "functions": {}, "llsd-lsl-syntax-version": 2, } + for alias in sorted(slua_definitions.typeAliases): + syntax["types"][alias.name] = alias.to_keywords_dict() for event in sorted(definitions.events.values(), key=lambda x: x.name): syntax["events"][event.name] = event.to_slua_dict(parser) From cd7555c1a10fd06fd09d2213b5592c3e1a7cdfa1 Mon Sep 17 00:00:00 2001 From: tapple Date: Mon, 19 Jan 2026 14:50:37 -0800 Subject: [PATCH 033/102] converted structured types to strings --- slua_definitions.yaml | 117 ++++++++++-------------------------------- 1 file changed, 26 insertions(+), 91 deletions(-) diff --git a/slua_definitions.yaml b/slua_definitions.yaml index 99258c3..7105f3d 100644 --- a/slua_definitions.yaml +++ b/slua_definitions.yaml @@ -131,112 +131,47 @@ baseClasses: typeAliases: - name: rotation comment: '''rotation'' is an alias for ''quaternion''' - definition: - name: quaternion - kind: reference + definition: quaternion - name: numeric - definition: - kind: union - types: - - boolean - - number + definition: boolean | number - name: list - definition: - elementType: - kind: union - types: - - string - - number - - vector - - uuid - - quaternion - - boolean - kind: array + definition: "{string | number | vector | uuid | quaternion | boolean}" - name: LLDetectedEventName - definition: - kind: literal-union - values: [] + # auto-generated from lsl_definitions.yaml + definition: "{}" - name: LLNonDetectedEventName - definition: - kind: literal-union - values: [] + # auto-generated from lsl_definitions.yaml + definition: "{}" - name: LLEventName - definition: - kind: union - types: - - LLDetectedEventName - - LLNonDetectedEventName + definition: LLDetectedEventName | LLNonDetectedEventName - name: LLEventHandler - definition: - kind: function - parameters: - - type: any - variadic: true - returnType: () + # auto-generated from lsl_definitions.yaml + definition: (...any) -> () - name: LLDetectedEventHandler - definition: - kind: function - parameters: - - name: detected - type: - elementType: LLDetectedEvent - kind: array - returnType: () + definition: "(detected: {LLDetectedEvent}) -> ()" - name: LLTimerEveryCallback comment: Callback type for LLTimers.every() - receives scheduled time and interval - definition: - kind: function - parameters: - - name: scheduled - type: number - - name: interval - type: number - returnType: () + definition: "(scheduled: number, interval: number) -> ()" - name: LLTimerOnceCallback comment: Callback type for LLTimers.once() - receives scheduled time - definition: - kind: function - parameters: - - name: scheduled - type: number - returnType: () + definition: "(scheduled: number) -> ()" - name: LLTimerCallback comment: Union of timer callback types - definition: - kind: union - types: - - LLTimerEveryCallback - - LLTimerOnceCallback - - (...any) -> ...any + definition: LLTimerEveryCallback | LLTimerOnceCallback - name: OsDateTime comment: Date/time table structure used by os.date and os.time - definition: - kind: table - properties: - - name: year - type: number - - name: month - type: number - - name: day - type: number - - name: hour - type: number - optional: true - - name: min - type: number - optional: true - - name: sec - type: number - optional: true - - name: wday - type: number - optional: true - - name: yday - type: number - optional: true - - name: isdst - type: boolean - optional: true + definition: |- + { + year: number, + month: number, + day: number, + hour: number?, + min: number?, + sec: number?, + wday: number?, + yday: number?, + isdst: boolean?, + } classes: - name: LLDetectedEvent comment: Event detection class providing access to detected object/avatar information From cc77ea802bca3d74ea11dd2116c6f588b2fcc160 Mon Sep 17 00:00:00 2001 From: tapple Date: Mon, 19 Jan 2026 14:51:01 -0800 Subject: [PATCH 034/102] fix validation issues --- gen_definitions.py | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/gen_definitions.py b/gen_definitions.py index 0757ef6..411ead2 100644 --- a/gen_definitions.py +++ b/gen_definitions.py @@ -450,7 +450,7 @@ def to_keywords_dict(self) -> dict: "arguments": [ { a.name: { - "tooltip": a.tooltip, + "tooltip": a.comment, "type": a.type, } } @@ -481,9 +481,15 @@ class SLuaTypeAlias: comment: str = "" def to_keywords_dict(self) -> dict: + definition = self.to_luau_def() + if len(definition) > 200: + definition = "" return { - "tooltip": self.comment + "\n" + self.definition, + "tooltip": f"{self.comment}\n{definition}".strip(), } + + def to_luau_def(self) -> str: + return f"type {self.name} = {self.definition}" @dataclasses.dataclass @@ -824,11 +830,13 @@ def _validate_function(self, data: any, scope: Set[str], method: bool = False) - def _validate_type_alias(self, data: any) -> SLuaTypeAlias: alias = SLuaTypeAlias(**data) - self._validate_identifier(alias.name) - self.validate_type(alias.definition) - # add it to scope only after validating type, to ensure it isn't recursive - self._validate_scope(alias.name, self.type_names) - self._validate_scope(alias.name, self.global_scope) + try: + self._validate_identifier(alias.name) + self.validate_type(alias.definition) + # add it to scope only after validating type, to ensure it isn't recursive + self._validate_scope(alias.name, self.type_names) + except Exception as e: + raise ValueError(f"In type alias {alias.name}: {e}") from e return alias def _validate_property(self, data: any, scope: Set[str], const: bool = False) -> SLuaProperty: @@ -850,7 +858,7 @@ def validate_type_params(self, type_params: List[str]) -> set[str]: self._validate_scope(type_param, known_types) return known_types - _TYPE_SEPERATORS_RE = re.compile(r"[ ?&|:,{}\[\]()]|\.\.\.|->") + _TYPE_SEPERATORS_RE = re.compile(r"[ \n?&|,{}\[\]()]|\.\.\.|->|[a-zA-Z0-9_]*:") def validate_type(self, type: str, known_type_names: set[str] | None = None) -> str: if not type: @@ -957,7 +965,7 @@ def dump_slua_syntax(definitions: LSLDefinitions, slua_definitions_file: str, pr "functions": {}, "llsd-lsl-syntax-version": 2, } - for alias in sorted(slua_definitions.typeAliases): + for alias in sorted(slua_definitions.typeAliases, key=lambda x: x.name): syntax["types"][alias.name] = alias.to_keywords_dict() for event in sorted(definitions.events.values(), key=lambda x: x.name): syntax["events"][event.name] = event.to_slua_dict(parser) @@ -970,10 +978,10 @@ def dump_slua_syntax(definitions: LSLDefinitions, slua_definitions_file: str, pr for func in sorted(definitions.functions.values(), key=lambda x: x.name): if func.private: continue - syntax["functions"][func.compute_slua_name()] = func.to_slua_dict(slua_definitions) + syntax["functions"][func.compute_slua_name()] = func.to_slua_dict(parser) - for const in slua_definitions.builtinConstants.values(): - syntax["constants"][const.name] = const.to_slua_dict(parser) + for const in slua_definitions.builtinConstants: + syntax["constants"][const.name] = const.to_keywords_dict() for const in sorted(definitions.constants.values(), key=lambda x: x.name): if const.private: continue From 28fa1fff3548f067c9e0a0c4dc19de987af8ae36 Mon Sep 17 00:00:00 2001 From: tapple Date: Mon, 19 Jan 2026 17:15:26 -0800 Subject: [PATCH 035/102] fix hidden keyword fields --- gen_definitions.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gen_definitions.py b/gen_definitions.py index 411ead2..f3e8363 100644 --- a/gen_definitions.py +++ b/gen_definitions.py @@ -903,14 +903,14 @@ def _remove_worthless(val: dict) -> dict: val.pop("pure", None) if not val.get("native"): val.pop("native", None) + if not val.get("bool_semantics"): + val.pop("bool_semantics", None) if not val.get("bool-semantics"): val.pop("bool-semantics", None) if not val.get("index-semantics"): val.pop("index-semantics", None) if not val.get("type-arguments"): val.pop("type-arguments", None) - if not val.get("tooltip"): - val.pop("tooltip", None) return val From 2e7a4ff0cb3852a62e9d4d5506c2414e4688dd8e Mon Sep 17 00:00:00 2001 From: tapple Date: Mon, 19 Jan 2026 17:37:51 -0800 Subject: [PATCH 036/102] generate classes --- gen_definitions.py | 62 ++++++++++++++++++++++++---------------------- 1 file changed, 33 insertions(+), 29 deletions(-) diff --git a/gen_definitions.py b/gen_definitions.py index f3e8363..b6a7ab0 100644 --- a/gen_definitions.py +++ b/gen_definitions.py @@ -496,8 +496,8 @@ def to_luau_def(self) -> str: class SLuaClassDeclaration: """Class declaration with properties and methods""" name: str - properties: Optional[List[SLuaProperty]] = None - methods: Optional[List[SLuaFunctionSignature]] = None + properties: List[SLuaProperty] + methods: List[SLuaFunctionSignature] comment: str = "" @@ -757,45 +757,49 @@ def _parse_dict(self, def_dict: dict) -> SLuaDefinitions: for func in def_dict["builtinFunctions"] ) # 2. SLua base classes. These only depend on Luau builtins + self.definitions.baseClasses.extend( + self._validate_class(class_, self.global_scope) + for class_ in def_dict["baseClasses"] + ) self.definitions.typeAliases.extend( self._validate_type_alias(alias) for alias in def_dict["typeAliases"] ) # 3. SLua standard library. Depends on base classes + self.definitions.classes.extend( + self._validate_class(class_, self.global_scope) + for class_ in def_dict["classes"] + ) self.definitions.globalFunctions.extend( self._validate_function(func, self.global_scope) for func in def_dict["globalFunctions"] ) -# for event_name, event_data in def_dict["events"].items(): -# self._handle_event(event_name, event_data) -# for func_name, func_data in def_dict["functions"].items(): -# func = self._handle_function(func_name, func_data) -# if func.func_id in seen_func_ids: -# raise ValueError(f"Func ID {func.func_id} was re-used by {func!r}") -# seen_func_ids.add(func.func_id) return self.definitions - def _handle_event(self, event_name: str, event_data: dict) -> LSLEvent: - self._validate_identifier(event_name) - event = LSLEvent( - name=event_name, - tooltip=event_data.get("tooltip", ""), - arguments=[ - self._handle_argument(event_name, arg) - for arg in (event_data.get("arguments") or []) - ], - private=event_data.get("private", False), - deprecated=event_data.get("deprecated", False), + def _validate_class(self, data: any) -> SLuaClassDeclaration: + class_ = SLuaClassDeclaration( + name=data["name"], + comment=data.get("comment", ""), + properties=[], + methods=[], ) - - if event.name in self._definitions.events: - raise KeyError(f"{event.name} is already defined") - self._validate_args(event) - - self._definitions.events[event.name] = event - return event + try: + self._validate_identifier(class_.name) + self._validate_scope(class_.name, self.type_names) + class_scope: Set[str] = set() + class_.properties = [ + self._validate_property(prop, class_scope) + for prop in data.get("properties", []) + ] + class_.methods = [ + self._validate_function(method, class_scope, method=True) + for method in data.get("methods", []) + ] + except Exception as e: + raise ValueError(f"In class {class_.name}: {e}") from e + return class_ def _validate_function(self, data: any, scope: Set[str], method: bool = False) -> SLuaFunctionSignature: func = SLuaFunctionSignature( @@ -803,12 +807,12 @@ def _validate_function(self, data: any, scope: Set[str], method: bool = False) - typeParameters=data.get("typeParameters", []), parameters=[SLuaParameter(**p) for p in data.get("parameters", [])], returnType=data.get("returnType", "void"), - comment=data.get("comment"), + comment=data.get("comment", ""), ) try: - known_types = self.validate_type_params(func.typeParameters) self._validate_identifier(func.name) self._validate_scope(func.name, scope) + known_types = self.validate_type_params(func.typeParameters) self.validate_return_type(func.returnType, known_types) params = func.parameters params_scope = set() From 696b61aabf3e31ea8ce23bd8edcefeab7a001312 Mon Sep 17 00:00:00 2001 From: tapple Date: Mon, 19 Jan 2026 17:42:24 -0800 Subject: [PATCH 037/102] generate classes --- gen_definitions.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/gen_definitions.py b/gen_definitions.py index b6a7ab0..b1b77ee 100644 --- a/gen_definitions.py +++ b/gen_definitions.py @@ -500,6 +500,9 @@ class SLuaClassDeclaration: methods: List[SLuaFunctionSignature] comment: str = "" + def to_keywords_dict(self) -> dict: + return { "tooltip": self.comment } + class SLuaDefinitions(NamedTuple): # for best results, load/generate in the same order defined here @@ -969,8 +972,14 @@ def dump_slua_syntax(definitions: LSLDefinitions, slua_definitions_file: str, pr "functions": {}, "llsd-lsl-syntax-version": 2, } + + for class_ in sorted(slua_definitions.baseClasses, key=lambda x: x.name): + syntax["types"][class_.name] = class_.to_keywords_dict() for alias in sorted(slua_definitions.typeAliases, key=lambda x: x.name): syntax["types"][alias.name] = alias.to_keywords_dict() + for class_ in sorted(slua_definitions.classes, key=lambda x: x.name): + syntax["types"][class_.name] = class_.to_keywords_dict() + for event in sorted(definitions.events.values(), key=lambda x: x.name): syntax["events"][event.name] = event.to_slua_dict(parser) From e6152029df1606330e47f210ec2320d7737c3750 Mon Sep 17 00:00:00 2001 From: tapple Date: Mon, 19 Jan 2026 18:06:12 -0800 Subject: [PATCH 038/102] classes are now generated --- gen_definitions.py | 4 ++-- slua_definitions.yaml | 32 +++++++++++++------------------- 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/gen_definitions.py b/gen_definitions.py index b1b77ee..e23dd57 100644 --- a/gen_definitions.py +++ b/gen_definitions.py @@ -761,7 +761,7 @@ def _parse_dict(self, def_dict: dict) -> SLuaDefinitions: ) # 2. SLua base classes. These only depend on Luau builtins self.definitions.baseClasses.extend( - self._validate_class(class_, self.global_scope) + self._validate_class(class_) for class_ in def_dict["baseClasses"] ) self.definitions.typeAliases.extend( @@ -771,7 +771,7 @@ def _parse_dict(self, def_dict: dict) -> SLuaDefinitions: # 3. SLua standard library. Depends on base classes self.definitions.classes.extend( - self._validate_class(class_, self.global_scope) + self._validate_class(class_) for class_ in def_dict["classes"] ) self.definitions.globalFunctions.extend( diff --git a/slua_definitions.yaml b/slua_definitions.yaml index 7105f3d..370a94f 100644 --- a/slua_definitions.yaml +++ b/slua_definitions.yaml @@ -7,7 +7,7 @@ version: 1.0.0 # baseClasses must not depend on anything else in this file (not typeAliases, not classes) baseClasses: - name: quaternion - comment: 'Luau Type Definition for LSL UserData Type: quaternion' + comment: A set of four float values. Used to represent rotations and orientations. methods: - name: __add parameters: @@ -57,7 +57,7 @@ baseClasses: - name: s type: number - name: uuid - comment: 'Luau Type Definition for LSL UserData Type: uuid' + comment: A 128‑bit unique identifier formatted as 36 hexadecimal characters (8‑4‑4‑4‑12), e.g. "A822FF2B-FF02-461D-B45D-DCD10A2DE0C2". methods: - name: __tostring parameters: @@ -72,7 +72,7 @@ baseClasses: is not in a compressed state type: string? - name: vector - comment: 'Luau Type Definition for LSL UserData Type: vector' + comment: A set of three float values. Used to represent colors (RGB), positions, directions, and velocities. methods: - name: __add comment: Native component-wise addition @@ -128,6 +128,16 @@ baseClasses: type: number - name: z type: number +- name: LLDetectedEvent + comment: Event detection class providing access to detected object/avatar information + methods: [] + properties: + - name: index + type: number + - name: valid + type: boolean + - name: canAdjustDamage + type: boolean typeAliases: - name: rotation comment: '''rotation'' is an alias for ''quaternion''' @@ -173,16 +183,6 @@ typeAliases: isdst: boolean?, } classes: -- name: LLDetectedEvent - comment: Event detection class providing access to detected object/avatar information - methods: [] - properties: - - name: index - type: number - - name: valid - type: boolean - - name: canAdjustDamage - type: boolean - name: LLEvents comment: Event registration and management class for Second Life events methods: @@ -1877,8 +1877,6 @@ builtinTypes: tooltip: The empty type that contains no values. number: tooltip: Double‑precision floating point number. - quaternion: - tooltip: A set of four float values. Used to represent rotations and orientations. string: tooltip: Read-only binary data. Usually UTF-8-encoded text. table: @@ -1887,12 +1885,8 @@ builtinTypes: tooltip: Represents a coroutine. userdata: tooltip: Opaque external data. - vector: - tooltip: A set of three float values. Used to represent colors (RGB), positions, directions, and velocities. unknown: tooltip: The union of every type. Similar to any without disabling type-checking. - uuid: - tooltip: A 128‑bit unique identifier formatted as 36 hexadecimal characters (8‑4‑4‑4‑12), e.g. "A822FF2B-FF02-461D-B45D-DCD10A2DE0C2". builtinConstants: - name: nil comment: "Lua nil: represents the absence of a useful value." From 85f0c4f24f419f4470ecdfd53ec70af9a3378aa5 Mon Sep 17 00:00:00 2001 From: tapple Date: Tue, 20 Jan 2026 06:56:20 -0800 Subject: [PATCH 039/102] moved quaternion, uuid, vector from globalVariables to modules --- slua_definitions.yaml | 608 +++++++++++++++++++++--------------------- 1 file changed, 304 insertions(+), 304 deletions(-) diff --git a/slua_definitions.yaml b/slua_definitions.yaml index 370a94f..f94df8c 100644 --- a/slua_definitions.yaml +++ b/slua_definitions.yaml @@ -255,315 +255,11 @@ classes: type: LLTimerCallback returnType: boolean globalVariables: -- name: quaternion - comment: Global 'quaternion' library table with callable metatable - type: - callSignature: - parameters: - - name: x - type: number - - name: y - type: number - - name: z - type: number - - name: s - type: number - returnType: quaternion - kind: callable-table - tableType: - properties: - - name: create - comment: Constructor - type: - kind: function - parameters: - - name: x - type: number - - name: y - type: number - - name: z - type: number - - name: s - type: number - returnType: quaternion - - name: identity - comment: Identity quaternion constant - type: quaternion - - name: normalize - comment: Returns normalized quaternion - type: - kind: function - parameters: - - name: q - type: quaternion - returnType: quaternion - - name: magnitude - comment: Returns magnitude of quaternion - type: - kind: function - parameters: - - name: q - type: quaternion - returnType: number - - name: dot - comment: Dot product of two quaternions - type: - kind: function - parameters: - - name: a - type: quaternion - - name: b - type: quaternion - returnType: number - - name: slerp - comment: Spherical linear interpolation - type: - kind: function - parameters: - - name: a - type: quaternion - - name: b - type: quaternion - - name: t - type: number - returnType: quaternion - - name: conjugate - comment: Returns conjugate of quaternion - type: - kind: function - parameters: - - name: q - type: quaternion - returnType: quaternion - - name: tofwd - comment: Returns forward vector from quaternion rotation - type: - kind: function - parameters: - - name: q - type: quaternion - returnType: vector - - name: toleft - comment: Returns left vector from quaternion rotation - type: - kind: function - parameters: - - name: q - type: quaternion - returnType: vector - - name: toup - comment: Returns up vector from quaternion rotation - type: - kind: function - parameters: - - name: q - type: quaternion - returnType: vector - name: rotation comment: '''rotation'' global is an alias to the ''quaternion'' library' type: kind: typeof target: quaternion -- name: uuid - comment: Global 'uuid' library table - type: - kind: table - properties: - - name: create - comment: Creates a new uuid from a string, buffer, or existing uuid. Returns - nil if the string is not a valid UUID. Throws an error if the buffer is - shorter than 16 bytes. - type: - kind: function - parameters: - - name: value - type: - kind: union - types: - - string - - buffer - - uuid - returnType: uuid? - - name: __call - comment: Allows calling uuid() as a constructor - type: - kind: function - parameters: - - name: self - type: any - - name: value - type: - kind: union - types: - - string - - buffer - - uuid - returnType: uuid? -- name: vector - comment: Global 'vector' library table - type: - kind: table - properties: - - name: create - comment: Creates a new vector with the given component values - type: - kind: function - parameters: - - name: x - type: number - - name: y - type: number - - name: z - type: number - optional: true - returnType: vector - - name: magnitude - comment: Calculates the magnitude of a given vector - type: - kind: function - parameters: - - name: v - type: vector - returnType: number - - name: normalize - comment: Computes the normalized version (unit vector) of a given vector - type: - kind: function - parameters: - - name: v - type: vector - returnType: vector - - name: cross - comment: Computes the cross product of two vectors - type: - kind: function - parameters: - - name: a - type: vector - - name: b - type: vector - returnType: vector - - name: dot - comment: Computes the dot product of two vectors - type: - kind: function - parameters: - - name: a - type: vector - - name: b - type: vector - returnType: number - - name: angle - comment: Computes the angle between two vectors in radians. The axis, if specified, - is used to determine the sign of the angle. - type: - kind: function - parameters: - - name: a - type: vector - - name: b - type: vector - - name: axis - type: vector - optional: true - returnType: number - - name: floor - comment: Applies math.floor to every component of the input vector - type: - kind: function - parameters: - - name: v - type: vector - returnType: vector - - name: ceil - comment: Applies math.ceil to every component of the input vector - type: - kind: function - parameters: - - name: v - type: vector - returnType: vector - - name: abs - comment: Applies math.abs to every component of the input vector - type: - kind: function - parameters: - - name: v - type: vector - returnType: vector - - name: sign - comment: Applies math.sign to every component of the input vector - type: - kind: function - parameters: - - name: v - type: vector - returnType: vector - - name: clamp - comment: Applies math.clamp to every component of the input vector - type: - kind: function - parameters: - - name: v - type: vector - - name: min - type: vector - - name: max - type: vector - returnType: vector - - name: max - comment: Applies math.max to the corresponding components of the input vectors - type: - kind: function - parameters: - - name: v - type: vector - - type: vector - variadic: true - returnType: vector - - name: min - comment: Applies math.min to the corresponding components of the input vectors - type: - kind: function - parameters: - - name: v - type: vector - - type: vector - variadic: true - returnType: vector - - name: lerp - comment: Linear interpolation between two vectors - type: - kind: function - parameters: - - name: a - type: vector - - name: b - type: vector - - name: t - type: number - returnType: vector - - name: zero - comment: A zero vector <0,0,0> - type: vector - - name: one - comment: A one vector <1,1,1> - type: vector - - name: __call - comment: 'Constructor call: vector(x, y, z)' - type: - kind: function - parameters: - - name: self - type: any - - name: x - type: number - - name: y - type: number - - name: z - type: number - optional: true - returnType: vector - name: loadstring comment: loadstring is removed in SLua type: nil @@ -1445,6 +1141,110 @@ modules: type: OsDateTime optional: true returnType: number? +- name: quaternion + comment: Global 'quaternion' library table with callable metatable + type: + callSignature: + parameters: + - name: x + type: number + - name: y + type: number + - name: z + type: number + - name: s + type: number + returnType: quaternion + kind: callable-table + tableType: + properties: + - name: create + comment: Constructor + type: + kind: function + parameters: + - name: x + type: number + - name: y + type: number + - name: z + type: number + - name: s + type: number + returnType: quaternion + - name: identity + comment: Identity quaternion constant + type: quaternion + - name: normalize + comment: Returns normalized quaternion + type: + kind: function + parameters: + - name: q + type: quaternion + returnType: quaternion + - name: magnitude + comment: Returns magnitude of quaternion + type: + kind: function + parameters: + - name: q + type: quaternion + returnType: number + - name: dot + comment: Dot product of two quaternions + type: + kind: function + parameters: + - name: a + type: quaternion + - name: b + type: quaternion + returnType: number + - name: slerp + comment: Spherical linear interpolation + type: + kind: function + parameters: + - name: a + type: quaternion + - name: b + type: quaternion + - name: t + type: number + returnType: quaternion + - name: conjugate + comment: Returns conjugate of quaternion + type: + kind: function + parameters: + - name: q + type: quaternion + returnType: quaternion + - name: tofwd + comment: Returns forward vector from quaternion rotation + type: + kind: function + parameters: + - name: q + type: quaternion + returnType: vector + - name: toleft + comment: Returns left vector from quaternion rotation + type: + kind: function + parameters: + - name: q + type: quaternion + returnType: vector + - name: toup + comment: Returns up vector from quaternion rotation + type: + kind: function + parameters: + - name: q + type: quaternion + returnType: vector - name: string comment: String manipulation library functions: @@ -1824,6 +1624,206 @@ modules: - name: charpattern comment: Pattern that matches exactly one UTF-8 byte sequence type: string +- name: uuid + comment: Global 'uuid' library table + type: + kind: table + properties: + - name: create + comment: Creates a new uuid from a string, buffer, or existing uuid. Returns + nil if the string is not a valid UUID. Throws an error if the buffer is + shorter than 16 bytes. + type: + kind: function + parameters: + - name: value + type: + kind: union + types: + - string + - buffer + - uuid + returnType: uuid? + - name: __call + comment: Allows calling uuid() as a constructor + type: + kind: function + parameters: + - name: self + type: any + - name: value + type: + kind: union + types: + - string + - buffer + - uuid + returnType: uuid? +- name: vector + comment: Global 'vector' library table + type: + kind: table + properties: + - name: create + comment: Creates a new vector with the given component values + type: + kind: function + parameters: + - name: x + type: number + - name: y + type: number + - name: z + type: number + optional: true + returnType: vector + - name: magnitude + comment: Calculates the magnitude of a given vector + type: + kind: function + parameters: + - name: v + type: vector + returnType: number + - name: normalize + comment: Computes the normalized version (unit vector) of a given vector + type: + kind: function + parameters: + - name: v + type: vector + returnType: vector + - name: cross + comment: Computes the cross product of two vectors + type: + kind: function + parameters: + - name: a + type: vector + - name: b + type: vector + returnType: vector + - name: dot + comment: Computes the dot product of two vectors + type: + kind: function + parameters: + - name: a + type: vector + - name: b + type: vector + returnType: number + - name: angle + comment: Computes the angle between two vectors in radians. The axis, if specified, + is used to determine the sign of the angle. + type: + kind: function + parameters: + - name: a + type: vector + - name: b + type: vector + - name: axis + type: vector + optional: true + returnType: number + - name: floor + comment: Applies math.floor to every component of the input vector + type: + kind: function + parameters: + - name: v + type: vector + returnType: vector + - name: ceil + comment: Applies math.ceil to every component of the input vector + type: + kind: function + parameters: + - name: v + type: vector + returnType: vector + - name: abs + comment: Applies math.abs to every component of the input vector + type: + kind: function + parameters: + - name: v + type: vector + returnType: vector + - name: sign + comment: Applies math.sign to every component of the input vector + type: + kind: function + parameters: + - name: v + type: vector + returnType: vector + - name: clamp + comment: Applies math.clamp to every component of the input vector + type: + kind: function + parameters: + - name: v + type: vector + - name: min + type: vector + - name: max + type: vector + returnType: vector + - name: max + comment: Applies math.max to the corresponding components of the input vectors + type: + kind: function + parameters: + - name: v + type: vector + - type: vector + variadic: true + returnType: vector + - name: min + comment: Applies math.min to the corresponding components of the input vectors + type: + kind: function + parameters: + - name: v + type: vector + - type: vector + variadic: true + returnType: vector + - name: lerp + comment: Linear interpolation between two vectors + type: + kind: function + parameters: + - name: a + type: vector + - name: b + type: vector + - name: t + type: number + returnType: vector + - name: zero + comment: A zero vector <0,0,0> + type: vector + - name: one + comment: A one vector <1,1,1> + type: vector + - name: __call + comment: 'Constructor call: vector(x, y, z)' + type: + kind: function + parameters: + - name: self + type: any + - name: x + type: number + - name: y + type: number + - name: z + type: number + optional: true + returnType: vector constants: [] # Everything below here is only for keywords.xml generation, not typechecking From ddce53f4acccd6fd88b4e6fd7dd6fa43ee9085e0 Mon Sep 17 00:00:00 2001 From: tapple Date: Tue, 20 Jan 2026 07:32:20 -0800 Subject: [PATCH 040/102] generate modules --- gen_definitions.py | 89 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 74 insertions(+), 15 deletions(-) diff --git a/gen_definitions.py b/gen_definitions.py index e23dd57..e4e77a6 100644 --- a/gen_definitions.py +++ b/gen_definitions.py @@ -464,15 +464,6 @@ def to_keywords_dict(self) -> dict: ) -@dataclasses.dataclass -class SLuaModuleDeclaration: - """ Module declaration with properties and functions """ - name: str - properties: List[SLuaProperty] - functions: List[SLuaFunctionSignature] - comment: str = "" - - @dataclasses.dataclass class SLuaTypeAlias: """Type alias definition""" @@ -504,6 +495,32 @@ def to_keywords_dict(self) -> dict: return { "tooltip": self.comment } +@dataclasses.dataclass +class SLuaModuleDeclaration: + """ Module declaration with properties and functions """ + name: str + callable: Optional[SLuaFunctionSignature] + properties: List[SLuaProperty] + functions: List[SLuaFunctionSignature] + comment: str = "" + + def to_keywords_functions_dict(self) -> dict: + functions = {} + if self.callable: + functions[self.name] = self.callable.to_keywords_dict() + functions.update({ + f"{self.name}.{func.name}": func.to_keywords_dict() + for func in sorted(self.functions, key=lambda x: x.name) + }) + return functions + + def to_keywords_properties_dict(self) -> dict: + return { + f"{self.name}.{prop.name}": prop.to_keywords_dict() + for prop in sorted(self.properties, key=lambda x: x.name) + } + + class SLuaDefinitions(NamedTuple): # for best results, load/generate in the same order defined here @@ -520,6 +537,7 @@ class SLuaDefinitions(NamedTuple): # 3. SLua standard library. Depends on base classes classes: List[SLuaClassDeclaration] globalFunctions: List[SLuaFunctionSignature] + modules: List[SLuaModuleDeclaration] globalVariables: List[SLuaProperty] @@ -721,7 +739,7 @@ def _massage_const_value(val: Any) -> Any: class SLuaDefinitionParser: def __init__(self): - self.definitions = SLuaDefinitions({}, {}, [], [], [], [], [], [], []) + self.definitions = SLuaDefinitions({}, {}, [], [], [], [], [], [], [], []) self.type_names: Set[str] = set() self.global_scope: Set[str] = set() @@ -778,9 +796,43 @@ def _parse_dict(self, def_dict: dict) -> SLuaDefinitions: self._validate_function(func, self.global_scope) for func in def_dict["globalFunctions"] ) + self.definitions.modules.extend( + self._validate_module(module) + for module in def_dict["modules"] + ) return self.definitions + def _validate_module(self, data: any) -> SLuaModuleDeclaration: + module = SLuaModuleDeclaration( + name=data["name"], + comment=data.get("comment", ""), + callable=None, + properties=[], + functions=[], + ) + try: + self._validate_identifier(module.name) + self._validate_scope(module.name, self.type_names) + module_scope: Set[str] = set() + callable = data.get("callable") + if callable is not None: + module.callable = self._validate_function(callable, module_scope) + if module.callable.name != module.name: + raise ValueError("module.callable.name must match module.name") + module_scope.clear() + module.properties = [ + self._validate_property(prop, module_scope, const=True) + for prop in data.get("properties", []) + ] + module.functions = [ + self._validate_function(function, module_scope) + for function in data.get("functions", []) + ] + except Exception as e: + raise ValueError(f"In module {module.name}: {e}") from e + return module + def _validate_class(self, data: any) -> SLuaClassDeclaration: class_ = SLuaClassDeclaration( name=data["name"], @@ -960,7 +1012,7 @@ def dump_syntax(definitions: LSLDefinitions, pretty: bool = False) -> bytes: return llsd.format_xml(syntax, c_compat=True, sort_maps=True) -def dump_slua_syntax(definitions: LSLDefinitions, slua_definitions_file: str, pretty: bool = False) -> bytes: +def dump_slua_syntax(lsl_definitions: LSLDefinitions, slua_definitions_file: str, pretty: bool = False) -> bytes: """Write a syntax file for use by viewers""" parser = SLuaDefinitionParser() slua_definitions = parser.parse_file(slua_definitions_file) @@ -973,6 +1025,7 @@ def dump_slua_syntax(definitions: LSLDefinitions, slua_definitions_file: str, pr "llsd-lsl-syntax-version": 2, } + # types for class_ in sorted(slua_definitions.baseClasses, key=lambda x: x.name): syntax["types"][class_.name] = class_.to_keywords_dict() for alias in sorted(slua_definitions.typeAliases, key=lambda x: x.name): @@ -980,22 +1033,28 @@ def dump_slua_syntax(definitions: LSLDefinitions, slua_definitions_file: str, pr for class_ in sorted(slua_definitions.classes, key=lambda x: x.name): syntax["types"][class_.name] = class_.to_keywords_dict() - for event in sorted(definitions.events.values(), key=lambda x: x.name): + # events + for event in sorted(lsl_definitions.events.values(), key=lambda x: x.name): syntax["events"][event.name] = event.to_slua_dict(parser) - #for func in sorted(slua_definitions.globalFunctions, key=lambda x: x.name): + # functions for func in slua_definitions.builtinFunctions: syntax["functions"][func.name] = func.to_keywords_dict() for func in sorted(slua_definitions.globalFunctions, key=lambda x: x.name): syntax["functions"][func.name] = func.to_keywords_dict() - for func in sorted(definitions.functions.values(), key=lambda x: x.name): + for module in sorted(slua_definitions.modules, key=lambda x: x.name): + syntax["functions"].update(module.to_keywords_functions_dict()) + for func in sorted(lsl_definitions.functions.values(), key=lambda x: x.name): if func.private: continue syntax["functions"][func.compute_slua_name()] = func.to_slua_dict(parser) + # constants for const in slua_definitions.builtinConstants: syntax["constants"][const.name] = const.to_keywords_dict() - for const in sorted(definitions.constants.values(), key=lambda x: x.name): + for module in sorted(slua_definitions.modules, key=lambda x: x.name): + syntax["constants"].update(module.to_keywords_constants_dict()) + for const in sorted(lsl_definitions.constants.values(), key=lambda x: x.name): if const.private: continue if const.slua_removed: From ad5bbe371f53bc1acac527689334fae3cfb03432 Mon Sep 17 00:00:00 2001 From: tapple Date: Tue, 20 Jan 2026 07:37:36 -0800 Subject: [PATCH 041/102] fix variadics --- slua_definitions.yaml | 62 +++++++++++++++++++++---------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/slua_definitions.yaml b/slua_definitions.yaml index f94df8c..1a5ce55 100644 --- a/slua_definitions.yaml +++ b/slua_definitions.yaml @@ -315,8 +315,8 @@ modules: - name: band comment: Bitwise AND of all arguments parameters: - - type: number - variadic: true + - name: ... + type: ...number returnType: number - name: bnot comment: Bitwise NOT @@ -327,20 +327,20 @@ modules: - name: bor comment: Bitwise OR of all arguments parameters: - - type: number - variadic: true + - name: ... + type: ...number returnType: number - name: bxor comment: Bitwise XOR of all arguments parameters: - - type: number - variadic: true + - name: ... + type: ...number returnType: number - name: btest comment: Returns true if bitwise AND of all arguments is not zero parameters: - - type: number - variadic: true + - name: ... + type: ...number returnType: boolean - name: extract comment: Extracts bits from n at position field with width @@ -675,8 +675,8 @@ modules: parameters: - name: co type: thread - - type: any - variadic: true + - name: ... + type: ...any returnType: (boolean, ...any) - name: running comment: Returns the running coroutine, or nil if called from main thread @@ -697,8 +697,8 @@ modules: - name: yield comment: Suspends the coroutine and returns values to resume parameters: - - type: any - variadic: true + - name: ... + type: ...any returnType: '...any' - name: isyieldable comment: Returns true if the coroutine can yield @@ -982,16 +982,16 @@ modules: parameters: - name: x type: number - - type: number - variadic: true + - name: ... + type: ...number returnType: number - name: min comment: Returns the minimum value among the arguments parameters: - name: x type: number - - type: number - variadic: true + - name: ... + type: ...number returnType: number - name: modf comment: Returns the integer and fractional parts of x @@ -1263,8 +1263,8 @@ modules: - name: char comment: Returns a string from character codes parameters: - - type: number - variadic: true + - name: ... + type: ...number returnType: string - name: find comment: Finds first match of pattern in string @@ -1285,8 +1285,8 @@ modules: parameters: - name: formatstring type: string - - type: any - variadic: true + - name: ... + type: ...any returnType: string - name: gmatch comment: Returns an iterator function for pattern matches @@ -1337,8 +1337,8 @@ modules: parameters: - name: fmt type: string - - type: any - variadic: true + - name: ... + type: ...any returnType: string - name: packsize comment: Returns the size of a packed string for the given format @@ -1489,8 +1489,8 @@ modules: comment: Packs arguments into a table with length field n typeParameters: [T] parameters: - - type: T - variadic: true + - name: ... + type...: T returnType: '{ n: number, [number]: T }' - name: unpack comment: Unpacks table elements as multiple return values @@ -1575,8 +1575,8 @@ modules: - name: char comment: Returns a string from UTF-8 codepoints parameters: - - type: number - variadic: true + - name: ... + type: ...number returnType: string - name: codes comment: Returns an iterator for UTF-8 codepoints in a string @@ -1778,8 +1778,8 @@ modules: parameters: - name: v type: vector - - type: vector - variadic: true + - name: ... + type: ...vector returnType: vector - name: min comment: Applies math.min to the corresponding components of the input vectors @@ -1788,8 +1788,8 @@ modules: parameters: - name: v type: vector - - type: vector - variadic: true + - name: ... + type: ...vector returnType: vector - name: lerp comment: Linear interpolation between two vectors @@ -1953,7 +1953,7 @@ builtinFunctions: - name: print comment: Prints all arguments to standard output using Tab as a separator. parameters: - - name: args + - name: ... comment: Arguments to print to standard output. type: ...any returnType: void From ef6b28a2d502dc7f7d90d37c046ea5f20303e5ca Mon Sep 17 00:00:00 2001 From: tapple Date: Tue, 20 Jan 2026 07:43:22 -0800 Subject: [PATCH 042/102] fixed optionals --- slua_definitions.yaml | 144 ++++++++++++++---------------------------- 1 file changed, 48 insertions(+), 96 deletions(-) diff --git a/slua_definitions.yaml b/slua_definitions.yaml index 1a5ce55..22da510 100644 --- a/slua_definitions.yaml +++ b/slua_definitions.yaml @@ -350,8 +350,7 @@ modules: - name: field type: number - name: width - type: number - optional: true + type: number? returnType: number - name: lrotate comment: Left rotate @@ -379,8 +378,7 @@ modules: - name: field type: number - name: width - type: number - optional: true + type: number? returnType: number - name: rrotate comment: Right rotate @@ -601,8 +599,7 @@ modules: - name: value type: string - name: count - type: number - optional: true + type: number? returnType: () - name: len comment: Returns the length of the buffer @@ -620,11 +617,9 @@ modules: - name: source type: buffer - name: sourceOffset - type: number - optional: true + type: number? - name: count - type: number - optional: true + type: number? returnType: () - name: fill comment: Fill buffer with a value @@ -636,8 +631,7 @@ modules: - name: value type: number - name: count - type: number - optional: true + type: number? returnType: () - name: readbits comment: Read bits from buffer @@ -744,21 +738,17 @@ modules: - comment: Returns a string with a traceback of the current call stack parameters: - name: message - type: string - optional: true + type: string? - name: level - type: number - optional: true + type: number? returnType: string parameters: - name: thread type: thread - name: message - type: string - optional: true + type: string? - name: level - type: number - optional: true + type: number? returnType: string - name: llbase64 comment: Base64 encoding/decoding library @@ -777,8 +767,7 @@ modules: - name: data type: string - name: asBuffer - type: boolean - optional: true + type: boolean? returnType: string | buffer parameters: - name: data @@ -806,8 +795,7 @@ modules: - name: value type: any - name: tight - type: boolean - optional: true + type: boolean? returnType: string - name: sldecode comment: Decodes a JSON string to a Lua value preserving SL types @@ -954,8 +942,7 @@ modules: - name: x type: number - name: base - type: number - optional: true + type: number? returnType: number - name: log10 comment: Returns the base-10 logarithm of x @@ -1005,11 +992,9 @@ modules: - name: x type: number - name: y - type: number - optional: true + type: number? - name: z - type: number - optional: true + type: number? returnType: number - name: pow comment: Returns base^exponent @@ -1029,11 +1014,9 @@ modules: comment: Returns a pseudo-random number parameters: - name: m - type: number - optional: true + type: number? - name: n - type: number - optional: true + type: number? returnType: number - name: randomseed comment: Sets the seed for the pseudo-random generator @@ -1119,11 +1102,9 @@ modules: comment: Returns a string or table containing date and time parameters: - name: format - type: string - optional: true + type: string? - name: time - type: number - optional: true + type: number? returnType: string | OsDateTime | nil - name: difftime comment: Returns the difference in seconds between two times @@ -1131,15 +1112,13 @@ modules: - name: t2 type: number - name: t1 - type: number - optional: true + type: number? returnType: number - name: time comment: Returns the current time or converts a table to time parameters: - name: time - type: OsDateTime - optional: true + type: OsDateTime? returnType: number? - name: quaternion comment: Global 'quaternion' library table with callable metatable @@ -1254,11 +1233,9 @@ modules: - name: s type: string - name: i - type: number - optional: true + type: number? - name: j - type: number - optional: true + type: number? returnType: '...number' - name: char comment: Returns a string from character codes @@ -1274,11 +1251,9 @@ modules: - name: pattern type: string - name: init - type: number - optional: true + type: number? - name: plain - type: boolean - optional: true + type: boolean? returnType: (number?, number?, ...string) - name: format comment: Returns a formatted string @@ -1306,8 +1281,7 @@ modules: - name: repl type: 'string | { [string]: string } | (...string) -> string' - name: n - type: number - optional: true + type: number? returnType: (string, number) - name: len comment: Returns the length of the string @@ -1329,8 +1303,7 @@ modules: - name: pattern type: string - name: init - type: number - optional: true + type: number? returnType: '...string' - name: pack comment: Packs values into a binary string @@ -1366,8 +1339,7 @@ modules: - name: s type: string - name: separator - type: string - optional: true + type: string? returnType: '{string}' - name: sub comment: Returns a substring @@ -1377,8 +1349,7 @@ modules: - name: i type: number - name: j - type: number - optional: true + type: number? returnType: string - name: unpack comment: Unpacks values from a binary string @@ -1388,8 +1359,7 @@ modules: - name: s type: string - name: pos - type: number - optional: true + type: number? returnType: '...any' - name: upper comment: Converts string to uppercase @@ -1406,14 +1376,11 @@ modules: - name: list type: '{string}' - name: sep - type: string - optional: true + type: string? - name: i - type: number - optional: true + type: number? - name: j - type: number - optional: true + type: number? returnType: string - name: foreach comment: Iterates over table key-value pairs (deprecated) @@ -1472,8 +1439,7 @@ modules: - name: list type: '{T}' - name: pos - type: number - optional: true + type: number? returnType: T? - name: sort comment: Sorts list elements in place @@ -1482,8 +1448,7 @@ modules: - name: list type: '{T}' - name: comp - type: '(a: T, b: T) -> boolean' - optional: true + type: '((a: T, b: T) -> boolean)?' returnType: () - name: pack comment: Packs arguments into a table with length field n @@ -1499,11 +1464,9 @@ modules: - name: list type: '{T}' - name: i - type: number - optional: true + type: number? - name: j - type: number - optional: true + type: number? returnType: '...T' - name: move comment: Moves elements from one table to another @@ -1518,8 +1481,7 @@ modules: - name: t type: number - name: a2 - type: '{T}' - optional: true + type: '{T}?' returnType: '{T}' - name: create comment: Creates a new table with pre-allocated array slots @@ -1528,8 +1490,7 @@ modules: - name: count type: number - name: value - type: T - optional: true + type: T? returnType: '{T}' - name: find comment: Finds the index of a value in an array @@ -1540,8 +1501,7 @@ modules: - name: value type: T - name: init - type: number - optional: true + type: number? returnType: number? - name: clear comment: Removes all elements from a table @@ -1590,11 +1550,9 @@ modules: - name: s type: string - name: i - type: number - optional: true + type: number? - name: j - type: number - optional: true + type: number? returnType: '...number' - name: len comment: Returns the number of UTF-8 characters in a string, or nil and error @@ -1603,11 +1561,9 @@ modules: - name: s type: string - name: i - type: number - optional: true + type: number? - name: j - type: number - optional: true + type: number? returnType: (number?, number?) - name: offset comment: Returns the byte position of the n-th character @@ -1617,8 +1573,7 @@ modules: - name: n type: number - name: i - type: number - optional: true + type: number? returnType: number? properties: - name: charpattern @@ -1674,8 +1629,7 @@ modules: - name: y type: number - name: z - type: number - optional: true + type: number? returnType: vector - name: magnitude comment: Calculates the magnitude of a given vector @@ -1724,8 +1678,7 @@ modules: - name: b type: vector - name: axis - type: vector - optional: true + type: vector? returnType: number - name: floor comment: Applies math.floor to every component of the input vector @@ -1821,8 +1774,7 @@ modules: - name: y type: number - name: z - type: number - optional: true + type: number? returnType: vector constants: [] From b4380413b9ffa39e1225eb009ba3e54b329b52fe Mon Sep 17 00:00:00 2001 From: tapple Date: Tue, 20 Jan 2026 08:40:01 -0800 Subject: [PATCH 043/102] add values to constants --- slua_definitions.yaml | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/slua_definitions.yaml b/slua_definitions.yaml index 22da510..43f8265 100644 --- a/slua_definitions.yaml +++ b/slua_definitions.yaml @@ -806,22 +806,26 @@ modules: properties: - name: 'null' comment: A constant to pass for null to json encode - type: any + type: userdata - name: empty_array_mt comment: Metatable for declaring table as an empty array for json encode type: '{ [any]: any }' + value: '{}' - name: array_mt comment: Metatable for declaring table as an array for json encode type: '{ [any]: any }' + value: '{}' - name: empty_array comment: A constant to pass for an empty array to json encode - type: any + type: userdata - name: _NAME comment: Name of the lljson library type: string + value: lljson - name: _VERSION comment: Version of the lljson library type: string + value: "2.1.0.11" - name: math comment: Mathematical functions library functions: @@ -1088,9 +1092,11 @@ modules: - name: pi comment: The value of pi type: number + value: 3.141592653589793 - name: huge comment: A value larger than any other numeric value (infinity) type: number + value: inf - name: os comment: Operating system facilities library functions: @@ -1105,7 +1111,7 @@ modules: type: string? - name: time type: number? - returnType: string | OsDateTime | nil + returnType: (string | OsDateTime)? - name: difftime comment: Returns the difference in seconds between two times parameters: @@ -1455,7 +1461,7 @@ modules: typeParameters: [T] parameters: - name: ... - type...: T + type: ...T returnType: '{ n: number, [number]: T }' - name: unpack comment: Unpacks table elements as multiple return values @@ -1579,6 +1585,7 @@ modules: - name: charpattern comment: Pattern that matches exactly one UTF-8 byte sequence type: string + value: "[\\x00-\\x7F\\xC2-\\xF4][\\x80-\\xBF]*" - name: uuid comment: Global 'uuid' library table type: From 4dbb40b7b32a347d325a51f07488d843bdad31b2 Mon Sep 17 00:00:00 2001 From: tapple Date: Tue, 20 Jan 2026 09:00:44 -0800 Subject: [PATCH 044/102] converted quaternion, vector, uuid to module format --- slua_definitions.yaml | 523 +++++++++++++++++++----------------------- 1 file changed, 231 insertions(+), 292 deletions(-) diff --git a/slua_definitions.yaml b/slua_definitions.yaml index 43f8265..7191aa5 100644 --- a/slua_definitions.yaml +++ b/slua_definitions.yaml @@ -1128,108 +1128,90 @@ modules: returnType: number? - name: quaternion comment: Global 'quaternion' library table with callable metatable - type: - callSignature: - parameters: - - name: x - type: number - - name: y - type: number - - name: z - type: number - - name: s - type: number - returnType: quaternion - kind: callable-table - tableType: - properties: - - name: create - comment: Constructor - type: - kind: function - parameters: - - name: x - type: number - - name: y - type: number - - name: z - type: number - - name: s - type: number - returnType: quaternion - - name: identity - comment: Identity quaternion constant - type: quaternion - - name: normalize - comment: Returns normalized quaternion - type: - kind: function - parameters: - - name: q - type: quaternion - returnType: quaternion - - name: magnitude - comment: Returns magnitude of quaternion - type: - kind: function - parameters: - - name: q - type: quaternion - returnType: number - - name: dot - comment: Dot product of two quaternions - type: - kind: function - parameters: - - name: a - type: quaternion - - name: b - type: quaternion - returnType: number - - name: slerp - comment: Spherical linear interpolation - type: - kind: function - parameters: - - name: a - type: quaternion - - name: b - type: quaternion - - name: t - type: number - returnType: quaternion - - name: conjugate - comment: Returns conjugate of quaternion - type: - kind: function - parameters: - - name: q - type: quaternion - returnType: quaternion - - name: tofwd - comment: Returns forward vector from quaternion rotation - type: - kind: function - parameters: - - name: q - type: quaternion - returnType: vector - - name: toleft - comment: Returns left vector from quaternion rotation - type: - kind: function - parameters: - - name: q - type: quaternion - returnType: vector - - name: toup - comment: Returns up vector from quaternion rotation - type: - kind: function - parameters: - - name: q - type: quaternion - returnType: vector + callable: + name: quaternion + parameters: + - name: x + type: number + - name: y + type: number + - name: z + type: number + - name: s + type: number + returnType: quaternion + functions: + - name: create + comment: Constructor + parameters: + - name: x + type: number + - name: y + type: number + - name: z + type: number + - name: s + type: number + returnType: quaternion + - name: normalize + comment: Returns normalized quaternion + parameters: + - name: q + type: quaternion + returnType: quaternion + - name: magnitude + comment: Returns magnitude of quaternion + parameters: + - name: q + type: quaternion + returnType: number + - name: dot + comment: Dot product of two quaternions + parameters: + - name: a + type: quaternion + - name: b + type: quaternion + returnType: number + - name: slerp + comment: Spherical linear interpolation + parameters: + - name: a + type: quaternion + - name: b + type: quaternion + - name: t + type: number + returnType: quaternion + - name: conjugate + comment: Returns conjugate of quaternion + parameters: + - name: q + type: quaternion + returnType: quaternion + - name: tofwd + comment: Returns forward vector from quaternion rotation + parameters: + - name: q + type: quaternion + returnType: vector + - name: toleft + comment: Returns left vector from quaternion rotation + parameters: + - name: q + type: quaternion + returnType: vector + - name: toup + comment: Returns up vector from quaternion rotation + parameters: + - name: q + type: quaternion + returnType: vector + properties: + - name: identity + comment: Identity quaternion constant + type: quaternion + value: <0, 0, 0, 1> - name: string comment: String manipulation library functions: @@ -1588,201 +1570,158 @@ modules: value: "[\\x00-\\x7F\\xC2-\\xF4][\\x80-\\xBF]*" - name: uuid comment: Global 'uuid' library table - type: - kind: table - properties: - - name: create - comment: Creates a new uuid from a string, buffer, or existing uuid. Returns - nil if the string is not a valid UUID. Throws an error if the buffer is - shorter than 16 bytes. - type: - kind: function - parameters: - - name: value - type: - kind: union - types: - - string - - buffer - - uuid - returnType: uuid? - - name: __call - comment: Allows calling uuid() as a constructor - type: - kind: function - parameters: - - name: self - type: any - - name: value - type: - kind: union - types: - - string - - buffer - - uuid - returnType: uuid? + callable: + name: uuid + comment: Allows calling uuid() as a constructor + parameters: + - name: self + type: any + - name: value + type: string | buffer | uuid + returnType: uuid? + functions: + - name: create + comment: Creates a new uuid from a string, buffer, or existing uuid. Returns + nil if the string is not a valid UUID. Throws an error if the buffer is + shorter than 16 bytes. + parameters: + - name: value + type: string | buffer | uuid + returnType: uuid? - name: vector comment: Global 'vector' library table - type: - kind: table - properties: - - name: create - comment: Creates a new vector with the given component values - type: - kind: function - parameters: - - name: x - type: number - - name: y - type: number - - name: z - type: number? - returnType: vector - - name: magnitude - comment: Calculates the magnitude of a given vector - type: - kind: function - parameters: - - name: v - type: vector - returnType: number - - name: normalize - comment: Computes the normalized version (unit vector) of a given vector - type: - kind: function - parameters: - - name: v - type: vector - returnType: vector - - name: cross - comment: Computes the cross product of two vectors - type: - kind: function - parameters: - - name: a - type: vector - - name: b - type: vector - returnType: vector - - name: dot - comment: Computes the dot product of two vectors - type: - kind: function - parameters: - - name: a - type: vector - - name: b - type: vector - returnType: number - - name: angle - comment: Computes the angle between two vectors in radians. The axis, if specified, - is used to determine the sign of the angle. - type: - kind: function - parameters: - - name: a - type: vector - - name: b - type: vector - - name: axis - type: vector? - returnType: number - - name: floor - comment: Applies math.floor to every component of the input vector - type: - kind: function - parameters: - - name: v - type: vector - returnType: vector - - name: ceil - comment: Applies math.ceil to every component of the input vector - type: - kind: function - parameters: - - name: v - type: vector - returnType: vector - - name: abs - comment: Applies math.abs to every component of the input vector - type: - kind: function - parameters: - - name: v - type: vector - returnType: vector - - name: sign - comment: Applies math.sign to every component of the input vector - type: - kind: function - parameters: - - name: v - type: vector - returnType: vector - - name: clamp - comment: Applies math.clamp to every component of the input vector - type: - kind: function - parameters: - - name: v - type: vector - - name: min - type: vector - - name: max - type: vector - returnType: vector - - name: max - comment: Applies math.max to the corresponding components of the input vectors - type: - kind: function - parameters: - - name: v - type: vector - - name: ... - type: ...vector - returnType: vector + callable: + name: vector + comment: 'Constructor call: vector(x, y, z)' + parameters: + - name: self + type: any + - name: x + type: number + - name: y + type: number + - name: z + type: number? + returnType: vector + functions: + - name: create + comment: Creates a new vector with the given component values + parameters: + - name: x + type: number + - name: y + type: number + - name: z + type: number? + returnType: vector + - name: magnitude + comment: Calculates the magnitude of a given vector + parameters: + - name: v + type: vector + returnType: number + - name: normalize + comment: Computes the normalized version (unit vector) of a given vector + parameters: + - name: v + type: vector + returnType: vector + - name: cross + comment: Computes the cross product of two vectors + parameters: + - name: a + type: vector + - name: b + type: vector + returnType: vector + - name: dot + comment: Computes the dot product of two vectors + parameters: + - name: a + type: vector + - name: b + type: vector + returnType: number + - name: angle + comment: Computes the angle between two vectors in radians. The axis, if specified, + is used to determine the sign of the angle. + parameters: + - name: a + type: vector + - name: b + type: vector + - name: axis + type: vector? + returnType: number + - name: floor + comment: Applies math.floor to every component of the input vector + parameters: + - name: v + type: vector + returnType: vector + - name: ceil + comment: Applies math.ceil to every component of the input vector + parameters: + - name: v + type: vector + returnType: vector + - name: abs + comment: Applies math.abs to every component of the input vector + parameters: + - name: v + type: vector + returnType: vector + - name: sign + comment: Applies math.sign to every component of the input vector + parameters: + - name: v + type: vector + returnType: vector + - name: clamp + comment: Applies math.clamp to every component of the input vector + parameters: + - name: v + type: vector - name: min - comment: Applies math.min to the corresponding components of the input vectors - type: - kind: function - parameters: - - name: v - type: vector - - name: ... - type: ...vector - returnType: vector - - name: lerp - comment: Linear interpolation between two vectors - type: - kind: function - parameters: - - name: a - type: vector - - name: b - type: vector - - name: t - type: number - returnType: vector - - name: zero - comment: A zero vector <0,0,0> type: vector - - name: one - comment: A one vector <1,1,1> + - name: max type: vector - - name: __call - comment: 'Constructor call: vector(x, y, z)' - type: - kind: function - parameters: - - name: self - type: any - - name: x - type: number - - name: y - type: number - - name: z - type: number? - returnType: vector + returnType: vector + - name: max + comment: Applies math.max to the corresponding components of the input vectors + parameters: + - name: v + type: vector + - name: ... + type: ...vector + returnType: vector + - name: min + comment: Applies math.min to the corresponding components of the input vectors + parameters: + - name: v + type: vector + - name: ... + type: ...vector + returnType: vector + - name: lerp + comment: Linear interpolation between two vectors + parameters: + - name: a + type: vector + - name: b + type: vector + - name: t + type: number + returnType: vector + properties: + - name: zero + comment: A zero vector + type: vector + value: <0,0,0> + - name: one + comment: A one vector + type: vector + value: <1,1,1> constants: [] # Everything below here is only for keywords.xml generation, not typechecking From 56fa56f08b42a785c22524a1e7838a901313b0e6 Mon Sep 17 00:00:00 2001 From: tapple Date: Tue, 20 Jan 2026 09:01:02 -0800 Subject: [PATCH 045/102] fix bugs generating modules --- gen_definitions.py | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/gen_definitions.py b/gen_definitions.py index e4e77a6..982ee09 100644 --- a/gen_definitions.py +++ b/gen_definitions.py @@ -514,7 +514,7 @@ def to_keywords_functions_dict(self) -> dict: }) return functions - def to_keywords_properties_dict(self) -> dict: + def to_keywords_constants_dict(self) -> dict: return { f"{self.name}.{prop.name}": prop.to_keywords_dict() for prop in sorted(self.properties, key=lambda x: x.name) @@ -766,7 +766,6 @@ def _parse_dict(self, def_dict: dict) -> SLuaDefinitions: # 1. Luau builtins. Typecheckers already know about these self.definitions.builtinTypes.update(def_dict["builtinTypes"]) self.type_names.update(self.definitions.builtinTypes.keys()) - self.global_scope.update(self.definitions.builtinTypes.keys()) self.definitions.controls.update(def_dict["controls"]) self.global_scope.update(self.definitions.controls.keys()) self.definitions.builtinConstants.extend( @@ -813,7 +812,7 @@ def _validate_module(self, data: any) -> SLuaModuleDeclaration: ) try: self._validate_identifier(module.name) - self._validate_scope(module.name, self.type_names) + self._validate_scope(module.name, self.global_scope) module_scope: Set[str] = set() callable = data.get("callable") if callable is not None: @@ -857,14 +856,14 @@ def _validate_class(self, data: any) -> SLuaClassDeclaration: return class_ def _validate_function(self, data: any, scope: Set[str], method: bool = False) -> SLuaFunctionSignature: - func = SLuaFunctionSignature( - name=data["name"], - typeParameters=data.get("typeParameters", []), - parameters=[SLuaParameter(**p) for p in data.get("parameters", [])], - returnType=data.get("returnType", "void"), - comment=data.get("comment", ""), - ) try: + func = SLuaFunctionSignature( + name=data["name"], + typeParameters=data.get("typeParameters", []), + parameters=[SLuaParameter(**p) for p in data.get("parameters", [])], + returnType=data.get("returnType", "void"), + comment=data.get("comment", ""), + ) self._validate_identifier(func.name) self._validate_scope(func.name, scope) known_types = self.validate_type_params(func.typeParameters) @@ -883,9 +882,9 @@ def _validate_function(self, data: any, scope: Set[str], method: bool = False) - self._validate_identifier(param.name) self._validate_scope(param.name, params_scope) self.validate_type(param.type, known_types) + return func except Exception as e: - raise ValueError(f"In function {func.name}: {e}") from e - return func + raise ValueError(f"In function {data["name"]}: {e}") from e def _validate_type_alias(self, data: any) -> SLuaTypeAlias: alias = SLuaTypeAlias(**data) @@ -902,7 +901,7 @@ def _validate_property(self, data: any, scope: Set[str], const: bool = False) -> prop = SLuaProperty(**data) self._validate_identifier(prop.name) self._validate_scope(prop.name, scope) - if const and prop.value is None: + if const and prop.type != "userdata" and prop.value is None: raise ValueError(f"Constant {prop.name} must have a value") if prop.name == "nil" and prop.type == "nil" and scope is self.global_scope: return prop # only nil is allowed to be nil @@ -917,7 +916,7 @@ def validate_type_params(self, type_params: List[str]) -> set[str]: self._validate_scope(type_param, known_types) return known_types - _TYPE_SEPERATORS_RE = re.compile(r"[ \n?&|,{}\[\]()]|\.\.\.|->|[a-zA-Z0-9_]*:") + _TYPE_SEPERATORS_RE = re.compile(r"[ \n?&|,{}\[\]()]|\.\.\.|->|[a-zA-Z0-9_]*:|\"[a-zA-Z0-9_]*\"") def validate_type(self, type: str, known_type_names: set[str] | None = None) -> str: if not type: From a31f5f99c6b2b9049b68ece52e9f6c3c3f07b665 Mon Sep 17 00:00:00 2001 From: tapple Date: Tue, 20 Jan 2026 11:56:38 -0800 Subject: [PATCH 046/102] Merged in bit32 comments from keywords_lua.xml --- slua_definitions.yaml | 119 +++++++++++++++++++++++++++++++++--------- 1 file changed, 93 insertions(+), 26 deletions(-) diff --git a/slua_definitions.yaml b/slua_definitions.yaml index 7191aa5..31dfeb8 100644 --- a/slua_definitions.yaml +++ b/slua_definitions.yaml @@ -418,241 +418,308 @@ modules: comment: Buffer manipulation library for binary data functions: - name: create - comment: Creates a new buffer of the specified size + comment: Creates a buffer of the requested size with all bytes initialized to 0. parameters: - name: size + comment: Size of the buffer to create. type: number returnType: buffer - name: fromstring - comment: Creates a buffer from a string + comment: Creates a buffer initialized to the contents of the string. parameters: - name: str + comment: String to initialize the buffer with. type: string returnType: buffer - name: tostring - comment: Converts buffer to string + comment: Returns the buffer data as a string. parameters: - name: b + comment: Buffer to convert to a string. type: buffer returnType: string - name: readi8 - comment: Read signed 8-bit integer + comment: Reads a signed 8-bit integer from the buffer at the given offset. parameters: - name: b + comment: Buffer to read from. type: buffer - name: offset + comment: Byte offset to read from. type: number returnType: number - name: readu8 - comment: Read unsigned 8-bit integer + comment: Reads an unsigned 8-bit integer from the buffer at the given offset. parameters: - name: b + comment: Buffer to read from. type: buffer - name: offset + comment: Byte offset to read from. type: number returnType: number - name: readi16 - comment: Read signed 16-bit integer + comment: Reads a signed 16-bit integer from the buffer at the given offset. parameters: - name: b + comment: Buffer to read from. type: buffer - name: offset + comment: Byte offset to read from. type: number returnType: number - name: readu16 - comment: Read unsigned 16-bit integer + comment: Reads an unsigned 16-bit integer from the buffer at the given offset. parameters: - name: b + comment: Buffer to read from. type: buffer - name: offset + comment: Byte offset to read from. type: number returnType: number - name: readi32 - comment: Read signed 32-bit integer + comment: Reads a signed 32-bit integer from the buffer at the given offset. parameters: - name: b + comment: Buffer to read from. type: buffer - name: offset + comment: Byte offset to read from. type: number returnType: number - name: readu32 - comment: Read unsigned 32-bit integer + comment: Reads an unsigned 32-bit integer from the buffer at the given offset. parameters: - name: b + comment: Buffer to read from. type: buffer - name: offset + comment: Byte offset to read from. type: number returnType: number - name: readf32 - comment: Read 32-bit float + comment: Reads a 32-bit floating-point number from the buffer at the given offset. parameters: - name: b + comment: Buffer to read from. type: buffer - name: offset + comment: Byte offset to read from. type: number returnType: number - name: readf64 - comment: Read 64-bit float + comment: Reads a 64-bit floating-point number from the buffer at the given offset. parameters: - name: b + comment: Buffer to read from. type: buffer - name: offset + comment: Byte offset to read from. type: number returnType: number - name: writei8 - comment: Write signed 8-bit integer + comment: Writes a signed 8-bit integer to the buffer at the given offset. parameters: - name: b + comment: Buffer to write to. type: buffer - name: offset + comment: Byte offset to write at. type: number - name: value + comment: Value to write. type: number returnType: () - name: writeu8 - comment: Write unsigned 8-bit integer + comment: Writes an unsigned 8-bit integer to the buffer at the given offset. parameters: - name: b + comment: Buffer to write to. type: buffer - name: offset + comment: Byte offset to write at. type: number - name: value + comment: Value to write. type: number returnType: () - name: writei16 - comment: Write signed 16-bit integer + comment: Writes a signed 16-bit integer to the buffer at the given offset. parameters: - name: b + comment: Buffer to write to. type: buffer - name: offset + comment: Byte offset to write at. type: number - name: value + comment: Value to write. type: number returnType: () - name: writeu16 - comment: Write unsigned 16-bit integer + comment: Writes an unsigned 16-bit integer to the buffer at the given offset. parameters: - name: b + comment: Buffer to write to. type: buffer - name: offset + comment: Byte offset to write at. type: number - name: value + comment: Value to write. type: number returnType: () - name: writei32 - comment: Write signed 32-bit integer + comment: Writes a signed 32-bit integer to the buffer at the given offset. parameters: - name: b + comment: Buffer to write to. type: buffer - name: offset + comment: Byte offset to write at. type: number - name: value + comment: Value to write. type: number returnType: () - name: writeu32 - comment: Write unsigned 32-bit integer + comment: Writes an unsigned 32-bit integer to the buffer at the given offset. parameters: - name: b + comment: Buffer to write to. type: buffer - name: offset + comment: Byte offset to write at. type: number - name: value + comment: Value to write. type: number returnType: () - name: writef32 - comment: Write 32-bit float + comment: Writes a 32-bit floating-point number to the buffer at the given offset. parameters: - name: b + comment: Buffer to write to. type: buffer - name: offset + comment: Byte offset to write at. type: number - name: value + comment: Value to write. type: number returnType: () - name: writef64 - comment: Write 64-bit float + comment: Writes a 64-bit floating-point number to the buffer at the given offset. parameters: - name: b + comment: Buffer to write to. type: buffer - name: offset + comment: Byte offset to write at. type: number - name: value + comment: Value to write. type: number returnType: () - name: readstring - comment: Read string from buffer + comment: Reads a string of the given length from the buffer at the specified offset. parameters: - name: b + comment: Buffer to read from. type: buffer - name: offset + comment: Byte offset to start reading. type: number - name: count + comment: Number of bytes to read. type: number returnType: string - name: writestring - comment: Write string to buffer + comment: Writes data from a string into the buffer at the specified offset. parameters: - name: b + comment: Buffer to write to. type: buffer - name: offset + comment: Byte offset to write at. type: number - name: value + comment: String to write. type: string - name: count + comment: Number of bytes to write (optional). type: number? returnType: () - name: len - comment: Returns the length of the buffer + comment: Returns the size of the buffer in bytes. parameters: - name: b + comment: Buffer to get the size of. type: buffer returnType: number - name: copy - comment: Copy data from source buffer to target buffer + comment: Copies bytes from the source buffer into the target buffer. parameters: - name: target + comment: Target buffer to copy into. type: buffer - name: targetOffset + comment: Offset in target buffer. type: number - name: source + comment: Source buffer to copy from. type: buffer - name: sourceOffset + comment: Offset in source buffer (optional). type: number? - name: count + comment: Number of bytes to copy (optional). type: number? returnType: () - name: fill - comment: Fill buffer with a value + comment: Fills the buffer with the specified value starting at the given offset. parameters: - name: b + comment: Buffer to fill. type: buffer - name: offset + comment: Byte offset to start filling. type: number - name: value + comment: Value to fill with. type: number - name: count + comment: Number of bytes to fill (optional). type: number? returnType: () - name: readbits - comment: Read bits from buffer + comment: Reads up to 32 bits from the buffer at the given offset. parameters: - name: b + comment: Buffer to read from. type: buffer - name: bitOffset + comment: Bit offset to read at. type: number - name: bitCount + comment: Number of bits to read. Must be in [0, 32] range. type: number returnType: number - name: writebits - comment: Write bits to buffer + comment: Writes up to 32 bits to the buffer at the given offset. parameters: - name: b + comment: Buffer to write to. type: buffer - name: bitOffset + comment: Bit offset to write at. type: number - name: bitCount + comment: Number of bits to write. Must be in [0, 32] range. type: number - name: value + comment: Source of bits to write. type: number returnType: () - name: coroutine From f748d606658168317b404555d26f9f520e2b7324 Mon Sep 17 00:00:00 2001 From: tapple Date: Tue, 20 Jan 2026 11:57:44 -0800 Subject: [PATCH 047/102] generate a library header in keywords_lua --- gen_definitions.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gen_definitions.py b/gen_definitions.py index 982ee09..d102a33 100644 --- a/gen_definitions.py +++ b/gen_definitions.py @@ -508,6 +508,8 @@ def to_keywords_functions_dict(self) -> dict: functions = {} if self.callable: functions[self.name] = self.callable.to_keywords_dict() + else: + functions[self.name] = {"energy": -1.0, "tooltip": self.comment} functions.update({ f"{self.name}.{func.name}": func.to_keywords_dict() for func in sorted(self.functions, key=lambda x: x.name) From c8cf02efa115a0e0c735d5b4a2b4a7823827c6cc Mon Sep 17 00:00:00 2001 From: tapple Date: Tue, 20 Jan 2026 14:37:50 -0800 Subject: [PATCH 048/102] Merged in coroutine comments from keywords_lua.xml --- slua_definitions.yaml | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/slua_definitions.yaml b/slua_definitions.yaml index 31dfeb8..c992115 100644 --- a/slua_definitions.yaml +++ b/slua_definitions.yaml @@ -726,49 +726,56 @@ modules: comment: Coroutine manipulation library functions: - name: create - comment: Creates a new coroutine from a function + comment: Returns a new coroutine that, when resumed, will run function f. parameters: - name: f + comment: A function to be executed by the new coroutine. type: (...any) -> ...any returnType: thread - name: resume - comment: Resumes a coroutine, returns success and results + comment: Resumes a coroutine, returning true and results if successful, or false and an error. parameters: - name: co + comment: The coroutine to resume. type: thread - name: ... + comment: Arguments to pass to the coroutine. type: ...any returnType: (boolean, ...any) - name: running - comment: Returns the running coroutine, or nil if called from main thread + comment: Returns the currently running coroutine, or nil if called from in the main coroutine. parameters: [] returnType: thread? - name: status - comment: Returns the status of a coroutine + comment: 'Returns the status of the coroutine: "running", "suspended", "normal", or "dead".' parameters: - name: co + comment: The coroutine to check status of. type: thread returnType: '"running" | "suspended" | "normal" | "dead"' - name: wrap - comment: Creates a coroutine and returns a function that resumes it + comment: Creates a coroutine and returns a function that resumes it. parameters: - name: f + comment: A function to execute in a coroutine. type: (...any) -> ...any returnType: (...any) -> ...any - name: yield - comment: Suspends the coroutine and returns values to resume + comment: Yields the current coroutine, passing arguments to the resuming code. parameters: - name: ... + comment: Values to pass to the resuming code. type: ...any returnType: '...any' - name: isyieldable - comment: Returns true if the coroutine can yield + comment: Returns true if the currently running coroutine can yield. parameters: [] returnType: boolean - name: close - comment: Closes a coroutine, returns success and optional error message + comment: Closes a coroutine, returning true if successful or false and an error. parameters: - name: co + comment: The coroutine to close. type: thread returnType: (boolean, string?) - name: debug From 6ea7e07c33154189f0cfaa20889c7f3219adee14 Mon Sep 17 00:00:00 2001 From: tapple Date: Tue, 20 Jan 2026 15:59:38 -0800 Subject: [PATCH 049/102] Merged in debug comments and private functions from keywords_lua.xml --- slua_definitions.yaml | 115 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 105 insertions(+), 10 deletions(-) diff --git a/slua_definitions.yaml b/slua_definitions.yaml index c992115..24aafac 100644 --- a/slua_definitions.yaml +++ b/slua_definitions.yaml @@ -782,48 +782,143 @@ modules: comment: Debug library for introspection functions: - name: info - comment: Returns information about a function or stack level + comment: Returns information about a stack frame or function based on specified format. overloads: - comment: Returns information about a stack level parameters: - name: level + comment: Stack level or function reference for inspection. type: number - - name: options + - name: s + comment: String specifying requested information. type: string returnType: '...any' - comment: Returns information about a function parameters: - name: func + comment: Function reference. type: (...any) -> ...any - - name: options + - name: s + comment: String specifying requested information. type: string returnType: '...any' parameters: - - name: thread - type: thread + - name: co + comment: Optional thread or function reference. + type: thread | ((...any) -> ...any) | number - name: level + comment: Stack level or function reference for inspection. type: number - - name: options + - name: s + comment: String specifying requested information. type: string returnType: '...any' - name: traceback - comment: Returns a string with a traceback of the call stack + comment: Returns a human-readable call stack starting from the specified level. overloads: - comment: Returns a string with a traceback of the current call stack parameters: - name: message + comment: Optional message prepended to the traceback. type: string? - name: level + comment: Optional stack level to start traceback. type: number? returnType: string parameters: - - name: thread + - name: co + comment: Optional thread reference for traceback. type: thread - - name: message + - name: msg + comment: Optional message prepended to the traceback. type: string? - name: level + comment: Optional stack level to start traceback. type: number? returnType: string + - name: getinfo + comment: Returns a table containing debug information about a function or stack frame. + parameters: + - name: thread + comment: Optional thread whose stack frame is being inspected. + type: thread + - name: function + comment: Function reference or stack level number. + type: ((...any) -> ...any) | number + - name: what + comment: String specifying which fields to retrieve. + type: string + private: true + returnType: "{[any]: any}" + - name: getlocal + comment: Returns the name and value of a local variable at the specified stack level. + parameters: + - name: level + comment: Stack level number. + type: number + - name: index + comment: Index of the local variable. + type: number + private: true + returnType: string | any + - name: setlocal + comment: Sets the value of a local variable at the specified stack level. + parameters: + - name: level + comment: Stack level number. + type: number + - name: index + comment: Index of the local variable. + type: number + - name: value + comment: New value for the local variable. + type: any + private: true + returnType: boolean + - name: getupvalue + comment: Returns the name and value of an upvalue for a given function. + parameters: + - name: function + comment: Function whose upvalues are being retrieved. + type: (...any) -> ...any + - name: index + comment: Index of the upvalue. + type: number + private: true + returnType: string | any + - name: setupvalue + comment: Sets the value of an upvalue for a given function. + parameters: + - name: function + comment: Function whose upvalues are being modified. + type: (...any) -> ...any + - name: index + comment: Index of the upvalue. + type: number + - name: value + comment: New value for the upvalue. + type: any + private: true + returnType: string + - name: getmetatable + comment: Returns the metatable of the given value, if any. + parameters: + - name: value + comment: Value whose metatable is retrieved. + type: any + private: true + returnType: "{[any]: any}?" + - name: setmetatable + comment: Sets the metatable for a given value. + parameters: + - name: value + comment: Value whose metatable is to be set. + type: any + - name: metatable + comment: Table to be set as the new metatable. + type: "{[any]: any}?" + private: true + returnType: any - name: llbase64 comment: Base64 encoding/decoding library functions: @@ -1903,7 +1998,7 @@ builtinFunctions: - name: obj comment: The object to get the metatable for. type: any - returnType: "{any}?" + returnType: "{[any]: any}?" - name: next comment: Returns the next key-value pair in the table traversal order. typeParameters: [K, V] From c113e12e4ea91a89e7c823883e10f987a95f1f63 Mon Sep 17 00:00:00 2001 From: tapple Date: Tue, 20 Jan 2026 16:11:48 -0800 Subject: [PATCH 050/102] don't generate private functions --- gen_definitions.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gen_definitions.py b/gen_definitions.py index d102a33..db6e882 100644 --- a/gen_definitions.py +++ b/gen_definitions.py @@ -440,7 +440,8 @@ class SLuaFunctionSignature: parameters: List[SLuaParameter] returnType: str typeParameters: Optional[List[str]] = None - comment: Optional[str] = None + comment: str = "" + private: bool = False overloads: Optional[List[SLuaFunctionOverload]] = None def to_keywords_dict(self) -> dict: @@ -513,6 +514,7 @@ def to_keywords_functions_dict(self) -> dict: functions.update({ f"{self.name}.{func.name}": func.to_keywords_dict() for func in sorted(self.functions, key=lambda x: x.name) + if not func.private }) return functions @@ -865,6 +867,7 @@ def _validate_function(self, data: any, scope: Set[str], method: bool = False) - parameters=[SLuaParameter(**p) for p in data.get("parameters", [])], returnType=data.get("returnType", "void"), comment=data.get("comment", ""), + private=data.get("private", False), ) self._validate_identifier(func.name) self._validate_scope(func.name, scope) From eafe6a48cb1698c4690a649653af16290ccbbeba Mon Sep 17 00:00:00 2001 From: tapple Date: Tue, 20 Jan 2026 16:38:15 -0800 Subject: [PATCH 051/102] Merged in bit32 comments from keywords_lua.xml --- slua_definitions.yaml | 71 +++++++++++++++++++++++++++---------------- 1 file changed, 45 insertions(+), 26 deletions(-) diff --git a/slua_definitions.yaml b/slua_definitions.yaml index 24aafac..b6a74a9 100644 --- a/slua_definitions.yaml +++ b/slua_definitions.yaml @@ -305,47 +305,58 @@ modules: comment: Bitwise operations library functions: - name: arshift - comment: Arithmetic right shift + comment: |- + Shifts n by i bits to the right. If i is negative, a left shift is performed. + Does an arithmetic shift: The most significant bit of n is propagated during the shift. parameters: - - name: x + - name: "n" + comment: Number to shift. type: number - - name: disp + - name: i + comment: Number of bits to shift. type: number returnType: number - name: band - comment: Bitwise AND of all arguments + comment: Performs a bitwise AND operation on input numbers. parameters: - name: ... + comment: Numbers to perform bitwise AND on. type: ...number returnType: number - name: bnot - comment: Bitwise NOT + comment: Returns the bitwise negation of the input number. parameters: - - name: x + - name: "n" + comment: Number to negate. type: number returnType: number - name: bor - comment: Bitwise OR of all arguments + comment: Performs a bitwise OR operation on input numbers. parameters: - name: ... + comment: Numbers to perform bitwise OR on. type: ...number returnType: number - name: bxor - comment: Bitwise XOR of all arguments + comment: Performs a bitwise XOR operation on input numbers. parameters: - name: ... + comment: Numbers to perform bitwise XOR on. type: ...number returnType: number - name: btest - comment: Returns true if bitwise AND of all arguments is not zero + comment: |- + Performs a bitwise AND operation on input numbers. + Returns true if result is non-zero. parameters: - name: ... + comment: Numbers to perform bitwise AND on. type: ...number returnType: boolean - name: extract comment: Extracts bits from n at position field with width parameters: - - name: n + - name: "n" type: number - name: field type: number @@ -353,25 +364,29 @@ modules: type: number? returnType: number - name: lrotate - comment: Left rotate + comment: Rotates n by i bits to the left. If i is negative, a right rotate is performed. parameters: - - name: x + - name: "n" + comment: Number to rotate. type: number - - name: disp + - name: i + comment: Number of bits to rotate. type: number returnType: number - name: lshift - comment: Left shift + comment: Shifts n by i bits to the left. If i is negative, a right shift is performed. parameters: - - name: x + - name: "n" + comment: Number to shift. type: number - - name: disp + - name: i + comment: Number of bits to shift. type: number returnType: number - name: replace comment: Replaces bits in n at position field with width using value v parameters: - - name: n + - name: "n" type: number - name: v type: number @@ -381,37 +396,41 @@ modules: type: number? returnType: number - name: rrotate - comment: Right rotate + comment: Rotates n by i bits to the right. If i is negative, a left rotate is performed. parameters: - - name: x + - name: "n" + comment: Number to rotate. type: number - - name: disp + - name: i + comment: Number of bits to rotate. type: number returnType: number - name: rshift - comment: Right shift + comment: Shifts n by i bits to the right. If i is negative, a left shift is performed. parameters: - - name: x + - name: "n" + comment: Number to shift. type: number - - name: disp + - name: i + comment: Number of bits to shift. type: number returnType: number - name: countlz comment: Count leading zeros parameters: - - name: n + - name: "n" type: number returnType: number - name: countrz comment: Count trailing zeros parameters: - - name: n + - name: "n" type: number returnType: number - name: byteswap comment: Swap byte order parameters: - - name: n + - name: "n" type: number returnType: number - name: buffer From c5c80e43e20c0b724b9f931167c9fd482eab91fd Mon Sep 17 00:00:00 2001 From: tapple Date: Tue, 20 Jan 2026 21:08:30 -0800 Subject: [PATCH 052/102] Merged in math comments from keywords_lua.xml --- slua_definitions.yaml | 213 ++++++++++++++++++++++++++---------------- 1 file changed, 134 insertions(+), 79 deletions(-) diff --git a/slua_definitions.yaml b/slua_definitions.yaml index b6a74a9..508b3a5 100644 --- a/slua_definitions.yaml +++ b/slua_definitions.yaml @@ -50,7 +50,7 @@ baseClasses: properties: - name: x type: number - - name: y + - name: "y" type: number - name: z type: number @@ -124,7 +124,7 @@ baseClasses: properties: - name: x type: number - - name: y + - name: "y" type: number - name: z type: number @@ -1018,262 +1018,317 @@ modules: comment: Mathematical functions library functions: - name: abs - comment: Returns the absolute value of x + comment: Returns the absolute value of n. parameters: - - name: x + - name: "n" + comment: A number. type: number returnType: number - name: acos - comment: Returns the arc cosine of x (in radians) + comment: Returns the arc cosine of n in radians. parameters: - - name: x + - name: "n" + comment: A number in the range [-1, 1]. type: number returnType: number - name: asin - comment: Returns the arc sine of x (in radians) + comment: Returns the arc sine of n in radians. parameters: - - name: x + - name: "n" + comment: A number in the range [-1, 1]. type: number returnType: number - name: atan - comment: Returns the arc tangent of x (in radians) + comment: Returns the arc tangent of n in radians. parameters: - - name: x + - name: "n" + comment: A number. type: number returnType: number - name: atan2 - comment: Returns the arc tangent of y/x (in radians), using the signs to determine - the quadrant + comment: Returns the arc tangent of y/x in radians, using the signs to determine + the quadrant. parameters: - - name: y + - name: "y" + comment: The y-coordinate. type: number - name: x + comment: The x-coordinate. type: number returnType: number - name: ceil - comment: Returns the smallest integer larger than or equal to x + comment: Returns the smallest integer larger than or equal to n. parameters: - - name: x + - name: "n" + comment: A number to round up. type: number returnType: number - name: clamp - comment: Returns n clamped between min and max + comment: Returns n clamped between min and max. parameters: - - name: n + - name: "n" + comment: The value to be clamped. type: number - name: min + comment: Minimum allowable value. type: number - name: max + comment: Maximum allowable value. type: number returnType: number - name: cos - comment: Returns the cosine of x (x in radians) + comment: Returns the cosine of n (n is in radians). parameters: - - name: x + - name: "n" + comment: An angle in radians. type: number returnType: number - name: cosh - comment: Returns the hyperbolic cosine of x + comment: Returns the hyperbolic cosine of n. parameters: - - name: x + - name: "n" + comment: A number to compute the hyperbolic cosine of. type: number returnType: number - name: deg - comment: Converts x from radians to degrees + comment: Converts n from radians to degrees. parameters: - - name: x + - name: "n" + comment: A value in radians. type: number returnType: number - name: exp - comment: Returns e^x + comment: Returns the base-e exponent of n. parameters: - - name: x + - name: "n" + comment: A number to compute e^n. type: number returnType: number - name: floor - comment: Returns the largest integer smaller than or equal to x + comment: Returns the largest integer smaller than or equal to n. parameters: - - name: x + - name: "n" + comment: A number to round down. type: number returnType: number - name: fmod - comment: Returns the remainder of x/y that rounds towards zero + comment: Returns the remainder of x modulo y, rounded towards zero. parameters: - name: x + comment: The dividend. type: number - - name: y + - name: "y" + comment: The divisor. type: number returnType: number - name: frexp - comment: Returns m and e such that x = m * 2^e + comment: Returns m and e such that n = m * 2^e. parameters: - - name: x + - name: "n" + comment: A number to split into significand and exponent. type: number returnType: (number, number) - name: ldexp - comment: Returns m * 2^e + comment: Returns s * 2^e. parameters: - - name: m + - name: s + comment: The significand. type: number - name: e + comment: The exponent. type: number returnType: number - name: lerp - comment: Linear interpolation between a and b by t + comment: Linearly interpolates between a and b using factor t. parameters: - name: a + comment: Start value. type: number - name: b + comment: End value. type: number - name: t + comment: Interpolation factor. type: number returnType: number - name: log - comment: Returns the logarithm of x in the given base (default e) + comment: Returns the logarithm of n in the given base (default e). parameters: - - name: x + - name: "n" + comment: A number to compute logarithm. type: number - name: base + comment: Base of the logarithm (default is e). type: number? returnType: number - name: log10 - comment: Returns the base-10 logarithm of x + comment: Returns the base-10 logarithm of n. parameters: - - name: x + - name: "n" + comment: A number to compute base-10 logarithm. type: number returnType: number - name: map - comment: Maps x from input range to output range + comment: Maps n from input range to output range. parameters: - - name: x + - name: "n" + comment: A number. type: number - name: inMin + comment: A number. type: number - name: inMax + comment: A number. type: number - name: outMin + comment: A number. type: number - name: outMax + comment: A number. type: number returnType: number - name: max - comment: Returns the maximum value among the arguments + comment: Returns the maximum value in the given list. parameters: - - name: x + - name: "n" + comment: A number. type: number - name: ... + comment: A list of numbers to find the maximum from. type: ...number returnType: number - name: min - comment: Returns the minimum value among the arguments + comment: Returns the minimum value in the given list. parameters: - - name: x + - name: "n" + comment: A number. type: number - name: ... + comment: A list of numbers to find the minimum from. type: ...number returnType: number - name: modf - comment: Returns the integer and fractional parts of x + comment: Returns the integer and fractional parts of n. parameters: - - name: x + - name: "n" + comment: A number to split into integer and fractional parts. type: number returnType: (number, number) - name: noise - comment: Returns Perlin noise value for the given coordinates + comment: Returns Perlin noise value for the point (x, y, z). parameters: - name: x + comment: X coordinate for the noise function. type: number - - name: y + - name: "y" + comment: Y coordinate for the noise function (default is 0). type: number? - name: z + comment: Z coordinate for the noise function (default is 0). type: number? returnType: number - name: pow - comment: Returns base^exponent + comment: Returns base to the power of exponent. parameters: - name: base + comment: Base value. type: number - name: exponent + comment: Exponent value. type: number returnType: number - name: rad - comment: Converts x from degrees to radians + comment: Converts n from degrees to radians. parameters: - - name: x + - name: "n" + comment: A value in degrees. type: number returnType: number - name: random - comment: Returns a pseudo-random number + comment: Returns a random number within the given range. parameters: - - name: m + - name: min + comment: Minimum value of the range (optional). type: number? - - name: n + - name: max + comment: Maximum value of the range (optional). type: number? returnType: number - name: randomseed - comment: Sets the seed for the pseudo-random generator + comment: Sets the seed for the random number generator. parameters: - name: seed + comment: Seed for the random number generator. type: number returnType: () - name: round - comment: Returns x rounded to the nearest integer + comment: Rounds n to the nearest integer. parameters: - - name: x + - name: "n" + comment: A number to round to the nearest integer. type: number returnType: number - name: sign - comment: Returns -1, 0, or 1 depending on the sign of x + comment: Returns -1 if n is negative, 1 if positive, and 0 if zero. parameters: - - name: x + - name: "n" + comment: A number to get the sign of. type: number returnType: number - name: sin - comment: Returns the sine of x (x in radians) + comment: Returns the sine of n (n is in radians). parameters: - - name: x + - name: "n" + comment: An angle in radians. type: number returnType: number - name: sinh - comment: Returns the hyperbolic sine of x + comment: Returns the hyperbolic sine of n. parameters: - - name: x + - name: "n" + comment: A number to compute the hyperbolic sine of. type: number returnType: number - name: sqrt - comment: Returns the square root of x + comment: Returns the square root of n. parameters: - - name: x + - name: "n" + comment: A number to compute the square root of. type: number returnType: number - name: tan - comment: Returns the tangent of x (x in radians) + comment: Returns the tangent of n (n is in radians). parameters: - - name: x + - name: "n" + comment: An angle in radians. type: number returnType: number - name: tanh - comment: Returns the hyperbolic tangent of x + comment: Returns the hyperbolic tangent of n. parameters: - - name: x + - name: "n" + comment: A number to compute the hyperbolic tangent of. type: number returnType: number - name: isnan - comment: Returns true if x is NaN + comment: Returns true if n is NaN. parameters: - - name: x + - name: "n" + comment: A number. type: number returnType: boolean - name: isinf - comment: Returns true if x is infinite + comment: Returns true if n is infinite. parameters: - - name: x + - name: "n" + comment: A number. type: number returnType: boolean - name: isfinite - comment: Returns true if x is finite + comment: Returns true if n is finite. parameters: - - name: x + - name: "n" + comment: A number. type: number returnType: boolean properties: @@ -1321,7 +1376,7 @@ modules: parameters: - name: x type: number - - name: y + - name: "y" type: number - name: z type: number @@ -1334,7 +1389,7 @@ modules: parameters: - name: x type: number - - name: y + - name: "y" type: number - name: z type: number @@ -1786,7 +1841,7 @@ modules: type: any - name: x type: number - - name: y + - name: "y" type: number - name: z type: number? @@ -1797,7 +1852,7 @@ modules: parameters: - name: x type: number - - name: y + - name: "y" type: number - name: z type: number? From 3bdd699de687a9d4a5e47d156e97a11dbee02465 Mon Sep 17 00:00:00 2001 From: tapple Date: Tue, 20 Jan 2026 21:39:24 -0800 Subject: [PATCH 053/102] Merged in os comments from keywords_lua.xml --- slua_definitions.yaml | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/slua_definitions.yaml b/slua_definitions.yaml index 508b3a5..daf3f05 100644 --- a/slua_definitions.yaml +++ b/slua_definitions.yaml @@ -1344,29 +1344,34 @@ modules: comment: Operating system facilities library functions: - name: clock - comment: Returns CPU time used by the program in seconds + comment: Returns a high-precision timestamp in seconds for measuring durations. parameters: [] returnType: number - name: date - comment: Returns a string or table containing date and time + comment: Returns a table or string representation of the time based on the provided format. parameters: - - name: format + - name: s + comment: Optional format string for the date representation. type: string? - - name: time + - name: t + comment: Optional timestamp to format; defaults to the current time. type: number? returnType: (string | OsDateTime)? - name: difftime - comment: Returns the difference in seconds between two times + comment: Returns the difference in seconds between two timestamps. parameters: - - name: t2 + - name: a + comment: First timestamp value. type: number - - name: t1 + - name: b + comment: Second timestamp value. type: number? returnType: number - name: time - comment: Returns the current time or converts a table to time + comment: Returns the current Unix timestamp or the timestamp of the given date. parameters: - - name: time + - name: t + comment: Optional table with date/time fields; returns the corresponding Unix timestamp. type: OsDateTime? returnType: number? - name: quaternion From b49cf891ff59b89e12973a6f971fc66bfe69cb7c Mon Sep 17 00:00:00 2001 From: tapple Date: Wed, 21 Jan 2026 05:51:05 -0800 Subject: [PATCH 054/102] Merged in string comments from keywords_lua.xml --- slua_definitions.yaml | 74 ++++++++++++++++++++++++++++++++----------- 1 file changed, 55 insertions(+), 19 deletions(-) diff --git a/slua_definitions.yaml b/slua_definitions.yaml index daf3f05..3c6fdf9 100644 --- a/slua_definitions.yaml +++ b/slua_definitions.yaml @@ -1464,143 +1464,179 @@ modules: comment: String manipulation library functions: - name: byte - comment: Returns the internal numeric codes of the characters + comment: Returns the numeric code of every byte in the input string within the given range. parameters: - name: s + comment: Input string. type: string - name: i + comment: Starting index (optional). type: number? - name: j + comment: Ending index (optional). type: number? returnType: '...number' - name: char - comment: Returns a string from character codes + comment: Returns a string containing characters for the given byte values. parameters: - name: ... + comment: Byte values to convert to string. type: ...number returnType: string - name: find - comment: Finds first match of pattern in string + comment: Finds the first instance of the pattern in the string. parameters: - name: s + comment: Input string. type: string - name: pattern + comment: Pattern to search for. type: string - name: init + comment: Starting index (optional). type: number? - name: plain + comment: Perform raw search (optional). type: boolean? returnType: (number?, number?, ...string) - name: format - comment: Returns a formatted string + comment: Formats input values into a string using printf-style format specifiers. parameters: - name: formatstring + comment: Format string. type: string - name: ... + comment: Values to format. type: ...any returnType: string - name: gmatch comment: Returns an iterator function for pattern matches parameters: - name: s + comment: Input string. type: string - name: pattern + comment: Pattern to search for. type: string returnType: () -> ...string - name: gsub - comment: Global substitution of pattern matches + comment: Performs pattern-based substitution in a string. parameters: - name: s + comment: Input string. type: string - name: pattern + comment: Pattern to replace. type: string - name: repl + comment: Replacement string, function, or table. type: 'string | { [string]: string } | (...string) -> string' - - name: n + - name: maxn + comment: Maximum replacements (optional). type: number? returnType: (string, number) - name: len - comment: Returns the length of the string + comment: "Returns the number of bytes in the string. Identical to #s" parameters: - name: s + comment: Input string. type: string returnType: number - name: lower - comment: Converts string to lowercase + comment: Returns a lowercase version of the input string. parameters: - name: s + comment: Input string. type: string returnType: string - name: match - comment: Returns captures from pattern match + comment: Finds and returns matches for a pattern in the input string. parameters: - name: s + comment: Input string. type: string - name: pattern + comment: Pattern to match. type: string - name: init + comment: Starting index (optional). type: number? returnType: '...string' - name: pack - comment: Packs values into a binary string + comment: Packs values into a binary string. parameters: - name: fmt + comment: Pack format string. type: string - name: ... + comment: Values to encode. type: ...any returnType: string - name: packsize - comment: Returns the size of a packed string for the given format + comment: Returns the size of a packed string for the given format. parameters: - name: fmt + comment: Pack format string. type: string returnType: number - name: rep - comment: Returns a string repeated n times + comment: Returns the input string repeated a given number of times. parameters: - name: s + comment: Input string. type: string - - name: n + - name: "n" + comment: Number of times to repeat the string. type: number returnType: string - name: reverse - comment: Reverses a string + comment: Returns the input string with bytes in reverse order. parameters: - name: s + comment: Input string. type: string returnType: string - name: split - comment: Splits a string by separator + comment: Splits a string by separator. Returns a list of substrings. parameters: - name: s + comment: Input string. type: string - name: separator + comment: Seperator to split on. Default is "," type: string? returnType: '{string}' - name: sub - comment: Returns a substring + comment: Returns a substring from the given range. parameters: - name: s + comment: Input string. type: string - name: i + comment: Starting index. type: number - name: j + comment: Ending index (optional). type: number? returnType: string - name: unpack - comment: Unpacks values from a binary string + comment: Decodes a binary string using a pack format. parameters: - name: fmt + comment: Pack format string. type: string - name: s + comment: Encoded string. type: string - - name: pos + - name: init + comment: Starting index (optional). type: number? returnType: '...any' - name: upper - comment: Converts string to uppercase + comment: Returns an uppercase version of the input string. parameters: - name: s + comment: Input string. type: string returnType: string - name: table From 7edc20e12df6b31b3fd9790dd7e198b2222822ca Mon Sep 17 00:00:00 2001 From: tapple Date: Wed, 21 Jan 2026 07:55:32 -0800 Subject: [PATCH 055/102] Merged in table comments from keywords_lua.xml --- slua_definitions.yaml | 207 +++++++++++++++++++++++++----------------- 1 file changed, 123 insertions(+), 84 deletions(-) diff --git a/slua_definitions.yaml b/slua_definitions.yaml index 3c6fdf9..8943c50 100644 --- a/slua_definitions.yaml +++ b/slua_definitions.yaml @@ -1603,7 +1603,7 @@ modules: comment: Input string. type: string - name: separator - comment: Seperator to split on. Default is "," + comment: Separator to split on. Default is "," type: string? returnType: '{string}' - name: sub @@ -1643,164 +1643,203 @@ modules: comment: Table manipulation library functions: - name: concat - comment: Concatenates table elements into a string + comment: Joins an array of strings into one string, with an optional separator. parameters: - - name: list - type: '{string}' + - name: a + comment: Array of strings. + type: '{string | number}' - name: sep + comment: Separator string (optional). type: string? - name: i + comment: Starting index (optional). type: number? - name: j + comment: Ending index (optional). type: number? returnType: string - name: foreach - comment: Iterates over table key-value pairs (deprecated) - typeParameters: [T, U] + comment: Iterates over all key-value pairs in the table (deprecated). + typeParameters: [K, V, R] parameters: - name: t - type: '{[T]: U}' + comment: Table to iterate over. + type: '{[K]: V}' - name: f - type: '(key: T, value: T) -> any' - returnType: any? + comment: Function applied to each key-value pair. + type: '(key: K, value: V) -> R?' + returnType: R? - name: foreachi - comment: Iterates over array indices (deprecated) - typeParameters: [T] + comment: Iterates over all index-value pairs in the array (deprecated). + typeParameters: [V, R] parameters: - - name: t - type: '{T}' + - name: a + comment: Array to iterate over. + type: '{V}' - name: f - type: '(index: number, value: T) -> any' - returnType: any? + comment: Function applied to each index-value pair. + type: '(index: number, value: V) -> R?' + returnType: R? - name: getn - comment: 'Returns the length of a table (deprecated, use # operator)' + comment: 'Returns the length of an array (deprecated; use # instead).' parameters: - - name: t + - name: a + comment: Array to check. type: '{any}' returnType: number - name: maxn - comment: Returns the largest positive numeric index + comment: Returns the highest numeric key in the table. parameters: - name: t + comment: Table to check. type: '{any}' returnType: number - name: insert - comment: Inserts an element at the end of a list + comment: Inserts an element at the specified index, + or at the end of the array. overloads: - - comment: Inserts an element at a specific position - typeParameters: [T] + - comment: Inserts an element at the end of a list + typeParameters: [V] parameters: - - name: list - type: '{T}' - - name: pos - type: number + - name: a + comment: Array to insert into. + type: '{V}' - name: value - type: T + comment: Value to insert. + type: V returnType: () - typeParameters: [T] + typeParameters: [V] parameters: - - name: list - type: '{T}' - - name: value - type: T + - name: a + comment: Array to insert into. + type: '{V}' + - name: i + comment: "Index to insert at (default: at the end)." + type: number + - name: v + comment: Value to insert. + type: V returnType: () - name: remove - comment: Removes and returns an element from a list - typeParameters: [T] + comment: Removes and returns the element at the specified index from the array, + or from the end of the array. + typeParameters: [V] parameters: - - name: list - type: '{T}' - - name: pos + - name: a + comment: Array to remove from. + type: '{V}' + - name: i + comment: "Index to remove (default: the last one)." type: number? - returnType: T? + returnType: V? - name: sort - comment: Sorts list elements in place - typeParameters: [T] + comment: Sorts an array in place. + typeParameters: [V] parameters: - - name: list - type: '{T}' - - name: comp - type: '((a: T, b: T) -> boolean)?' + - name: a + comment: Array to be sorted. + type: '{V}' + - name: f + comment: Comparison function. + type: '((a: V, b: V) -> boolean)?' returnType: () - name: pack - comment: Packs arguments into a table with length field n - typeParameters: [T] + comment: Packs multiple arguments into a new array with length field n. + typeParameters: [V] parameters: - name: ... - type: ...T - returnType: '{ n: number, [number]: T }' + comment: Array elements. + type: ...V + returnType: '{ n: number, [number]: V }' - name: unpack - comment: Unpacks table elements as multiple return values - typeParameters: [T] + comment: Unpacks array elements into multiple return values. + typeParameters: [V] parameters: - - name: list - type: '{T}' + - name: a + comment: Array to unpack. + type: '{V}' - name: i + comment: Starting index (optional). type: number? - name: j + comment: Ending index (optional). type: number? - returnType: '...T' + returnType: '...V' - name: move - comment: Moves elements from one table to another - typeParameters: [T] + comment: Inserts elements [i..j] from src array into dest array at [d]. + typeParameters: [V] parameters: - - name: a1 - type: '{T}' - - name: f + - name: src + comment: Source array. + type: '{V}' + - name: i + comment: Starting index. type: number - - name: e + - name: j + comment: Ending index. type: number - - name: t + - name: d + comment: Destination index. type: number - - name: a2 - type: '{T}?' - returnType: '{T}' + - name: dest + comment: Destination array (optional). + type: '{V}?' + returnType: '{V}' - name: create - comment: Creates a new table with pre-allocated array slots - typeParameters: [T] + comment: Creates a new table with pre-allocated array capacity, optionally filled. + typeParameters: [V] parameters: - - name: count + - name: "n" + comment: Number of elements to allocate. type: number - - name: value - type: T? - returnType: '{T}' + - name: v + comment: Value to prefill elements with (optional). + type: V? + returnType: '{V}' - name: find - comment: Finds the index of a value in an array - typeParameters: [T] + comment: Finds the first occurrence of a value in the array and returns its index. + typeParameters: [V] parameters: - name: t - type: '{T}' - - name: value - type: T - - name: init + comment: Table to search in. + type: '{V}' + - name: v + comment: Value to search for. + type: V + - name: i + comment: Starting index (optional). type: number? returnType: number? - name: clear - comment: Removes all elements from a table + comment: Clears all elements from a table while keeping its capacity. parameters: - name: t + comment: Table to clear. type: '{[any]: any}' returnType: () - name: freeze - comment: Makes a table read-only - typeParameters: [T, U] + comment: Freezes a table, making it read-only. + typeParameters: [K, V] parameters: - name: t - type: '{[T]: U}' - returnType: '{[T]: U}' + comment: Table to freeze. + type: '{[K]: V}' + returnType: '{[K]: V}' - name: isfrozen - comment: Returns true if a table is frozen + comment: Returns true if a table is frozen. parameters: - name: t + comment: Table to check. type: '{[any]: any}' returnType: boolean - name: clone - comment: Creates a shallow copy of a table - typeParameters: [T, U] + comment: Creates a shallow copy of the table. + typeParameters: [K, V] parameters: - name: t - type: '{[T]: U}' - returnType: '{[T]: U}' + comment: Table to clone. + type: '{[K]: V}' + returnType: '{[K]: V}' - name: utf8 comment: UTF-8 support library functions: From 3ac7f9fdf3cf7d941aa17489c27df5e21f716c75 Mon Sep 17 00:00:00 2001 From: tapple Date: Wed, 21 Jan 2026 08:42:01 -0800 Subject: [PATCH 056/102] Merged in utf8 comments from keywords_lua.xml --- slua_definitions.yaml | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/slua_definitions.yaml b/slua_definitions.yaml index 8943c50..e364d54 100644 --- a/slua_definitions.yaml +++ b/slua_definitions.yaml @@ -1844,46 +1844,58 @@ modules: comment: UTF-8 support library functions: - name: char - comment: Returns a string from UTF-8 codepoints + comment: Creates a string from Unicode codepoints. parameters: - name: ... + comment: Unicode codepoints. type: ...number returnType: string - name: codes - comment: Returns an iterator for UTF-8 codepoints in a string + comment: Returns an iterator that produces + the byte offset and Unicode codepoint for each character in the string. parameters: - name: s + comment: Input string. type: string returnType: ((string, number) -> (number, number), string, number) - name: codepoint - comment: Returns the codepoints of characters in a string + comment: Returns the Unicode codepoints in the specified range of the string. parameters: - name: s + comment: Input string. type: string - name: i + comment: Starting index (optional). type: number? - name: j + comment: Ending index (optional). type: number? returnType: '...number' - name: len - comment: Returns the number of UTF-8 characters in a string, or nil and error - position + comment: Returns the number of Unicode codepoints in the specified range of the string, + or nil and error index. parameters: - name: s + comment: Input string. type: string - name: i + comment: Starting index (optional). type: number? - name: j + comment: Ending index (optional). type: number? returnType: (number?, number?) - name: offset - comment: Returns the byte position of the n-th character + comment: Returns the byte offset of the nth Unicode codepoint in the string. parameters: - name: s + comment: Input string. type: string - name: n + comment: Character position. type: number - name: i + comment: Starting index (optional). type: number? returnType: number? properties: From 034f51169b5cc4f96466973ce2d11efdb05e5384 Mon Sep 17 00:00:00 2001 From: tapple Date: Wed, 21 Jan 2026 09:38:51 -0800 Subject: [PATCH 057/102] Merged in vector comments from keywords_lua.xml --- slua_definitions.yaml | 76 +++++++++++++++++++++++++++++-------------- 1 file changed, 52 insertions(+), 24 deletions(-) diff --git a/slua_definitions.yaml b/slua_definitions.yaml index e364d54..7f108f1 100644 --- a/slua_definitions.yaml +++ b/slua_definitions.yaml @@ -1188,23 +1188,23 @@ modules: type: number returnType: number - name: max - comment: Returns the maximum value in the given list. + comment: Returns the maximum value from the given numbers. parameters: - name: "n" comment: A number. type: number - name: ... - comment: A list of numbers to find the maximum from. + comment: Numbers to find the maximum from. type: ...number returnType: number - name: min - comment: Returns the minimum value in the given list. + comment: Returns the minimum value from the given numbers. parameters: - name: "n" comment: A number. type: number - name: ... - comment: A list of numbers to find the minimum from. + comment: Numbers to find the minimum from. type: ...number returnType: number - name: modf @@ -1927,134 +1927,162 @@ modules: comment: Global 'vector' library table callable: name: vector - comment: 'Constructor call: vector(x, y, z)' + comment: Creates a new vector with the given component values. + Alias of vector.create. parameters: - - name: self - type: any - name: x + comment: X component of the vector. type: number - name: "y" + comment: Y component of the vector. type: number - name: z + comment: Z component of the vector (optional). type: number? returnType: vector functions: - name: create - comment: Creates a new vector with the given component values + comment: Creates a new vector with the given component values. parameters: - name: x + comment: X component of the vector. type: number - name: "y" + comment: Y component of the vector. type: number - name: z + comment: Z component of the vector (optional). type: number? returnType: vector - name: magnitude - comment: Calculates the magnitude of a given vector + comment: Computes the magnitude of the vector. parameters: - name: v + comment: Input vector. type: vector returnType: number - name: normalize - comment: Computes the normalized version (unit vector) of a given vector + comment: Computes the normalized version (unit vector) of the vector. parameters: - name: v + comment: Input vector. type: vector returnType: vector - name: cross - comment: Computes the cross product of two vectors + comment: Computes the cross product of two vectors. parameters: - name: a + comment: Left input vector. type: vector - name: b + comment: Right input vector. type: vector returnType: vector - name: dot - comment: Computes the dot product of two vectors + comment: Computes the dot product of two vectors. parameters: - name: a + comment: Left input vector. type: vector - name: b + comment: Right input vector. type: vector returnType: number - name: angle - comment: Computes the angle between two vectors in radians. The axis, if specified, - is used to determine the sign of the angle. + comment: Computes the angle between two vectors in radians. + The axis, if specified, is used to determine the sign of the angle. parameters: - name: a type: vector + comment: Left input vector. - name: b + comment: Right input vector. type: vector - name: axis + comment: Axis to determine the sign of the angle (optional). type: vector? returnType: number - name: floor - comment: Applies math.floor to every component of the input vector + comment: Applies math.floor to each component of the vector. parameters: - name: v + comment: Input vector. type: vector returnType: vector - name: ceil - comment: Applies math.ceil to every component of the input vector + comment: Applies math.ceil to each component of the vector. parameters: - name: v + comment: Input vector. type: vector returnType: vector - name: abs - comment: Applies math.abs to every component of the input vector + comment: Applies math.abs to each component of the vector. parameters: - name: v + comment: Input vector. type: vector returnType: vector - name: sign - comment: Applies math.sign to every component of the input vector + comment: Applies math.sign to each component of the vector. parameters: - name: v + comment: Input vector. type: vector returnType: vector - name: clamp - comment: Applies math.clamp to every component of the input vector + comment: Clamps each component of the vector between min and max values. parameters: - name: v + comment: Input vector to be clamped. type: vector - name: min + comment: Minimum vector value. type: vector - name: max + comment: Maximum vector value. type: vector returnType: vector - name: max - comment: Applies math.max to the corresponding components of the input vectors + comment: Applies math.max to each component of the vectors. parameters: - name: v + comment: Input vector. type: vector - name: ... + comment: Vectors to find the maximum from. type: ...vector returnType: vector - name: min - comment: Applies math.min to the corresponding components of the input vectors + comment: Applies math.max to each component of the vectors. parameters: - name: v + comment: Input vector. type: vector - name: ... + comment: Vectors to find the minimum from. type: ...vector returnType: vector - name: lerp - comment: Linear interpolation between two vectors + comment: Linearly interpolates between a and b using factor t. parameters: - name: a + comment: Start vector. type: vector - name: b + comment: End vector. type: vector - name: t + comment: Interpolation factor. type: number returnType: vector properties: - name: zero - comment: A zero vector + comment: Constant vector with all components set to 0. type: vector value: <0,0,0> - name: one - comment: A one vector + comment: Constant vector with all components set to 1. type: vector value: <1,1,1> constants: [] From 7240e78588953400bcdc743e5fe2818a70b07d14 Mon Sep 17 00:00:00 2001 From: tapple Date: Wed, 21 Jan 2026 10:07:45 -0800 Subject: [PATCH 058/102] generate a header for ll library --- gen_definitions.py | 4 ++++ slua_definitions.yaml | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/gen_definitions.py b/gen_definitions.py index db6e882..c4a1fa8 100644 --- a/gen_definitions.py +++ b/gen_definitions.py @@ -1020,6 +1020,7 @@ def dump_slua_syntax(lsl_definitions: LSLDefinitions, slua_definitions_file: str """Write a syntax file for use by viewers""" parser = SLuaDefinitionParser() slua_definitions = parser.parse_file(slua_definitions_file) + ll_module = [m for m in slua_definitions.modules if m.name == "ll"][0] syntax = { "controls": slua_definitions.controls.copy(), "types": slua_definitions.builtinTypes.copy(), @@ -1047,7 +1048,10 @@ def dump_slua_syntax(lsl_definitions: LSLDefinitions, slua_definitions_file: str for func in sorted(slua_definitions.globalFunctions, key=lambda x: x.name): syntax["functions"][func.name] = func.to_keywords_dict() for module in sorted(slua_definitions.modules, key=lambda x: x.name): + if module.name in {"ll", "llcompat"}: + continue syntax["functions"].update(module.to_keywords_functions_dict()) + syntax["functions"].update(ll_module.to_keywords_functions_dict()) for func in sorted(lsl_definitions.functions.values(), key=lambda x: x.name): if func.private: continue diff --git a/slua_definitions.yaml b/slua_definitions.yaml index 7f108f1..54bd1f1 100644 --- a/slua_definitions.yaml +++ b/slua_definitions.yaml @@ -2085,6 +2085,12 @@ modules: comment: Constant vector with all components set to 1. type: vector value: <1,1,1> +- name: ll + # auto-generated from lsl_definitions.yaml + comment: Library for functions shared between LSL and SLua +- name: llcompat + # auto-generated from lsl_definitions.yaml + comment: Like ll, but exactly matches LSL semantics constants: [] # Everything below here is only for keywords.xml generation, not typechecking From 67a780ee7abf84c4a70c782c534f91406b4348c8 Mon Sep 17 00:00:00 2001 From: tapple Date: Wed, 21 Jan 2026 11:44:45 -0800 Subject: [PATCH 059/102] the "events" schema wasn't actually validating anything. now it is --- lsl_definitions.schema.json | 157 +++++++++++++++++++----------------- 1 file changed, 81 insertions(+), 76 deletions(-) diff --git a/lsl_definitions.schema.json b/lsl_definitions.schema.json index 6a8d638..aca523b 100644 --- a/lsl_definitions.schema.json +++ b/lsl_definitions.schema.json @@ -140,89 +140,94 @@ "type": "object" }, "events": { - "properties": { - "arguments": { - "items": { - "additionalProperties": false, - "patternProperties": { - "^(?:[a-z]+(?:_[a-z]+)*)$": { - "properties": { - "tooltip": { - "markdownDescription": "A brief description of this event argument.", - "type": "string" - }, - "type": { - "defaultSnippets": [ - { - "label": "float", - "body": "float" - }, - { - "label": "integer", - "body": "integer" - }, - { - "label": "key", - "body": "key" - }, - { - "label": "list", - "body": "list" - }, - { - "label": "quaternion", - "body": "quaternion" - }, - { - "label": "rotation", - "body": "rotation" - }, - { - "label": "string", - "body": "string" + "patternProperties": { + "^[a-z_]+$": { + "additionalProperties": false, + "properties": { + "arguments": { + "items": { + "additionalProperties": false, + "patternProperties": { + "^(?:[A-Za-z]+(?:_[A-Za-z]+)*)$": { + "properties": { + "tooltip": { + "markdownDescription": "A brief description of this event argument.", + "type": "string" }, - { - "label": "vector", - "body": "vector" + "type": { + "defaultSnippets": [ + { + "label": "float", + "body": "float" + }, + { + "label": "integer", + "body": "integer" + }, + { + "label": "key", + "body": "key" + }, + { + "label": "list", + "body": "list" + }, + { + "label": "quaternion", + "body": "quaternion" + }, + { + "label": "rotation", + "body": "rotation" + }, + { + "label": "string", + "body": "string" + }, + { + "label": "vector", + "body": "vector" + } + ], + "markdownDescription": "One of the valid types for this event argument: [float, integer, key, list, rotation, string, vector].", + "oneOf": [ + { "const": "float" }, + { "const": "integer" }, + { "const": "key" }, + { "const": "list" }, + { + "$comment": "quaternion is an alias for rotation", + "const": "quaternion" + }, + { "const": "rotation" }, + { "const": "string" }, + { "const": "vector" } + ] } + }, + "required": [ + "type" ], - "markdownDescription": "One of the valid types for this event argument: [float, integer, key, list, rotation, string, vector].", - "oneOf": [ - { "const": "float" }, - { "const": "integer" }, - { "const": "key" }, - { "const": "list" }, - { - "$comment": "quaternion is an alias for rotation", - "const": "quaternion" - }, - { "const": "rotation" }, - { "const": "string" }, - { "const": "vector" } - ] + "type": "object" } }, - "required": [ - "type" - ], "type": "object" - } + }, + "markdownDescription": "An array of event arguments.", + "minItems": 0, + "type": "array", + "uniqueItems": true }, - "type": "object" - }, - "markdownDescription": "An array of event arguments.", - "minItems": 1, - "type": "array", - "uniqueItems": true - }, - "deprecated": { - "const": true, - "markdownDescription": "This event has been deprecated.", - "type": "boolean" - }, - "tooltip": { - "markdownDescription": "A brief description of this event.", - "type": "string" + "deprecated": { + "const": true, + "markdownDescription": "This event has been deprecated.", + "type": "boolean" + }, + "tooltip": { + "markdownDescription": "A brief description of this event.", + "type": "string" + } + } } }, "required": [], From a22727fe363df16f45baf2bbcd1a488b4fa3f85e Mon Sep 17 00:00:00 2001 From: tapple Date: Wed, 21 Jan 2026 11:47:17 -0800 Subject: [PATCH 060/102] fix schema errors now that events is actually being validated --- lsl_definitions.yaml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lsl_definitions.yaml b/lsl_definitions.yaml index a0cdbb9..be1913c 100644 --- a/lsl_definitions.yaml +++ b/lsl_definitions.yaml @@ -4659,21 +4659,21 @@ events: tooltip: This event is triggered when a resident has given an amount of Linden dollars to the object. moving_end: - arguments: null + arguments: [] tooltip: Triggered whenever an object with this script stops moving. moving_start: - arguments: null + arguments: [] tooltip: Triggered whenever an object with this script starts moving. no_sensor: - arguments: null + arguments: [] tooltip: This event is raised when sensors are active, via the llSensor function call, but are not sensing anything. not_at_rot_target: - arguments: null + arguments: [] tooltip: When a target is set via the llRotTarget function call, but the script is outside the specified angle this event is raised. not_at_target: - arguments: null + arguments: [] tooltip: When a target is set via the llTarget library call, but the script is outside the specified range this event is raised. object_rez: @@ -4755,15 +4755,15 @@ events: \ to the script in the parameter. Information on those objects may be gathered\ \ via the llDetected* functions." state_entry: - arguments: null + arguments: [] tooltip: The state_entry event occurs whenever a new state is entered, including at program start, and is always the first event handled. state_exit: - arguments: null + arguments: [] tooltip: The state_exit event occurs whenever the state command is used to transition to another state. It is handled before the new states state_entry event. timer: - arguments: null + arguments: [] tooltip: This event is raised at regular intervals set by the llSetTimerEvent library function. touch: From 849a604c8e106ca7e041a94f31af708f00f31a06 Mon Sep 17 00:00:00 2001 From: tapple Date: Wed, 21 Jan 2026 12:19:30 -0800 Subject: [PATCH 061/102] fixed slua detected events and state_entry/exit --- gen_definitions.py | 35 ++++++++++++++++++++++++++--------- lsl_definitions.schema.json | 12 +++++++++++- lsl_definitions.yaml | 11 +++++++++++ 3 files changed, 48 insertions(+), 10 deletions(-) diff --git a/gen_definitions.py b/gen_definitions.py index c4a1fa8..8e5e1c2 100644 --- a/gen_definitions.py +++ b/gen_definitions.py @@ -207,6 +207,8 @@ class LSLEvent: tooltip: str private: bool deprecated: bool + slua_removed: bool + detected_semantics: bool def to_dict(self) -> dict: return _remove_worthless( @@ -227,18 +229,29 @@ def to_dict(self) -> dict: def to_slua_dict(self, slua: "SLuaDefinitionParser") -> dict: try: + if self.detected_semantics: + arguments = [ + { + "detected": { + "tooltip": "Array of detected events.", + "type": slua.validate_type("{LLDetectedEvent}"), + } + } + ] + else: + arguments = [ + { + a.name: { + "tooltip": a.tooltip, + "type": slua.validate_type(a.compute_slua_type()), + } + } + for a in self.arguments + ] return _remove_worthless( { "deprecated": self.deprecated, - "arguments": [ - { - a.name: { - "tooltip": a.tooltip, - "type": slua.validate_type(a.compute_slua_type()), - } - } - for a in self.arguments - ], + "arguments": arguments, "tooltip": self.tooltip, } ) @@ -621,6 +634,8 @@ def _handle_event(self, event_name: str, event_data: dict) -> LSLEvent: ], private=event_data.get("private", False), deprecated=event_data.get("deprecated", False), + slua_removed=event_data.get("slua-removed", False), + detected_semantics=event_data.get("detected-semantics", False), ) if event.name in self._definitions.events: @@ -1040,6 +1055,8 @@ def dump_slua_syntax(lsl_definitions: LSLDefinitions, slua_definitions_file: str # events for event in sorted(lsl_definitions.events.values(), key=lambda x: x.name): + if event.slua_removed: + continue syntax["events"][event.name] = event.to_slua_dict(parser) # functions diff --git a/lsl_definitions.schema.json b/lsl_definitions.schema.json index aca523b..8b99f09 100644 --- a/lsl_definitions.schema.json +++ b/lsl_definitions.schema.json @@ -140,6 +140,7 @@ "type": "object" }, "events": { + "additionalProperties": false, "patternProperties": { "^[a-z_]+$": { "additionalProperties": false, @@ -218,11 +219,21 @@ "type": "array", "uniqueItems": true }, + "detected-semantics": { + "const": true, + "markdownDescription": "Uses llDetected* in LSL and {LLDetectedEvent} in SLua.", + "type": "boolean" + }, "deprecated": { "const": true, "markdownDescription": "This event has been deprecated.", "type": "boolean" }, + "slua-removed": { + "const": true, + "markdownDescription": "This event has been removed in SLua.", + "type": "boolean" + }, "tooltip": { "markdownDescription": "A brief description of this event.", "type": "string" @@ -230,7 +241,6 @@ } } }, - "required": [], "type": "object" }, "functions": { diff --git a/lsl_definitions.yaml b/lsl_definitions.yaml index be1913c..c940a2a 100644 --- a/lsl_definitions.yaml +++ b/lsl_definitions.yaml @@ -4448,6 +4448,7 @@ events: - NumberOfCollisions: tooltip: '' type: integer + detected-semantics: true tooltip: "This event is raised while another object, or avatar, is colliding with\ \ the object the script is attached to.\n\t\t\tThe number of detected objects\ \ is passed to the script. Information on those objects may be gathered via\ @@ -4457,6 +4458,7 @@ events: - NumberOfCollisions: tooltip: '' type: integer + detected-semantics: true tooltip: "This event is raised when another object, or avatar, stops colliding\ \ with the object the script is attached to.\n\t\t\tThe number of detected objects\ \ is passed to the script. Information on those objects may be gathered via\ @@ -4466,6 +4468,7 @@ events: - NumberOfCollisions: tooltip: '' type: integer + detected-semantics: true tooltip: "This event is raised when another object, or avatar, starts colliding\ \ with the object the script is attached to.\n\t\t\tThe number of detected objects\ \ is passed to the script. Information on those objects may be gathered via\ @@ -4536,6 +4539,7 @@ events: - count: tooltip: The number of damage events queued. type: integer + detected-semantics: true tooltip: Triggered as damage is applied to an avatar or task, after all on_damage events have been processed. game_control: @@ -4689,6 +4693,7 @@ events: - count: tooltip: The number of damage events queued. type: integer + detected-semantics: true tooltip: Triggered when an avatar or object receives damage. on_death: arguments: [] @@ -4750,6 +4755,7 @@ events: - NumberDetected: tooltip: '' type: integer + detected-semantics: true tooltip: "This event is raised whenever objects matching the constraints of the\ \ llSensor command are detected.\n\t\t\tThe number of detected objects is passed\ \ to the script in the parameter. Information on those objects may be gathered\ @@ -4758,8 +4764,10 @@ events: arguments: [] tooltip: The state_entry event occurs whenever a new state is entered, including at program start, and is always the first event handled. + slua-removed: true state_exit: arguments: [] + slua-removed: true tooltip: The state_exit event occurs whenever the state command is used to transition to another state. It is handled before the new states state_entry event. timer: @@ -4771,6 +4779,7 @@ events: - NumberOfTouches: tooltip: '' type: integer + detected-semantics: true tooltip: "This event is raised while a user is touching the object the script\ \ is attached to.\n\t\t\tThe number of touching objects is passed to the script\ \ in the parameter.\n\t\t\tInformation on those objects may be gathered via\ @@ -4780,6 +4789,7 @@ events: - NumberOfTouches: tooltip: '' type: integer + detected-semantics: true tooltip: "This event is raised when a user stops touching the object the script\ \ is attached to. The number of touches is passed to the script in the parameter.\n\ \t\t\tInformation on those objects may be gathered via the llDetected* library\ @@ -4789,6 +4799,7 @@ events: - NumberOfTouches: tooltip: '' type: integer + detected-semantics: true tooltip: "This event is raised when a user first touches the object the script\ \ is attached to. The number of touches is passed to the script in the parameter.\n\ \t\t\tInformation on those objects may be gathered via the llDetected() library\ From e370d5ecd3a1648679dffe60b038deef09f216fa Mon Sep 17 00:00:00 2001 From: tapple Date: Wed, 21 Jan 2026 13:11:06 -0800 Subject: [PATCH 062/102] wrote an entry for table.shrink --- slua_definitions.yaml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/slua_definitions.yaml b/slua_definitions.yaml index 54bd1f1..fd89cb1 100644 --- a/slua_definitions.yaml +++ b/slua_definitions.yaml @@ -1817,6 +1817,17 @@ modules: comment: Table to clear. type: '{[any]: any}' returnType: () + - name: shrink + comment: Reduces the memory usage of the table to the minimum necessary. + typeParameters: [K, V] + parameters: + - name: t + comment: Table to shrink. + type: '{[K]: V}' + - name: reorder + comment: Allow moving sparse array elements to hash table storage. + type: boolean? + returnType: '{[K]: V}' - name: freeze comment: Freezes a table, making it read-only. typeParameters: [K, V] From 7741ff2d503d6d06bd09fad79a49e25798223291 Mon Sep 17 00:00:00 2001 From: tapple Date: Wed, 21 Jan 2026 13:28:15 -0800 Subject: [PATCH 063/102] Improved the quaternion comments based on the vector comments --- slua_definitions.yaml | 42 +++++++++++++++++++++++++++++++----------- 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/slua_definitions.yaml b/slua_definitions.yaml index fd89cb1..20e9b14 100644 --- a/slua_definitions.yaml +++ b/slua_definitions.yaml @@ -1375,89 +1375,109 @@ modules: type: OsDateTime? returnType: number? - name: quaternion - comment: Global 'quaternion' library table with callable metatable + comment: Creates a new quaternion with the given component values. + Alias of quaternion.create. callable: name: quaternion parameters: - name: x + comment: X component of the quaternion. type: number - name: "y" + comment: Y component of the quaternion. type: number - name: z + comment: Z component of the quaternion. type: number - name: s + comment: S component of the quaternion. type: number returnType: quaternion functions: - name: create - comment: Constructor + comment: Creates a new quaternion with the given component values. parameters: - name: x + comment: X component of the quaternion. type: number - name: "y" + comment: Y component of the quaternion. type: number - name: z + comment: Z component of the quaternion. type: number - name: s + comment: S component of the quaternion. type: number returnType: quaternion - name: normalize - comment: Returns normalized quaternion + comment: Computes the normalized version (unit quaternion) of the quaternion. parameters: - name: q + comment: Input quaternion. type: quaternion returnType: quaternion - name: magnitude - comment: Returns magnitude of quaternion + comment: Computes the magnitude of the quaternion. parameters: - name: q + comment: Input quaternion. type: quaternion returnType: number - name: dot - comment: Dot product of two quaternions + comment: Computes the dot product of two quaternions. parameters: - name: a + comment: Left input quaternion. type: quaternion - name: b + comment: Right input quaternion. type: quaternion returnType: number - name: slerp - comment: Spherical linear interpolation + comment: Spherical linear interpolation from a to b using factor t. parameters: - name: a + comment: Start quaternion. type: quaternion - name: b + comment: End quaternion. type: quaternion - name: t + comment: Interpolation factor. type: number returnType: quaternion - name: conjugate - comment: Returns conjugate of quaternion + comment: Computes the conjugate of the quaternion. parameters: - name: q + comment: Input quaternion. type: quaternion returnType: quaternion - name: tofwd - comment: Returns forward vector from quaternion rotation + comment: Computes the forward vector from the quaternion. parameters: - name: q + comment: Input quaternion. type: quaternion returnType: vector - name: toleft - comment: Returns left vector from quaternion rotation + comment: Computes the left vector from the quaternion. parameters: - name: q + comment: Input quaternion. type: quaternion returnType: vector - name: toup - comment: Returns up vector from quaternion rotation + comment: Computes the up vector from the quaternion. parameters: - name: q + comment: Input quaternion. type: quaternion returnType: vector properties: - name: identity - comment: Identity quaternion constant + comment: Identity quaternion constant. type: quaternion value: <0, 0, 0, 1> - name: string From ae5ca3f8b0e77d7d49e75b6b86d5a3387763c041 Mon Sep 17 00:00:00 2001 From: tapple Date: Wed, 21 Jan 2026 13:34:22 -0800 Subject: [PATCH 064/102] a few small comment improvements in vector, quaternion, uuid --- slua_definitions.yaml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/slua_definitions.yaml b/slua_definitions.yaml index 20e9b14..936fc6f 100644 --- a/slua_definitions.yaml +++ b/slua_definitions.yaml @@ -1375,10 +1375,11 @@ modules: type: OsDateTime? returnType: number? - name: quaternion - comment: Creates a new quaternion with the given component values. - Alias of quaternion.create. + comment: Quaternion manipulation library callable: name: quaternion + comment: Creates a new quaternion with the given component values. + Alias of quaternion.create. parameters: - name: x comment: X component of the quaternion. @@ -1935,13 +1936,13 @@ modules: type: string value: "[\\x00-\\x7F\\xC2-\\xF4][\\x80-\\xBF]*" - name: uuid - comment: Global 'uuid' library table + comment: uuid library callable: name: uuid - comment: Allows calling uuid() as a constructor + comment: Creates a new uuid from a string, buffer, or existing uuid. Returns + nil if the string is not a valid UUID. Throws an error if the buffer is + shorter than 16 bytes. Alias of uuid.create parameters: - - name: self - type: any - name: value type: string | buffer | uuid returnType: uuid? @@ -1955,7 +1956,7 @@ modules: type: string | buffer | uuid returnType: uuid? - name: vector - comment: Global 'vector' library table + comment: Vector manipulation library callable: name: vector comment: Creates a new vector with the given component values. From 4e58a5f2880131639b5f95722e5868db86252e4c Mon Sep 17 00:00:00 2001 From: tapple Date: Wed, 21 Jan 2026 14:44:38 -0800 Subject: [PATCH 065/102] convert void -> () in luau --- gen_definitions.py | 2 +- slua_definitions.yaml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gen_definitions.py b/gen_definitions.py index 8e5e1c2..d3841f9 100644 --- a/gen_definitions.py +++ b/gen_definitions.py @@ -69,7 +69,7 @@ class LSLTypeMeta(NamedTuple): library_abbr="", cs_name="void", mono_bind_name="void", - slua_name="void", + slua_name="()", ), LSLType.INTEGER: LSLTypeMeta( cil_name="int32", diff --git a/slua_definitions.yaml b/slua_definitions.yaml index 936fc6f..fff1ba9 100644 --- a/slua_definitions.yaml +++ b/slua_definitions.yaml @@ -2255,7 +2255,7 @@ builtinFunctions: - name: ... comment: Arguments to print to standard output. type: ...any - returnType: void + returnType: () - name: rawequal comment: Returns true if a and b have the same type and value. parameters: @@ -2318,7 +2318,7 @@ builtinFunctions: - name: mt comment: The metatable to set. type: table? - returnType: void + returnType: () - name: tonumber comment: Converts the input string to a number in the specified base. parameters: From 14303046ddca5c9aa25d8772962dd962d4e654ee Mon Sep 17 00:00:00 2001 From: tapple Date: Wed, 21 Jan 2026 15:07:31 -0800 Subject: [PATCH 066/102] convert void -> () in luau --- gen_definitions.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/gen_definitions.py b/gen_definitions.py index d3841f9..857e646 100644 --- a/gen_definitions.py +++ b/gen_definitions.py @@ -369,7 +369,7 @@ def to_slua_dict(self, slua: "SLuaDefinitionParser") -> dict: "deprecated": self.deprecated, "energy": self.energy, "god-mode": self.god_mode, - "return": slua.validate_return_type(self.compute_slua_type(), known_types), + "return": slua.validate_type(self.compute_slua_type(), known_types), "sleep": self.sleep, "tooltip": self.tooltip, } @@ -880,14 +880,14 @@ def _validate_function(self, data: any, scope: Set[str], method: bool = False) - name=data["name"], typeParameters=data.get("typeParameters", []), parameters=[SLuaParameter(**p) for p in data.get("parameters", [])], - returnType=data.get("returnType", "void"), + returnType=data.get("returnType", LSLType.VOID.meta.slua_name), comment=data.get("comment", ""), private=data.get("private", False), ) self._validate_identifier(func.name) self._validate_scope(func.name, scope) known_types = self.validate_type_params(func.typeParameters) - self.validate_return_type(func.returnType, known_types) + self.validate_type(func.returnType, known_types) params = func.parameters params_scope = set() if method: @@ -950,11 +950,6 @@ def validate_type(self, type: str, known_type_names: set[str] | None = None) -> if not unknown_subtypes: return type raise ValueError(f"Unknown types {unknown_subtypes} in definition {type!r}") - - def validate_return_type(self, type: str, known_types: set[str] | None = None) -> str: - if type == LSLType.VOID.meta.slua_name: - return type - return self.validate_type(type, known_types) def _validate_scope(self, name: str, scope: Set[str]) -> None: if name in scope: From 8b1b10be675d3b6194afa3a1dd38cc5984f2963b Mon Sep 17 00:00:00 2001 From: tapple Date: Wed, 21 Jan 2026 15:08:39 -0800 Subject: [PATCH 067/102] spacing --- gen_definitions.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/gen_definitions.py b/gen_definitions.py index 857e646..acbc006 100644 --- a/gen_definitions.py +++ b/gen_definitions.py @@ -425,7 +425,6 @@ def to_keywords_dict(self) -> dict: } - @dataclasses.dataclass class SLuaParameter: """ @@ -446,6 +445,7 @@ class SLuaFunctionOverload: returnType: str comment: Optional[str] = None + @dataclasses.dataclass class SLuaFunctionSignature: """Function or method signature with optional overloads""" @@ -963,7 +963,6 @@ def _validate_identifier(self, name: str) -> None: raise ValueError(f"{name!r} is not a valid identifier") - def _remove_worthless(val: dict) -> dict: """Remove attributes that have the same implied values when not present""" if not val.get("deprecated"): From 88f31c6b41642e3505f8c07a5f0081bbe9a976e8 Mon Sep 17 00:00:00 2001 From: tapple Date: Wed, 21 Jan 2026 15:13:23 -0800 Subject: [PATCH 068/102] pre-commit run -a --- gen_definitions.py | 91 +++++++++++++++++++++++++------------------- lsl_definitions.yaml | 6 +-- 2 files changed, 55 insertions(+), 42 deletions(-) diff --git a/gen_definitions.py b/gen_definitions.py index acbc006..ddeb57f 100644 --- a/gen_definitions.py +++ b/gen_definitions.py @@ -3,7 +3,6 @@ # deciding that this script is Python 2. It is not. import ast -import ctypes import dataclasses import enum import itertools @@ -166,7 +165,7 @@ def to_dict(self) -> dict: "value": _escape_python(self.value), } ) - + def to_slua_dict(self, slua: "SLuaDefinitionParser") -> dict: try: return _remove_worthless( @@ -410,7 +409,8 @@ class LSLFunctionRanges(enum.IntEnum): @dataclasses.dataclass class SLuaProperty: - """ Property definition """ + """Property definition""" + name: str type: str value: str | None = None @@ -420,8 +420,7 @@ def to_keywords_dict(self) -> dict: return { "tooltip": self.comment, "type": self.type, - **({"value": _escape_python(self.value)} - if self.value is not None else {}), + **({"value": _escape_python(self.value)} if self.value is not None else {}), } @@ -433,6 +432,7 @@ class SLuaParameter: - Self parameters only need name (type is implicit) - Variadic parameters need name "..." and type """ + name: str type: Optional[str] = None comment: str = "" @@ -441,6 +441,7 @@ class SLuaParameter: @dataclasses.dataclass class SLuaFunctionOverload: """Function overload signature""" + parameters: List[SLuaParameter] returnType: str comment: Optional[str] = None @@ -449,6 +450,7 @@ class SLuaFunctionOverload: @dataclasses.dataclass class SLuaFunctionSignature: """Function or method signature with optional overloads""" + name: str parameters: List[SLuaParameter] returnType: str @@ -481,6 +483,7 @@ def to_keywords_dict(self) -> dict: @dataclasses.dataclass class SLuaTypeAlias: """Type alias definition""" + name: str definition: str comment: str = "" @@ -492,7 +495,7 @@ def to_keywords_dict(self) -> dict: return { "tooltip": f"{self.comment}\n{definition}".strip(), } - + def to_luau_def(self) -> str: return f"type {self.name} = {self.definition}" @@ -500,18 +503,20 @@ def to_luau_def(self) -> str: @dataclasses.dataclass class SLuaClassDeclaration: """Class declaration with properties and methods""" + name: str properties: List[SLuaProperty] methods: List[SLuaFunctionSignature] comment: str = "" def to_keywords_dict(self) -> dict: - return { "tooltip": self.comment } - + return {"tooltip": self.comment} + @dataclasses.dataclass class SLuaModuleDeclaration: - """ Module declaration with properties and functions """ + """Module declaration with properties and functions""" + name: str callable: Optional[SLuaFunctionSignature] properties: List[SLuaProperty] @@ -522,27 +527,29 @@ def to_keywords_functions_dict(self) -> dict: functions = {} if self.callable: functions[self.name] = self.callable.to_keywords_dict() - else: + else: functions[self.name] = {"energy": -1.0, "tooltip": self.comment} - functions.update({ - f"{self.name}.{func.name}": func.to_keywords_dict() - for func in sorted(self.functions, key=lambda x: x.name) - if not func.private - }) + functions.update( + { + f"{self.name}.{func.name}": func.to_keywords_dict() + for func in sorted(self.functions, key=lambda x: x.name) + if not func.private + } + ) return functions - + def to_keywords_constants_dict(self) -> dict: return { f"{self.name}.{prop.name}": prop.to_keywords_dict() for prop in sorted(self.properties, key=lambda x: x.name) } - + class SLuaDefinitions(NamedTuple): # for best results, load/generate in the same order defined here - + # 1. Luau builtins. Typecheckers already know about these - controls: dict # same structure as LSLDefinitions.controls + controls: dict # same structure as LSLDefinitions.controls builtinTypes: dict # same structure as LSLDefinitions.types builtinConstants: List[SLuaProperty] builtinFunctions: List[SLuaFunctionSignature] @@ -797,26 +804,21 @@ def _parse_dict(self, def_dict: dict) -> SLuaDefinitions: ) # 2. SLua base classes. These only depend on Luau builtins self.definitions.baseClasses.extend( - self._validate_class(class_) - for class_ in def_dict["baseClasses"] + self._validate_class(class_) for class_ in def_dict["baseClasses"] ) self.definitions.typeAliases.extend( - self._validate_type_alias(alias) - for alias in def_dict["typeAliases"] + self._validate_type_alias(alias) for alias in def_dict["typeAliases"] ) # 3. SLua standard library. Depends on base classes self.definitions.classes.extend( - self._validate_class(class_) - for class_ in def_dict["classes"] + self._validate_class(class_) for class_ in def_dict["classes"] ) self.definitions.globalFunctions.extend( - self._validate_function(func, self.global_scope) - for func in def_dict["globalFunctions"] + self._validate_function(func, self.global_scope) for func in def_dict["globalFunctions"] ) self.definitions.modules.extend( - self._validate_module(module) - for module in def_dict["modules"] + self._validate_module(module) for module in def_dict["modules"] ) return self.definitions @@ -863,8 +865,7 @@ def _validate_class(self, data: any) -> SLuaClassDeclaration: self._validate_scope(class_.name, self.type_names) class_scope: Set[str] = set() class_.properties = [ - self._validate_property(prop, class_scope) - for prop in data.get("properties", []) + self._validate_property(prop, class_scope) for prop in data.get("properties", []) ] class_.methods = [ self._validate_function(method, class_scope, method=True) @@ -874,7 +875,9 @@ def _validate_class(self, data: any) -> SLuaClassDeclaration: raise ValueError(f"In class {class_.name}: {e}") from e return class_ - def _validate_function(self, data: any, scope: Set[str], method: bool = False) -> SLuaFunctionSignature: + def _validate_function( + self, data: any, scope: Set[str], method: bool = False + ) -> SLuaFunctionSignature: try: func = SLuaFunctionSignature( name=data["name"], @@ -904,7 +907,7 @@ def _validate_function(self, data: any, scope: Set[str], method: bool = False) - self.validate_type(param.type, known_types) return func except Exception as e: - raise ValueError(f"In function {data["name"]}: {e}") from e + raise ValueError(f"In function {data['name']}: {e}") from e def _validate_type_alias(self, data: any) -> SLuaTypeAlias: alias = SLuaTypeAlias(**data) @@ -936,7 +939,9 @@ def validate_type_params(self, type_params: List[str]) -> set[str]: self._validate_scope(type_param, known_types) return known_types - _TYPE_SEPERATORS_RE = re.compile(r"[ \n?&|,{}\[\]()]|\.\.\.|->|[a-zA-Z0-9_]*:|\"[a-zA-Z0-9_]*\"") + _TYPE_SEPERATORS_RE = re.compile( + r"[ \n?&|,{}\[\]()]|\.\.\.|->|[a-zA-Z0-9_]*:|\"[a-zA-Z0-9_]*\"" + ) def validate_type(self, type: str, known_type_names: set[str] | None = None) -> str: if not type: @@ -946,11 +951,11 @@ def validate_type(self, type: str, known_type_names: set[str] | None = None) -> if type in known_type_names: return type subtypes = self._TYPE_SEPERATORS_RE.split(type) - unknown_subtypes = set(subtypes) - known_type_names - {''} + unknown_subtypes = set(subtypes) - known_type_names - {""} if not unknown_subtypes: return type raise ValueError(f"Unknown types {unknown_subtypes} in definition {type!r}") - + def _validate_scope(self, name: str, scope: Set[str]) -> None: if name in scope: raise ValueError(f"{name!r} is already defined in this scope") @@ -1025,7 +1030,9 @@ def dump_syntax(definitions: LSLDefinitions, pretty: bool = False) -> bytes: return llsd.format_xml(syntax, c_compat=True, sort_maps=True) -def dump_slua_syntax(lsl_definitions: LSLDefinitions, slua_definitions_file: str, pretty: bool = False) -> bytes: +def dump_slua_syntax( + lsl_definitions: LSLDefinitions, slua_definitions_file: str, pretty: bool = False +) -> bytes: """Write a syntax file for use by viewers""" parser = SLuaDefinitionParser() slua_definitions = parser.parse_file(slua_definitions_file) @@ -2509,13 +2516,19 @@ def main(): sub = subparsers.add_parser("syntax") sub.add_argument("filename") sub.add_argument("--pretty", action="store_true", help="Pretty-print the XML output") - sub.set_defaults(func=lambda args, defs: _write_if_different(args.filename, dump_syntax(defs, args.pretty))) + sub.set_defaults( + func=lambda args, defs: _write_if_different(args.filename, dump_syntax(defs, args.pretty)) + ) sub = subparsers.add_parser("slua_syntax") sub.add_argument("slua_definitions", help="Path to the SLua definition yaml") sub.add_argument("filename") sub.add_argument("--pretty", action="store_true", help="Pretty-print the XML output") - sub.set_defaults(func=lambda args, defs: _write_if_different(args.filename, dump_slua_syntax(defs, args.slua_definitions, args.pretty))) + sub.set_defaults( + func=lambda args, defs: _write_if_different( + args.filename, dump_slua_syntax(defs, args.slua_definitions, args.pretty) + ) + ) sub = subparsers.add_parser("gen_constant_lsl_script") sub.set_defaults(func=lambda args, defs: gen_constant_lsl_script(defs)) diff --git a/lsl_definitions.yaml b/lsl_definitions.yaml index c940a2a..fcfad37 100644 --- a/lsl_definitions.yaml +++ b/lsl_definitions.yaml @@ -4823,9 +4823,9 @@ functions: # sleep: Additional sleep time imposed by the script after this function completes. # mono-sleep: Sleep in the mono script runtime # return: Return type of the function. -# slua-return: More specific return type for slua type-checking. -# slua-type: More specific argument type for slua type-checking. -# type-arguments: An array of strings naming the type variables used for generic type-checking this slua function. +# slua-return: More specific return type for slua type-checking. +# slua-type: More specific argument type for slua type-checking. +# type-arguments: An array of strings naming the type variables used for generic type-checking this slua function. # arguments: An array of maps of maps describing the parameters to this function. # tooltip: A brief description of this function. Map of maps is used to retain ordering. # func-id: The LSO function identifier, (See comment at the top of this file.) From 387afa4bd7b3aa09b9090f23af01e8207ee754ef Mon Sep 17 00:00:00 2001 From: tapple Date: Wed, 21 Jan 2026 15:42:15 -0800 Subject: [PATCH 069/102] validate globalVariables --- gen_definitions.py | 13 +++++++++---- slua_definitions.yaml | 9 +++++---- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/gen_definitions.py b/gen_definitions.py index ddeb57f..451c690 100644 --- a/gen_definitions.py +++ b/gen_definitions.py @@ -415,6 +415,7 @@ class SLuaProperty: type: str value: str | None = None comment: str = "" + slua_removed: bool = False def to_keywords_dict(self) -> dict: return { @@ -790,6 +791,8 @@ def _parse_dict(self, def_dict: dict) -> SLuaDefinitions: raise RuntimeError("Already parsed!") # 1. Luau builtins. Typecheckers already know about these + # nil is hardcoded because it should highlight as a constant, not a type + self.type_names.add("nil") self.definitions.builtinTypes.update(def_dict["builtinTypes"]) self.type_names.update(self.definitions.builtinTypes.keys()) self.definitions.controls.update(def_dict["controls"]) @@ -820,6 +823,10 @@ def _parse_dict(self, def_dict: dict) -> SLuaDefinitions: self.definitions.modules.extend( self._validate_module(module) for module in def_dict["modules"] ) + self.definitions.globalVariables.extend( + self._validate_property(const, self.global_scope) + for const in def_dict["globalVariables"] + ) return self.definitions @@ -921,13 +928,11 @@ def _validate_type_alias(self, data: any) -> SLuaTypeAlias: return alias def _validate_property(self, data: any, scope: Set[str], const: bool = False) -> SLuaProperty: - prop = SLuaProperty(**data) + prop = SLuaProperty(slua_removed=data.pop("slua-removed", False), **data) self._validate_identifier(prop.name) self._validate_scope(prop.name, scope) if const and prop.type != "userdata" and prop.value is None: raise ValueError(f"Constant {prop.name} must have a value") - if prop.name == "nil" and prop.type == "nil" and scope is self.global_scope: - return prop # only nil is allowed to be nil self.validate_type(prop.type) return prop @@ -940,7 +945,7 @@ def validate_type_params(self, type_params: List[str]) -> set[str]: return known_types _TYPE_SEPERATORS_RE = re.compile( - r"[ \n?&|,{}\[\]()]|\.\.\.|->|[a-zA-Z0-9_]*:|\"[a-zA-Z0-9_]*\"" + r"[ \n?&|,{}\[\]()]|\.\.\.|typeof|->|[a-zA-Z0-9_]*:|\"[a-zA-Z0-9_]*\"" ) def validate_type(self, type: str, known_type_names: set[str] | None = None) -> str: diff --git a/slua_definitions.yaml b/slua_definitions.yaml index fff1ba9..90baf6c 100644 --- a/slua_definitions.yaml +++ b/slua_definitions.yaml @@ -256,18 +256,19 @@ classes: returnType: boolean globalVariables: - name: rotation - comment: '''rotation'' global is an alias to the ''quaternion'' library' - type: - kind: typeof - target: quaternion + comment: rotation is an alias for quaternion + type: typeof(quaternion) - name: loadstring comment: loadstring is removed in SLua + slua-removed: true type: nil - name: getfenv comment: getfenv is removed in SLua + slua-removed: true type: nil - name: setfenv comment: setfenv is removed in SLua + slua-removed: true type: nil globalFunctions: - name: dangerouslyexecuterequiredmodule From 8bcb57e02a01f1ef2676e2a5f49c2040a67652cf Mon Sep 17 00:00:00 2001 From: tapple Date: Wed, 21 Jan 2026 17:36:58 -0800 Subject: [PATCH 070/102] label the functions/events deprecated in slua, and the wrapped DetectedEvent functions --- gen_definitions.py | 13 ++++++++++--- lsl_definitions.schema.json | 17 ++++++++++++++++- lsl_definitions.yaml | 24 ++++++++++++++++++++++++ slua_definitions.yaml | 5 +++-- 4 files changed, 53 insertions(+), 6 deletions(-) diff --git a/gen_definitions.py b/gen_definitions.py index 451c690..39c1916 100644 --- a/gen_definitions.py +++ b/gen_definitions.py @@ -206,6 +206,7 @@ class LSLEvent: tooltip: str private: bool deprecated: bool + slua_deprecated: bool slua_removed: bool detected_semantics: bool @@ -233,7 +234,7 @@ def to_slua_dict(self, slua: "SLuaDefinitionParser") -> dict: { "detected": { "tooltip": "Array of detected events.", - "type": slua.validate_type("{LLDetectedEvent}"), + "type": slua.validate_type("{DetectedEvent}"), } } ] @@ -249,7 +250,7 @@ def to_slua_dict(self, slua: "SLuaDefinitionParser") -> dict: ] return _remove_worthless( { - "deprecated": self.deprecated, + "deprecated": self.deprecated or self.slua_deprecated, "arguments": arguments, "tooltip": self.tooltip, } @@ -268,6 +269,7 @@ class LSLFunction: god_mode: bool index_semantics: bool bool_semantics: bool + detected_semantics: bool type_arguments: List[str] arguments: List[LSLArgument] tooltip: str @@ -279,6 +281,8 @@ class LSLFunction: implementation to Agni and don't want people to use it yet. """ deprecated: bool + slua_deprecated: bool + """Only exists in llcompat""" func_id: int pure: bool """ @@ -365,7 +369,7 @@ def to_slua_dict(self, slua: "SLuaDefinitionParser") -> dict: } for a in self.arguments ], - "deprecated": self.deprecated, + "deprecated": self.deprecated or self.slua_deprecated, "energy": self.energy, "god-mode": self.god_mode, "return": slua.validate_type(self.compute_slua_type(), known_types), @@ -642,6 +646,7 @@ def _handle_event(self, event_name: str, event_data: dict) -> LSLEvent: ], private=event_data.get("private", False), deprecated=event_data.get("deprecated", False), + slua_deprecated=event_data.get("slua-deprecated", False), slua_removed=event_data.get("slua-removed", False), detected_semantics=event_data.get("detected-semantics", False), ) @@ -672,11 +677,13 @@ def _handle_function(self, func_name: str, func_data: dict) -> LSLFunction: private=func_data.get("private", False), god_mode=func_data.get("god-mode", False), deprecated=func_data.get("deprecated", False), + slua_deprecated=func_data.get("slua-deprecated", False), func_id=func_data["func-id"], pure=func_data.get("pure", False), native=func_data.get("native", False), index_semantics=bool(func_data.get("index-semantics", False)), bool_semantics=bool(func_data.get("bool-semantics", False)), + detected_semantics=bool(func_data.get("detected-semantics", False)), ) if func.name in self._definitions.functions: diff --git a/lsl_definitions.schema.json b/lsl_definitions.schema.json index 8b99f09..02d36b1 100644 --- a/lsl_definitions.schema.json +++ b/lsl_definitions.schema.json @@ -221,7 +221,7 @@ }, "detected-semantics": { "const": true, - "markdownDescription": "Uses llDetected* in LSL and {LLDetectedEvent} in SLua.", + "markdownDescription": "Uses llDetected* in LSL and {DetectedEvent} in SLua.", "type": "boolean" }, "deprecated": { @@ -229,6 +229,11 @@ "markdownDescription": "This event has been deprecated.", "type": "boolean" }, + "slua-deprecated": { + "const": true, + "markdownDescription": "This event has been deprecated in SLua.", + "type": "boolean" + }, "slua-removed": { "const": true, "markdownDescription": "This event has been removed in SLua.", @@ -361,6 +366,16 @@ "markdownDescription": "This function has been deprecated.", "type": "boolean" }, + "detected-semantics": { + "const": true, + "markdownDescription": "This function is wrapped in the DetectedEvent class.", + "type": "boolean" + }, + "slua-deprecated": { + "const": true, + "markdownDescription": "This function only exists in llcompat, not ll.", + "type": "boolean" + }, "energy": { "$ref": "#/definitions/nonNegativeNumber", "markdownDescription": "The script energy consumed by this function." diff --git a/lsl_definitions.yaml b/lsl_definitions.yaml index fcfad37..22dbe6e 100644 --- a/lsl_definitions.yaml +++ b/lsl_definitions.yaml @@ -4772,6 +4772,7 @@ events: to another state. It is handled before the new states state_entry event. timer: arguments: [] + slua-deprecated: true tooltip: This event is raised at regular intervals set by the llSetTimerEvent library function. touch: @@ -4831,6 +4832,7 @@ functions: # func-id: The LSO function identifier, (See comment at the top of this file.) # private: Should this function be omitted from the generated documentation. # deprecated: Has this function been deprecated. +# slua-deprecated: Has this function or event been deprecated in SLua. # pure: Is the function guaranteed to have no side effects. # must-use: If true or `pure` is true, then the functions return value should not be discarded, as it serves no other purpose # native: If true, this function must use a native implementation for non-LSO VMs. @@ -4839,6 +4841,7 @@ functions: # linden-experience: If true, this function requires a linden-owned experience. # index-semantics: If true then the returned integer from this function represents 0 based index # bool-semantics: If true then the returned integer represents a boolean 1 or 0 +# detected-semantics: If true, the event or function is involved in the DetectedEvent wrapper in SLua llAbs: arguments: - Value: @@ -4908,6 +4911,7 @@ functions: energy: 10.0 func-id: 555 return: void + detected-semantics: true sleep: 0.0 tooltip: Changes the amount of damage to be delivered by this damage event. llAdjustSoundVolume: @@ -5548,6 +5552,7 @@ functions: energy: 10.0 func-id: 554 return: list + detected-semantics: true sleep: 0.0 tooltip: Returns a list containing the current damage for the event, the damage type and the original damage delivered. @@ -5561,6 +5566,7 @@ functions: energy: 10.0 func-id: 37 return: vector + detected-semantics: true sleep: 0.0 tooltip: Returns the grab offset of a user touching the object.\nReturns <0.0, 0.0, 0.0> if Number is not a valid object. @@ -5575,6 +5581,7 @@ functions: func-id: 39 return: integer bool-semantics: true + detected-semantics: true sleep: 0.0 tooltip: Returns TRUE if detected object or agent Number has the same user group active as this object.\nIt will return FALSE if the object or agent is in the @@ -5589,6 +5596,7 @@ functions: energy: 10.0 func-id: 32 return: key + detected-semantics: true sleep: 0.0 tooltip: Returns the key of detected object or avatar number.\nReturns NULL_KEY if Number is not a valid index. @@ -5603,6 +5611,7 @@ functions: func-id: 40 # Note that the return does NOT have index semantics, link numbers are already one-indexed (sort of) return: integer + detected-semantics: true sleep: 0.0 tooltip: Returns the link position of the triggered event for touches and collisions only.\n0 for a non-linked object, 1 for the root of a linked object, 2 for the @@ -5617,6 +5626,7 @@ functions: energy: 10.0 func-id: 31 return: string + detected-semantics: true sleep: 0.0 tooltip: Returns the name of detected object or avatar number.\nReturns the name of detected object number.\nReturns empty string if Number is not a valid index. @@ -5643,6 +5653,7 @@ functions: energy: 10.0 func-id: 35 return: vector + detected-semantics: true sleep: 0.0 tooltip: Returns the position of detected object or avatar number.\nReturns <0.0, 0.0, 0.0> if Number is not a valid index. @@ -5656,6 +5667,7 @@ functions: energy: 10.0 func-id: 553 return: key + detected-semantics: true sleep: 0.0 tooltip: Returns the key for the rezzer of the detected object. must-use: true @@ -5668,6 +5680,7 @@ functions: energy: 10.0 func-id: 38 return: rotation + detected-semantics: true sleep: 0.0 tooltip: Returns the rotation of detected object or avatar number.\nReturns <0.0, 0.0, 0.0, 1.0> if Number is not a valid offset. @@ -5681,6 +5694,7 @@ functions: energy: 10.0 func-id: 341 return: vector + detected-semantics: true sleep: 0.0 tooltip: Returns the surface bi-normal for a triggered touch event.\nReturns a vector that is the surface bi-normal (tangent to the surface) where the touch @@ -5696,6 +5710,7 @@ functions: func-id: 338 # NOTE: We can't change face number indexing easily because it's part of the viewer, so no index semantics for ret... return: integer + detected-semantics: true sleep: 0.0 tooltip: Returns the index of the face where the avatar clicked in a triggered touch event. @@ -5709,6 +5724,7 @@ functions: energy: 10.0 func-id: 340 return: vector + detected-semantics: true sleep: 0.0 tooltip: Returns the surface normal for a triggered touch event.\nReturns a vector that is the surface normal (perpendicular to the surface) where the touch event @@ -5723,6 +5739,7 @@ functions: energy: 10.0 func-id: 339 return: vector + detected-semantics: true sleep: 0.0 tooltip: Returns the position, in region coordinates, where the object was touched in a triggered touch event.\nUnless it is a HUD, in which case it returns the @@ -5753,6 +5770,7 @@ functions: energy: 10.0 func-id: 337 return: vector + detected-semantics: true sleep: 0.0 tooltip: Returns a vector that is the texture coordinates for where the prim was touched.\nThe X and Y vector positions contain the U and V face coordinates @@ -5768,6 +5786,7 @@ functions: energy: 10.0 func-id: 34 return: integer + detected-semantics: true sleep: 0.0 tooltip: "Returns the type (AGENT, ACTIVE, PASSIVE, SCRIPTED) of detected object.\\\ nReturns 0 if number is not a valid index.\\nNote that number is a bit-field,\ @@ -5783,6 +5802,7 @@ functions: energy: 10.0 func-id: 36 return: vector + detected-semantics: true sleep: 0.0 tooltip: Returns the velocity of the detected object Number.\nReturns<0.0, 0.0, 0.0> if Number is not a valid offset. @@ -6164,6 +6184,7 @@ functions: energy: 10.0 func-id: 84 return: float + slua-deprecated: true sleep: 0.0 tooltip: Returns the script time in seconds and then resets the script timer to zero.\nGets the time in seconds since starting and resets the time to zero. @@ -10128,6 +10149,7 @@ functions: energy: 10.0 func-id: 83 return: void + slua-deprecated: true sleep: 0.0 tooltip: Sets the time to zero.\nSets the internal timer to zero. llReturnObjectsByID: @@ -11113,6 +11135,7 @@ functions: func-id: 369 return: integer bool-semantics: true + slua-deprecated: true sleep: 0.0 tooltip: Requests Limit bytes to be reserved for this script.\nReturns TRUE or FALSE indicating whether the limit was set successfully.\nThis function has @@ -11477,6 +11500,7 @@ functions: energy: 10.0 func-id: 107 return: void + slua-deprecated: true sleep: 0.0 tooltip: Causes the timer event to be triggered every Rate seconds.\n Passing in 0.0 stops further timer events. diff --git a/slua_definitions.yaml b/slua_definitions.yaml index 90baf6c..93ae0f9 100644 --- a/slua_definitions.yaml +++ b/slua_definitions.yaml @@ -128,8 +128,9 @@ baseClasses: type: number - name: z type: number -- name: LLDetectedEvent +- name: DetectedEvent comment: Event detection class providing access to detected object/avatar information + # auto-generated from lsl_definitions.yaml methods: [] properties: - name: index @@ -158,7 +159,7 @@ typeAliases: # auto-generated from lsl_definitions.yaml definition: (...any) -> () - name: LLDetectedEventHandler - definition: "(detected: {LLDetectedEvent}) -> ()" + definition: "(detected: {DetectedEvent}) -> ()" - name: LLTimerEveryCallback comment: Callback type for LLTimers.every() - receives scheduled time and interval definition: "(scheduled: number, interval: number) -> ()" From 94f5b16e14af165a7836fd28cf6f29cfeda0b96d Mon Sep 17 00:00:00 2001 From: tapple Date: Thu, 22 Jan 2026 16:15:26 -0800 Subject: [PATCH 071/102] remove goto from lua keywords --- slua_definitions.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/slua_definitions.yaml b/slua_definitions.yaml index 93ae0f9..b8ba28d 100644 --- a/slua_definitions.yaml +++ b/slua_definitions.yaml @@ -2143,8 +2143,6 @@ controls: tooltip: "Lua end keyword: closes control structures like if, do, while, for, and function." for: tooltip: "Lua for loop: for var = start, end, step do ... end" - goto: - tooltip: "Lua goto statement: jumps to a specified label." return: tooltip: "Lua return statement: returns a value from a function." while: From deffcb31b46e1c085fde9f4bba812b4d43151300 Mon Sep 17 00:00:00 2001 From: tapple Date: Thu, 22 Jan 2026 17:06:49 -0800 Subject: [PATCH 072/102] add missing luau keywords continue and export --- slua_definitions.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/slua_definitions.yaml b/slua_definitions.yaml index b8ba28d..18a49fa 100644 --- a/slua_definitions.yaml +++ b/slua_definitions.yaml @@ -2155,8 +2155,12 @@ controls: tooltip: "Lua function keyword: begins a function definition." break: tooltip: "Lua break statement: exits the nearest loop." + continue: + tooltip: "Luau continue statement: skip to the next loop iteration." local: tooltip: "Lua local keyword: declares a local variable or function." + export: + tooltip: "Luau export keyword: declares a type that can be used in outside this module." in: tooltip: "Lua in keyword: used in generic for loops to iterate over elements." not: From 16e53cd5a3d7cc67ca3c4ad8b41706d0eff9bf03 Mon Sep 17 00:00:00 2001 From: tapple Date: Fri, 23 Jan 2026 05:16:10 -0800 Subject: [PATCH 073/102] add slua_definitions.yaml to README and CI --- .github/workflows/validate.yaml | 21 ++++++++++++++++----- README.md | 2 +- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/.github/workflows/validate.yaml b/.github/workflows/validate.yaml index 5dab399..d1d7538 100644 --- a/.github/workflows/validate.yaml +++ b/.github/workflows/validate.yaml @@ -44,13 +44,24 @@ jobs: python -m pip install --upgrade pip pip install . - - name: Check if syntax generation produces valid output + - name: Check if LSL syntax generation produces valid output run: | # Generate syntax to a temporary file to verify it's valid - gen-lsl-definitions ./lsl_definitions.yaml syntax /tmp/syntax_output.llsd + gen-lsl-definitions ./lsl_definitions.yaml syntax /tmp/lsl_syntax_output.llsd # Check that the output file was created and is not empty - if [ ! -s /tmp/syntax_output.llsd ]; then - echo "Error: Syntax generation produced empty output" + if [ ! -s /tmp/lsl_syntax_output.llsd ]; then + echo "Error: LSL Syntax generation produced empty output" exit 1 fi - echo "✓ Syntax generation successful and produced non-empty output" + echo "✓ LSL Syntax generation successful and produced non-empty output" + + - name: Check if SLua syntax generation produces valid output + run: | + # Generate syntax to a temporary file to verify it's valid + gen-lsl-definitions ./lsl_definitions.yaml slua-syntax ./slua_definitions.yaml /tmp/slua_syntax_output.llsd + # Check that the output file was created and is not empty + if [ ! -s /tmp/slua_syntax_output.llsd ]; then + echo "Error: SLua Syntax generation produced empty output" + exit 1 + fi + echo "✓ SLua Syntax generation successful and produced non-empty output" diff --git a/README.md b/README.md index c773419..29fa35f 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # LSL Definitions -This repository contains the canonical `lsl_definitions.yaml` file that serves as the authoritative source of truth for Second Life's LSL (Linden Scripting Language) library. +This repository contains the canonical `lsl_definitions.yaml` and `slua_definitions.yaml` files that serve as the authoritative source of truth for Second Life's LSL (Linden Scripting Language) and SLua (Server Lua) libraries. ## Purpose From 49bf9abce121b443f511e98b85e71a6a831ee9dd Mon Sep 17 00:00:00 2001 From: tapple Date: Sun, 25 Jan 2026 04:37:48 -0800 Subject: [PATCH 074/102] `userdata` is not a language keyword, just a string that `typeof` can return --- gen_definitions.py | 2 +- slua_definitions.yaml | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/gen_definitions.py b/gen_definitions.py index 39c1916..03c097b 100644 --- a/gen_definitions.py +++ b/gen_definitions.py @@ -938,7 +938,7 @@ def _validate_property(self, data: any, scope: Set[str], const: bool = False) -> prop = SLuaProperty(slua_removed=data.pop("slua-removed", False), **data) self._validate_identifier(prop.name) self._validate_scope(prop.name, scope) - if const and prop.type != "userdata" and prop.value is None: + if const and prop.type != "any" and prop.value is None: raise ValueError(f"Constant {prop.name} must have a value") self.validate_type(prop.type) return prop diff --git a/slua_definitions.yaml b/slua_definitions.yaml index 18a49fa..dbe6eb2 100644 --- a/slua_definitions.yaml +++ b/slua_definitions.yaml @@ -996,7 +996,7 @@ modules: properties: - name: 'null' comment: A constant to pass for null to json encode - type: userdata + type: any - name: empty_array_mt comment: Metatable for declaring table as an empty array for json encode type: '{ [any]: any }' @@ -1007,7 +1007,7 @@ modules: value: '{}' - name: empty_array comment: A constant to pass for an empty array to json encode - type: userdata + type: any - name: _NAME comment: Name of the lljson library type: string @@ -2186,8 +2186,6 @@ builtinTypes: tooltip: Collection of key‑value pairs. thread: tooltip: Represents a coroutine. - userdata: - tooltip: Opaque external data. unknown: tooltip: The union of every type. Similar to any without disabling type-checking. builtinConstants: @@ -2252,7 +2250,7 @@ builtinFunctions: - name: mt comment: Optional boolean to create a modifiable metatable. type: boolean? - returnType: userdata + returnType: any - name: print comment: Prints all arguments to standard output using Tab as a separator. parameters: From d40393097a9f3f02614cbb52c0656ee661762d85 Mon Sep 17 00:00:00 2001 From: tapple Date: Sun, 25 Jan 2026 04:47:42 -0800 Subject: [PATCH 075/102] `table` is not a language keyword, just a string that `typeof` can return, and a standard library module --- slua_definitions.yaml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/slua_definitions.yaml b/slua_definitions.yaml index dbe6eb2..433ae24 100644 --- a/slua_definitions.yaml +++ b/slua_definitions.yaml @@ -1663,7 +1663,7 @@ modules: type: string returnType: string - name: table - comment: Table manipulation library + comment: Table manipulation library. Tables are collections of key-value pairs. functions: - name: concat comment: Joins an array of strings into one string, with an optional separator. @@ -2182,8 +2182,6 @@ builtinTypes: tooltip: Double‑precision floating point number. string: tooltip: Read-only binary data. Usually UTF-8-encoded text. - table: - tooltip: Collection of key‑value pairs. thread: tooltip: Represents a coroutine. unknown: @@ -2316,10 +2314,10 @@ builtinFunctions: parameters: - name: t comment: The table to set the metatable for. - type: table + type: "{ [any]: any }" - name: mt comment: The metatable to set. - type: table? + type: "{ [any]: any }?" returnType: () - name: tonumber comment: Converts the input string to a number in the specified base. From d5cb4000a7d242b2d7813e91d793860079937f42 Mon Sep 17 00:00:00 2001 From: tapple Date: Sun, 25 Jan 2026 04:49:42 -0800 Subject: [PATCH 076/102] Added period to the end of table comments, for consistency with other comments --- slua_definitions.yaml | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/slua_definitions.yaml b/slua_definitions.yaml index 433ae24..1d4c91f 100644 --- a/slua_definitions.yaml +++ b/slua_definitions.yaml @@ -304,7 +304,7 @@ globalFunctions: returnType: quaternion? modules: - name: bit32 - comment: Bitwise operations library + comment: Bitwise operations library. functions: - name: arshift comment: |- @@ -436,7 +436,7 @@ modules: type: number returnType: number - name: buffer - comment: Buffer manipulation library for binary data + comment: Buffer manipulation library for binary data. functions: - name: create comment: Creates a buffer of the requested size with all bytes initialized to 0. @@ -744,7 +744,7 @@ modules: type: number returnType: () - name: coroutine - comment: Coroutine manipulation library + comment: Coroutine manipulation library. functions: - name: create comment: Returns a new coroutine that, when resumed, will run function f. @@ -800,7 +800,7 @@ modules: type: thread returnType: (boolean, string?) - name: debug - comment: Debug library for introspection + comment: Debug library for introspection. functions: - name: info comment: Returns information about a stack frame or function based on specified format. @@ -941,7 +941,7 @@ modules: private: true returnType: any - name: llbase64 - comment: Base64 encoding/decoding library + comment: Base64 encoding/decoding library. functions: - name: encode comment: Encodes a string or buffer to base64 @@ -964,7 +964,7 @@ modules: type: string returnType: string - name: lljson - comment: JSON encoding/decoding library for Second Life + comment: JSON encoding/decoding library for Second Life. functions: - name: encode comment: Encodes a Lua value as JSON @@ -1017,7 +1017,7 @@ modules: type: string value: "2.1.0.11" - name: math - comment: Mathematical functions library + comment: Mathematical functions library. functions: - name: abs comment: Returns the absolute value of n. @@ -1343,7 +1343,7 @@ modules: type: number value: inf - name: os - comment: Operating system facilities library + comment: Operating system facilities library. functions: - name: clock comment: Returns a high-precision timestamp in seconds for measuring durations. @@ -1377,7 +1377,7 @@ modules: type: OsDateTime? returnType: number? - name: quaternion - comment: Quaternion manipulation library + comment: Quaternion manipulation library. callable: name: quaternion comment: Creates a new quaternion with the given component values. @@ -1484,7 +1484,7 @@ modules: type: quaternion value: <0, 0, 0, 1> - name: string - comment: String manipulation library + comment: String manipulation library. functions: - name: byte comment: Returns the numeric code of every byte in the input string within the given range. @@ -1875,7 +1875,7 @@ modules: type: '{[K]: V}' returnType: '{[K]: V}' - name: utf8 - comment: UTF-8 support library + comment: UTF-8 support library. functions: - name: char comment: Creates a string from Unicode codepoints. @@ -1938,7 +1938,7 @@ modules: type: string value: "[\\x00-\\x7F\\xC2-\\xF4][\\x80-\\xBF]*" - name: uuid - comment: uuid library + comment: UUID library. callable: name: uuid comment: Creates a new uuid from a string, buffer, or existing uuid. Returns @@ -1958,7 +1958,7 @@ modules: type: string | buffer | uuid returnType: uuid? - name: vector - comment: Vector manipulation library + comment: Vector manipuluation library. callable: name: vector comment: Creates a new vector with the given component values. @@ -2121,10 +2121,11 @@ modules: value: <1,1,1> - name: ll # auto-generated from lsl_definitions.yaml - comment: Library for functions shared between LSL and SLua + comment: Library for functions shared between LSL and SLua. - name: llcompat # auto-generated from lsl_definitions.yaml - comment: Like ll, but exactly matches LSL semantics + comment: Like ll, but exactly matches LSL semantics. +# auto-generated from lsl_definitions.yaml constants: [] # Everything below here is only for keywords.xml generation, not typechecking From 36aa34b0f451c2200a02e5b4f3070ab947009691 Mon Sep 17 00:00:00 2001 From: tapple Date: Sun, 25 Jan 2026 06:03:35 -0800 Subject: [PATCH 077/102] removed `numeric` in favor of explicit `boolean | number`. `numeric` is unclear and confusingly similar to `number` --- slua_definitions.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/slua_definitions.yaml b/slua_definitions.yaml index 1d4c91f..1a4ea65 100644 --- a/slua_definitions.yaml +++ b/slua_definitions.yaml @@ -143,8 +143,6 @@ typeAliases: - name: rotation comment: '''rotation'' is an alias for ''quaternion''' definition: quaternion -- name: numeric - definition: boolean | number - name: list definition: "{string | number | vector | uuid | quaternion | boolean}" - name: LLDetectedEventName From 8b07f217e33ef3e4acb4f5c02fb9a02643091abb Mon Sep 17 00:00:00 2001 From: tapple Date: Sun, 25 Jan 2026 06:09:29 -0800 Subject: [PATCH 078/102] better return type for llGetExperienceList --- lsl_definitions.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/lsl_definitions.yaml b/lsl_definitions.yaml index 22dbe6e..f9233d1 100644 --- a/lsl_definitions.yaml +++ b/lsl_definitions.yaml @@ -6481,6 +6481,7 @@ functions: func-id: 410 private: true return: list + slua-return: '{uuid}' sleep: 0.0 tooltip: '' must-use: true From 892a981bb280d0503b13055cfb6be373a0756955 Mon Sep 17 00:00:00 2001 From: tapple Date: Sun, 25 Jan 2026 14:27:27 -0800 Subject: [PATCH 079/102] add deprecated field --- gen_definitions.py | 1 + 1 file changed, 1 insertion(+) diff --git a/gen_definitions.py b/gen_definitions.py index 03c097b..44532b2 100644 --- a/gen_definitions.py +++ b/gen_definitions.py @@ -462,6 +462,7 @@ class SLuaFunctionSignature: typeParameters: Optional[List[str]] = None comment: str = "" private: bool = False + deprecated: bool = False overloads: Optional[List[SLuaFunctionOverload]] = None def to_keywords_dict(self) -> dict: From 2af7281cc3aedf6cce0312d07b9751e3b7e4d95a Mon Sep 17 00:00:00 2001 From: tapple Date: Sun, 25 Jan 2026 14:44:01 -0800 Subject: [PATCH 080/102] mark deprecated luau functions --- gen_definitions.py | 2 ++ slua_definitions.yaml | 3 +++ 2 files changed, 5 insertions(+) diff --git a/gen_definitions.py b/gen_definitions.py index 44532b2..3df32f8 100644 --- a/gen_definitions.py +++ b/gen_definitions.py @@ -478,6 +478,7 @@ def to_keywords_dict(self) -> dict: } for a in self.parameters ], + "deprecated": self.deprecated, "energy": 10.0, "return": self.returnType, "sleep": 0.0, @@ -900,6 +901,7 @@ def _validate_function( parameters=[SLuaParameter(**p) for p in data.get("parameters", [])], returnType=data.get("returnType", LSLType.VOID.meta.slua_name), comment=data.get("comment", ""), + deprecated=data.get("deprecated", False), private=data.get("private", False), ) self._validate_identifier(func.name) diff --git a/slua_definitions.yaml b/slua_definitions.yaml index 1a4ea65..3149870 100644 --- a/slua_definitions.yaml +++ b/slua_definitions.yaml @@ -1681,6 +1681,7 @@ modules: returnType: string - name: foreach comment: Iterates over all key-value pairs in the table (deprecated). + deprecated: true typeParameters: [K, V, R] parameters: - name: t @@ -1692,6 +1693,7 @@ modules: returnType: R? - name: foreachi comment: Iterates over all index-value pairs in the array (deprecated). + deprecated: true typeParameters: [V, R] parameters: - name: a @@ -1703,6 +1705,7 @@ modules: returnType: R? - name: getn comment: 'Returns the length of an array (deprecated; use # instead).' + deprecated: true parameters: - name: a comment: Array to check. From ad5db61d43a24f6d9f6186aaf6987d431e337347 Mon Sep 17 00:00:00 2001 From: tapple Date: Sun, 25 Jan 2026 15:13:53 -0800 Subject: [PATCH 081/102] renamed slua-deprecated to slua-removed; re-added slua-deprecated --- gen_definitions.py | 7 ++++++- lsl_definitions.schema.json | 15 ++++++++++----- lsl_definitions.yaml | 7 ++++--- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/gen_definitions.py b/gen_definitions.py index 3df32f8..29d2cf7 100644 --- a/gen_definitions.py +++ b/gen_definitions.py @@ -282,6 +282,7 @@ class LSLFunction: """ deprecated: bool slua_deprecated: bool + slua_removed: bool """Only exists in llcompat""" func_id: int pure: bool @@ -369,7 +370,10 @@ def to_slua_dict(self, slua: "SLuaDefinitionParser") -> dict: } for a in self.arguments ], - "deprecated": self.deprecated or self.slua_deprecated, + "deprecated": self.deprecated + or self.slua_deprecated + or self.slua_removed + or self.detected_semantics, "energy": self.energy, "god-mode": self.god_mode, "return": slua.validate_type(self.compute_slua_type(), known_types), @@ -680,6 +684,7 @@ def _handle_function(self, func_name: str, func_data: dict) -> LSLFunction: god_mode=func_data.get("god-mode", False), deprecated=func_data.get("deprecated", False), slua_deprecated=func_data.get("slua-deprecated", False), + slua_removed=func_data.get("slua-removed", False), func_id=func_data["func-id"], pure=func_data.get("pure", False), native=func_data.get("native", False), diff --git a/lsl_definitions.schema.json b/lsl_definitions.schema.json index 02d36b1..8d28740 100644 --- a/lsl_definitions.schema.json +++ b/lsl_definitions.schema.json @@ -371,11 +371,6 @@ "markdownDescription": "This function is wrapped in the DetectedEvent class.", "type": "boolean" }, - "slua-deprecated": { - "const": true, - "markdownDescription": "This function only exists in llcompat, not ll.", - "type": "boolean" - }, "energy": { "$ref": "#/definitions/nonNegativeNumber", "markdownDescription": "The script energy consumed by this function." @@ -485,6 +480,16 @@ { "const": "void" } ] }, + "slua-deprecated": { + "const": true, + "markdownDescription": "This function is deprecated in SLua.", + "type": "boolean" + }, + "slua-removed": { + "const": true, + "markdownDescription": "In SLua, this function has been removed from ll module and only exists in llcompat.", + "type": "boolean" + }, "slua-return": { "markdownDescription": "A more specific return type for slua type-checking.", "type": "string" diff --git a/lsl_definitions.yaml b/lsl_definitions.yaml index f9233d1..667ebd5 100644 --- a/lsl_definitions.yaml +++ b/lsl_definitions.yaml @@ -4833,6 +4833,7 @@ functions: # private: Should this function be omitted from the generated documentation. # deprecated: Has this function been deprecated. # slua-deprecated: Has this function or event been deprecated in SLua. +# slua-removed: Has this function or event been removed in SLua. # pure: Is the function guaranteed to have no side effects. # must-use: If true or `pure` is true, then the functions return value should not be discarded, as it serves no other purpose # native: If true, this function must use a native implementation for non-LSO VMs. @@ -10150,7 +10151,7 @@ functions: energy: 10.0 func-id: 83 return: void - slua-deprecated: true + slua-removed: true sleep: 0.0 tooltip: Sets the time to zero.\nSets the internal timer to zero. llReturnObjectsByID: @@ -11136,7 +11137,7 @@ functions: func-id: 369 return: integer bool-semantics: true - slua-deprecated: true + slua-removed: true sleep: 0.0 tooltip: Requests Limit bytes to be reserved for this script.\nReturns TRUE or FALSE indicating whether the limit was set successfully.\nThis function has @@ -11501,7 +11502,7 @@ functions: energy: 10.0 func-id: 107 return: void - slua-deprecated: true + slua-removed: true sleep: 0.0 tooltip: Causes the timer event to be triggered every Rate seconds.\n Passing in 0.0 stops further timer events. From 69933308b1cfd02b30d4b45f7fe06f00ae5b2d03 Mon Sep 17 00:00:00 2001 From: tapple Date: Sun, 25 Jan 2026 15:19:16 -0800 Subject: [PATCH 082/102] renamed slua-deprecated to slua-removed; re-added slua-deprecated --- lsl_definitions.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lsl_definitions.yaml b/lsl_definitions.yaml index 667ebd5..506d29b 100644 --- a/lsl_definitions.yaml +++ b/lsl_definitions.yaml @@ -6185,7 +6185,7 @@ functions: energy: 10.0 func-id: 84 return: float - slua-deprecated: true + slua-removed: true sleep: 0.0 tooltip: Returns the script time in seconds and then resets the script timer to zero.\nGets the time in seconds since starting and resets the time to zero. From f6b37843de53b67adb535e2b519b0cfa1b878617 Mon Sep 17 00:00:00 2001 From: tapple Date: Sun, 25 Jan 2026 16:33:36 -0800 Subject: [PATCH 083/102] missed detected-semantics in llDetectedOwner, llDetectedTouchST --- lsl_definitions.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lsl_definitions.yaml b/lsl_definitions.yaml index 506d29b..a90f9a1 100644 --- a/lsl_definitions.yaml +++ b/lsl_definitions.yaml @@ -5641,6 +5641,7 @@ functions: energy: 10.0 func-id: 33 return: key + detected-semantics: true sleep: 0.0 tooltip: Returns the key of detected object's owner.\nReturns invalid key if Number is not a valid index. @@ -5755,6 +5756,7 @@ functions: energy: 10.0 func-id: 342 return: vector + detected-semantics: true sleep: 0.0 tooltip: Returns a vector that is the surface coordinates where the prim was touched.\nThe X and Y vector positions contain the horizontal (S) and vertical (T) face coordinates From 78d248b20a11d46a8ec667ff706c2f4c8f4b6254 Mon Sep 17 00:00:00 2001 From: tapple Date: Mon, 26 Jan 2026 05:40:43 -0800 Subject: [PATCH 084/102] mark type aliases for export, and don't add non-exported ones to keywords --- gen_definitions.py | 24 +++++++++++------------- slua_definitions.yaml | 3 +++ 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/gen_definitions.py b/gen_definitions.py index 29d2cf7..8434f50 100644 --- a/gen_definitions.py +++ b/gen_definitions.py @@ -498,6 +498,7 @@ class SLuaTypeAlias: name: str definition: str comment: str = "" + export: bool = False def to_keywords_dict(self) -> dict: definition = self.to_luau_def() @@ -508,7 +509,8 @@ def to_keywords_dict(self) -> dict: } def to_luau_def(self) -> str: - return f"type {self.name} = {self.definition}" + export_str = "export " if self.export else "" + return f"{export_str}type {self.name} = {self.definition}" @dataclasses.dataclass @@ -1070,7 +1072,8 @@ def dump_slua_syntax( for class_ in sorted(slua_definitions.baseClasses, key=lambda x: x.name): syntax["types"][class_.name] = class_.to_keywords_dict() for alias in sorted(slua_definitions.typeAliases, key=lambda x: x.name): - syntax["types"][alias.name] = alias.to_keywords_dict() + if alias.export: + syntax["types"][alias.name] = alias.to_keywords_dict() for class_ in sorted(slua_definitions.classes, key=lambda x: x.name): syntax["types"][class_.name] = class_.to_keywords_dict() @@ -1086,14 +1089,12 @@ def dump_slua_syntax( for func in sorted(slua_definitions.globalFunctions, key=lambda x: x.name): syntax["functions"][func.name] = func.to_keywords_dict() for module in sorted(slua_definitions.modules, key=lambda x: x.name): - if module.name in {"ll", "llcompat"}: - continue - syntax["functions"].update(module.to_keywords_functions_dict()) + if module.name not in {"ll", "llcompat"}: + syntax["functions"].update(module.to_keywords_functions_dict()) syntax["functions"].update(ll_module.to_keywords_functions_dict()) for func in sorted(lsl_definitions.functions.values(), key=lambda x: x.name): - if func.private: - continue - syntax["functions"][func.compute_slua_name()] = func.to_slua_dict(parser) + if not func.private: + syntax["functions"][func.compute_slua_name()] = func.to_slua_dict(parser) # constants for const in slua_definitions.builtinConstants: @@ -1101,11 +1102,8 @@ def dump_slua_syntax( for module in sorted(slua_definitions.modules, key=lambda x: x.name): syntax["constants"].update(module.to_keywords_constants_dict()) for const in sorted(lsl_definitions.constants.values(), key=lambda x: x.name): - if const.private: - continue - if const.slua_removed: - continue - syntax["constants"][const.name] = const.to_slua_dict(parser) + if not const.private and not const.slua_removed: + syntax["constants"][const.name] = const.to_slua_dict(parser) if pretty: return llsd.format_pretty_xml(syntax, indent=3, c_compat=True, sort_maps=False) diff --git a/slua_definitions.yaml b/slua_definitions.yaml index 3149870..d9352cd 100644 --- a/slua_definitions.yaml +++ b/slua_definitions.yaml @@ -142,8 +142,10 @@ baseClasses: typeAliases: - name: rotation comment: '''rotation'' is an alias for ''quaternion''' + export: true definition: quaternion - name: list + export: true definition: "{string | number | vector | uuid | quaternion | boolean}" - name: LLDetectedEventName # auto-generated from lsl_definitions.yaml @@ -169,6 +171,7 @@ typeAliases: definition: LLTimerEveryCallback | LLTimerOnceCallback - name: OsDateTime comment: Date/time table structure used by os.date and os.time + export: true definition: |- { year: number, From 137f9874c477f034f9d23cea0baf6fc7bfaead46 Mon Sep 17 00:00:00 2001 From: tapple Date: Mon, 26 Jan 2026 06:26:45 -0800 Subject: [PATCH 085/102] copied the lsl schema to start a slua schema --- pyproject.toml | 2 +- slua_definitions.schema.json | 586 +++++++++++++++++++++++++++++++++++ slua_definitions.yaml | 2 +- validate.py | 15 +- 4 files changed, 598 insertions(+), 7 deletions(-) create mode 100644 slua_definitions.schema.json diff --git a/pyproject.toml b/pyproject.toml index d02e92a..b23794d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,7 +31,7 @@ keywords = ["Linden Scripting Language", "Second Life"] [project.scripts] gen-lsl-definitions = "gen_definitions:main" -validate-lsl-definitions-via-jsonschema = "validate:validate_lsl_definitions_via_jsonschema" +validate-lsl-definitions-via-jsonschema = "validate:main" [project.urls] Homepage = "https://github.com/secondlife/lsl-definitions" diff --git a/slua_definitions.schema.json b/slua_definitions.schema.json new file mode 100644 index 0000000..8d28740 --- /dev/null +++ b/slua_definitions.schema.json @@ -0,0 +1,586 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "http://raw.githubusercontent.com/secondlife/lsl-definitions/refs/heads/main/lsl_definitions.schema.json", + "$comment": "This schema defines keywords for the Linden Scripting Language (LSL) of Second Life.", + "definitions": { + "nonNegativeInteger": { + "minimum": 0, + "type": "integer" + }, + "nonNegativeIntegerDefault0": { + "allOf": [ + { "$ref": "#/definitions/nonNegativeInteger" }, + { "default": 0 } + ] + }, + "nonNegativeNumber": { + "minimum": 0.0, + "type": "number" + }, + "positiveInteger": { + "exclusiveMinimum": 0, + "type": "integer" + }, + "zeroToOneNumber": { + "maximum": 1.0, + "minimum": 0.0, + "type": "number" + } + }, + "properties": { + "constants": { + "additionalProperties": false, + "patternProperties": { + "^(?:[A-Z]+[0-9]*(?:_(?:[0-9]+|[A-Z]+[0-9]*))*)$": { + "properties": { + "additionalProperties": false, + "deprecated": { + "const": true, + "markdownDescription": "This constant has been deprecated.", + "type": "boolean" + }, + "slua-removed": { + "const": true, + "markdownDescription": "This constant is only present in LSL, not SLua.", + "type": "boolean" + }, + "private": { + "const": true, + "markdownDescription": "This constant should be omitted from the generated documentation.", + "type": "boolean" + }, + "tooltip": { + "markdownDescription": "A brief description of this constant.", + "type": "string" + }, + "type": { + "defaultSnippets": [ + { + "label": "float", + "body": "float" + }, + { + "label": "integer", + "body": "integer" + }, + { + "label": "key", + "body": "key" + }, + { + "label": "list", + "body": "list" + }, + { + "label": "quaternion", + "body": "quaternion" + }, + { + "label": "rotation", + "body": "rotation" + }, + { + "label": "string", + "body": "string" + }, + { + "label": "vector", + "body": "vector" + } + ], + "markdownDescription": "One of the valid types for this constant: [float, integer, key, list, rotation, string, vector].", + "oneOf": [ + { "const": "float" }, + { "const": "integer" }, + { "const": "key" }, + { "const": "list" }, + { + "$comment": "quaternion is an alias for rotation", + "const": "quaternion" + }, + { "const": "rotation" }, + { "const": "string" }, + { "const": "vector" } + ] + }, + "value": { + "markdownDescription": "The value of the constant.", + "type": [ + "integer", + "string" + ] + } + }, + "required": [ + "tooltip", + "type", + "value" + ], + "type": "object" + } + }, + "type": "object" + }, + "controls": { + "additionalProperties": false, + "patternProperties": { + "^(?:[a-z]+)$": { + "properties": { + "tooltip": { + "markdownDescription": "A brief description of this control (keyword).", + "type": "string" + } + }, + "required": [ + "tooltip" + ], + "type": "object" + } + }, + "type": "object" + }, + "events": { + "additionalProperties": false, + "patternProperties": { + "^[a-z_]+$": { + "additionalProperties": false, + "properties": { + "arguments": { + "items": { + "additionalProperties": false, + "patternProperties": { + "^(?:[A-Za-z]+(?:_[A-Za-z]+)*)$": { + "properties": { + "tooltip": { + "markdownDescription": "A brief description of this event argument.", + "type": "string" + }, + "type": { + "defaultSnippets": [ + { + "label": "float", + "body": "float" + }, + { + "label": "integer", + "body": "integer" + }, + { + "label": "key", + "body": "key" + }, + { + "label": "list", + "body": "list" + }, + { + "label": "quaternion", + "body": "quaternion" + }, + { + "label": "rotation", + "body": "rotation" + }, + { + "label": "string", + "body": "string" + }, + { + "label": "vector", + "body": "vector" + } + ], + "markdownDescription": "One of the valid types for this event argument: [float, integer, key, list, rotation, string, vector].", + "oneOf": [ + { "const": "float" }, + { "const": "integer" }, + { "const": "key" }, + { "const": "list" }, + { + "$comment": "quaternion is an alias for rotation", + "const": "quaternion" + }, + { "const": "rotation" }, + { "const": "string" }, + { "const": "vector" } + ] + } + }, + "required": [ + "type" + ], + "type": "object" + } + }, + "type": "object" + }, + "markdownDescription": "An array of event arguments.", + "minItems": 0, + "type": "array", + "uniqueItems": true + }, + "detected-semantics": { + "const": true, + "markdownDescription": "Uses llDetected* in LSL and {DetectedEvent} in SLua.", + "type": "boolean" + }, + "deprecated": { + "const": true, + "markdownDescription": "This event has been deprecated.", + "type": "boolean" + }, + "slua-deprecated": { + "const": true, + "markdownDescription": "This event has been deprecated in SLua.", + "type": "boolean" + }, + "slua-removed": { + "const": true, + "markdownDescription": "This event has been removed in SLua.", + "type": "boolean" + }, + "tooltip": { + "markdownDescription": "A brief description of this event.", + "type": "string" + } + } + } + }, + "type": "object" + }, + "functions": { + "additionalProperties": false, + "patternProperties": { + "^ll[A-Zs](?:[A-Z0-9]*[a-z]*)+$": { + "additionalProperties": false, + "properties": { + "type-arguments": { + "items": { + "additionalProperties": false, + "patternProperties": { + "^(?:[A-Za-z]+)$": { + "markdownDescription": "A type variable name for slua typechecking." + } + }, + "type": "string" + }, + "markdownDescription": "An array of type variable names for slua typechecking.", + "type": "array", + "uniqueItems": true + }, + "arguments": { + "items": { + "additionalProperties": false, + "patternProperties": { + "^(?:[A-Za-z]+(?:[A-z0-9-_]+)*)$": { + "additionalProperties": false, + "properties": { + "bool-semantics": { + "const": true, + "markdownDescription": "This function argument's integer value represents a boolean value.", + "type": "boolean" + }, + "index-semantics": { + "const": true, + "markdownDescription": "This function argument's integer value represents a zero-based index.", + "type": "boolean" + }, + "tooltip": { + "markdownDescription": "A brief description of this function argument.", + "type": "string" + }, + "type": { + "defaultSnippets": [ + { + "label": "float", + "body": "float" + }, + { + "label": "integer", + "body": "integer" + }, + { + "label": "key", + "body": "key" + }, + { + "label": "list", + "body": "list" + }, + { + "label": "quaternion", + "body": "quaternion" + }, + { + "label": "rotation", + "body": "rotation" + }, + { + "label": "string", + "body": "string" + }, + { + "label": "vector", + "body": "vector" + } + ], + "markdownDescription": "One of the valid types for this function argument:\n- float\n- integer\n- key\n- list\n- rotation\n- string\n- vector", + "oneOf": [ + { "const": "float" }, + { "const": "integer" }, + { "const": "key" }, + { "const": "list" }, + { + "$comment": "quaternion is an alias for rotation", + "const": "quaternion" + }, + { "const": "rotation" }, + { "const": "string" }, + { "const": "vector" } + ] + }, + "slua-type": { + "markdownDescription": "A more specific argument type for slua type-checking.", + "type": "string" + } + }, + "required": [ + "type" + ], + "type": "object" + } + }, + "type": "object" + }, + "markdownDescription": "An array of function arguments.", + "type": "array", + "uniqueItems": true + }, + "bool-semantics": { + "const": true, + "markdownDescription": "The returned integer value represents a boolean value.", + "type": "boolean" + }, + "deprecated": { + "const": true, + "markdownDescription": "This function has been deprecated.", + "type": "boolean" + }, + "detected-semantics": { + "const": true, + "markdownDescription": "This function is wrapped in the DetectedEvent class.", + "type": "boolean" + }, + "energy": { + "$ref": "#/definitions/nonNegativeNumber", + "markdownDescription": "The script energy consumed by this function." + }, + "experience": { + "const": true, + "markdownDescription": "This function requires an experience to be set for the script to compile.", + "type": "boolean" + }, + "func-id": { + "$comment": "llSin has 'func-id: 0', so we must include zero", + "$ref": "#/definitions/nonNegativeInteger", + "markdownDescription": "The LSO function identifier." + }, + "god-mode": { + "const": true, + "markdownDescription": "This function can only be executed in god mode.", + "type": "boolean" + }, + "index-semantics": { + "const": true, + "markdownDescription": "The returned integer value represents a zero-based index.", + "type": "boolean" + }, + "linden-experience": { + "const": true, + "markdownDescription": "This function requires a Linden-owned experience.", + "type": "boolean" + }, + "mono-sleep": { + "$ref": "#/definitions/nonNegativeNumber", + "markdownDescription": "Sleep in the mono-script runtime." + }, + "must-use": { + "const": true, + "markdownDescription": "This functions return value should not be discarded but further used.", + "type": "boolean" + }, + "native": { + "const": true, + "markdownDescription": "This function must use a native implementation for non-LSO VMs.", + "type": "boolean" + }, + "private": { + "const": true, + "markdownDescription": "This function should be omitted from the generated documentation.", + "type": "boolean" + }, + "pure": { + "const": true, + "markdownDescription": "This function is guaranteed to have no side effects.", + "type": "boolean" + }, + "return": { + "default": "void", + "defaultSnippets": [ + { + "label": "float", + "body": "float" + }, + { + "label": "integer", + "body": "integer" + }, + { + "label": "key", + "body": "key" + }, + { + "label": "list", + "body": "list" + }, + { + "label": "quaternion", + "body": "quaternion" + }, + { + "label": "rotation", + "body": "rotation" + }, + { + "label": "string", + "body": "string" + }, + { + "label": "vector", + "body": "vector" + }, + { + "label": "void", + "body": "void" + } + ], + "markdownDescription": "One of the valid return types for functions:\n\n- float\n- integer\n- key\n- list\n- rotation\n- string\n- vector\n- void\n\nIf omitted, it is assumed to be void.", + "oneOf": [ + { "const": "float" }, + { "const": "integer" }, + { "const": "key" }, + { "const": "list" }, + { + "$comment": "quaternion is an alias for rotation", + "const": "quaternion" + }, + { "const": "rotation" }, + { "const": "string" }, + { "const": "vector" }, + { "const": "void" } + ] + }, + "slua-deprecated": { + "const": true, + "markdownDescription": "This function is deprecated in SLua.", + "type": "boolean" + }, + "slua-removed": { + "const": true, + "markdownDescription": "In SLua, this function has been removed from ll module and only exists in llcompat.", + "type": "boolean" + }, + "slua-return": { + "markdownDescription": "A more specific return type for slua type-checking.", + "type": "string" + }, + "sleep": { + "$ref": "#/definitions/nonNegativeNumber", + "markdownDescription": "Additional sleep time imposed by the script after this function completes." + }, + "tooltip": { + "markdownDescription": "A brief description of this function.", + "type": "string" + } + }, + "required": [ + "tooltip" + ] + } + }, + "type": "object" + }, + "llsd-lsl-syntax-version": { + "$ref": "#/definitions/positiveInteger", + "markdownDescription": "Only increment with file format changes." + }, + "types": { + "additionalProperties": false, + "defaultSnippets": [ + { + "label": "float", + "body": "float" + }, + { + "label": "integer", + "body": "integer" + }, + { + "label": "key", + "body": "key" + }, + { + "label": "list", + "body": "list" + }, + { + "label": "quaternion", + "body": "quaternion" + }, + { + "label": "rotation", + "body": "rotation" + }, + { + "label": "string", + "body": "string" + }, + { + "label": "vector", + "body": "vector" + } + ], + "markdownDescription": "The valid LSL storage types:\n\n- float\n- integer\n- key\n- list\n- rotation\n- string\n- vector", + "patternProperties": { + "^(?:float|integer|key|list|quaternion|rotation|string|vector)$": { + "properties": { + "private": { + "const": true, + "markdownDescription": "This type should be omitted from the generated documentation.", + "type": "boolean" + }, + "tooltip": { + "markdownDescription": "A brief description of this type.", + "type": "string" + } + }, + "required": [ + "tooltip" + ], + "type": "object" + } + }, + "type": "object" + } + }, + "required": [ + "constants", + "controls", + "events", + "functions", + "llsd-lsl-syntax-version", + "types" + ], + "title": "Second Life LSL Definitions", + "type": "object" +} diff --git a/slua_definitions.yaml b/slua_definitions.yaml index d9352cd..b158f4d 100644 --- a/slua_definitions.yaml +++ b/slua_definitions.yaml @@ -1,6 +1,6 @@ %YAML 1.2 --- -# yaml-language-server: $schema=http://raw.githubusercontent.com/secondlife/lsl-definitions/refs/heads/main/lsl_definitions.schema.json +# yaml-language-server: $schema=http://raw.githubusercontent.com/secondlife/lsl-definitions/refs/heads/main/slua_definitions.schema.json # # increment only when the file format changes, not just the content version: 1.0.0 diff --git a/validate.py b/validate.py index 26cf10d..219cfa2 100644 --- a/validate.py +++ b/validate.py @@ -9,7 +9,7 @@ import jsonschema -def validate_lsl_definitions_via_jsonschema() -> None: +def validate_definitions_via_jsonschema(schema_filename, yaml_filename) -> None: with open("lsl_definitions.schema.json", "r", encoding="utf-8") as schema_file: schemadata = json.load(schema_file) with open("lsl_definitions.yaml", "r", encoding="utf-8") as yaml_file: @@ -17,17 +17,22 @@ def validate_lsl_definitions_via_jsonschema() -> None: try: jsonschema.validate(instance=yamldata, schema=schemadata) - print("\nSUCCESS: Valid against the schema") + print(f"\nSUCCESS: Validated {yaml_filename} against the schema") except jsonschema.exceptions.ValidationError as e: - print("\nVALIDATION ERROR: INVALID", file=sys.stderr) + print(f"\nVALIDATION ERROR: INVALID {yaml_filename}", file=sys.stderr) print(f" Message: {e.message}", file=sys.stderr) print(f" Path: {' -> '.join(map(str, e.path))}", file=sys.stderr) print(f" Schema Path: {' -> '.join(map(str, e.schema_path))}", file=sys.stderr) raise e except jsonschema.exceptions.SchemaError as e: - print("\nSCHEMA ERROR: The schema is invalid", file=sys.stderr) + print(f"\nSCHEMA ERROR: The schema {schema_filename} is invalid", file=sys.stderr) print(f" Message: {e.message}", file=sys.stderr) raise e except Exception as e: - print(f"\nOh no ...: {e}", file=sys.stderr) + print(f"\nOh no ...: {e} processing {yaml_filename}", file=sys.stderr) raise e + + +def main(): + validate_definitions_via_jsonschema("lsl_definitions.schema.json", "lsl_definitions.yaml") + validate_definitions_via_jsonschema("slua_definitions.schema.json", "slua_definitions.yaml") From c0ed674395f2149add4b71bbc7c0eb7792ab5af7 Mon Sep 17 00:00:00 2001 From: tapple Date: Mon, 26 Jan 2026 06:51:25 -0800 Subject: [PATCH 086/102] updated schema version to 2019-09 --- lsl_definitions.schema.json | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lsl_definitions.schema.json b/lsl_definitions.schema.json index 8d28740..a6b6b8b 100644 --- a/lsl_definitions.schema.json +++ b/lsl_definitions.schema.json @@ -1,15 +1,15 @@ { - "$schema": "http://json-schema.org/draft-07/schema#", + "$schema": "http://json-schema.org/draft/2019-09/schema", "$id": "http://raw.githubusercontent.com/secondlife/lsl-definitions/refs/heads/main/lsl_definitions.schema.json", "$comment": "This schema defines keywords for the Linden Scripting Language (LSL) of Second Life.", - "definitions": { + "$defs": { "nonNegativeInteger": { "minimum": 0, "type": "integer" }, "nonNegativeIntegerDefault0": { "allOf": [ - { "$ref": "#/definitions/nonNegativeInteger" }, + { "$ref": "#/$defs/nonNegativeInteger" }, { "default": 0 } ] }, @@ -372,7 +372,7 @@ "type": "boolean" }, "energy": { - "$ref": "#/definitions/nonNegativeNumber", + "$ref": "#/$defs/nonNegativeNumber", "markdownDescription": "The script energy consumed by this function." }, "experience": { @@ -382,7 +382,7 @@ }, "func-id": { "$comment": "llSin has 'func-id: 0', so we must include zero", - "$ref": "#/definitions/nonNegativeInteger", + "$ref": "#/$defs/nonNegativeInteger", "markdownDescription": "The LSO function identifier." }, "god-mode": { @@ -401,7 +401,7 @@ "type": "boolean" }, "mono-sleep": { - "$ref": "#/definitions/nonNegativeNumber", + "$ref": "#/$defs/nonNegativeNumber", "markdownDescription": "Sleep in the mono-script runtime." }, "must-use": { @@ -495,7 +495,7 @@ "type": "string" }, "sleep": { - "$ref": "#/definitions/nonNegativeNumber", + "$ref": "#/$defs/nonNegativeNumber", "markdownDescription": "Additional sleep time imposed by the script after this function completes." }, "tooltip": { @@ -511,7 +511,7 @@ "type": "object" }, "llsd-lsl-syntax-version": { - "$ref": "#/definitions/positiveInteger", + "$ref": "#/$defs/positiveInteger", "markdownDescription": "Only increment with file format changes." }, "types": { From d4b6b7081853bbc50e9bea69a824b1c787651cf8 Mon Sep 17 00:00:00 2001 From: tapple Date: Mon, 26 Jan 2026 06:54:10 -0800 Subject: [PATCH 087/102] updated schema version to 2020-12 --- lsl_definitions.schema.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lsl_definitions.schema.json b/lsl_definitions.schema.json index a6b6b8b..7567c20 100644 --- a/lsl_definitions.schema.json +++ b/lsl_definitions.schema.json @@ -1,5 +1,5 @@ { - "$schema": "http://json-schema.org/draft/2019-09/schema", + "$schema": "http://json-schema.org/draft/2020-12/schema", "$id": "http://raw.githubusercontent.com/secondlife/lsl-definitions/refs/heads/main/lsl_definitions.schema.json", "$comment": "This schema defines keywords for the Linden Scripting Language (LSL) of Second Life.", "$defs": { From 934ee942f215171ea3619a3e1e592ea7ab46d1f6 Mon Sep 17 00:00:00 2001 From: tapple Date: Mon, 26 Jan 2026 06:58:07 -0800 Subject: [PATCH 088/102] validate the slua schema --- validate.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/validate.py b/validate.py index 219cfa2..476c160 100644 --- a/validate.py +++ b/validate.py @@ -10,9 +10,9 @@ def validate_definitions_via_jsonschema(schema_filename, yaml_filename) -> None: - with open("lsl_definitions.schema.json", "r", encoding="utf-8") as schema_file: + with open(schema_filename, "r", encoding="utf-8") as schema_file: schemadata = json.load(schema_file) - with open("lsl_definitions.yaml", "r", encoding="utf-8") as yaml_file: + with open(yaml_filename, "r", encoding="utf-8") as yaml_file: yamldata = yaml.safe_load(yaml_file) try: @@ -36,3 +36,7 @@ def validate_definitions_via_jsonschema(schema_filename, yaml_filename) -> None: def main(): validate_definitions_via_jsonschema("lsl_definitions.schema.json", "lsl_definitions.yaml") validate_definitions_via_jsonschema("slua_definitions.schema.json", "slua_definitions.yaml") + + +if __name__ == "__main__": + main() From 4880f6dd81ca125f1ef57cca489c17132e5e9406 Mon Sep 17 00:00:00 2001 From: tapple Date: Mon, 26 Jan 2026 07:05:26 -0800 Subject: [PATCH 089/102] updated schema version to 2020-12 --- slua_definitions.schema.json | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/slua_definitions.schema.json b/slua_definitions.schema.json index 8d28740..dc115f2 100644 --- a/slua_definitions.schema.json +++ b/slua_definitions.schema.json @@ -1,15 +1,15 @@ { - "$schema": "http://json-schema.org/draft-07/schema#", - "$id": "http://raw.githubusercontent.com/secondlife/lsl-definitions/refs/heads/main/lsl_definitions.schema.json", - "$comment": "This schema defines keywords for the Linden Scripting Language (LSL) of Second Life.", - "definitions": { + "$schema": "http://json-schema.org/draft/2019-09/schema", + "$id": "http://raw.githubusercontent.com/secondlife/lsl-definitions/refs/heads/main/slua_definitions.schema.json", + "$comment": "This schema defines keywords for the Server Lua Language (SLua) of Second Life.", + "$defs": { "nonNegativeInteger": { "minimum": 0, "type": "integer" }, "nonNegativeIntegerDefault0": { "allOf": [ - { "$ref": "#/definitions/nonNegativeInteger" }, + { "$ref": "#/$defs/nonNegativeInteger" }, { "default": 0 } ] }, @@ -25,7 +25,13 @@ "maximum": 1.0, "minimum": 0.0, "type": "number" + }, + "identifier": { + "maximum": 1.0, + "minimum": 0.0, + "type": "string" } + }, "properties": { "constants": { @@ -372,7 +378,7 @@ "type": "boolean" }, "energy": { - "$ref": "#/definitions/nonNegativeNumber", + "$ref": "#/$defs/nonNegativeNumber", "markdownDescription": "The script energy consumed by this function." }, "experience": { @@ -382,7 +388,7 @@ }, "func-id": { "$comment": "llSin has 'func-id: 0', so we must include zero", - "$ref": "#/definitions/nonNegativeInteger", + "$ref": "#/$defs/nonNegativeInteger", "markdownDescription": "The LSO function identifier." }, "god-mode": { @@ -401,7 +407,7 @@ "type": "boolean" }, "mono-sleep": { - "$ref": "#/definitions/nonNegativeNumber", + "$ref": "#/$defs/nonNegativeNumber", "markdownDescription": "Sleep in the mono-script runtime." }, "must-use": { @@ -495,7 +501,7 @@ "type": "string" }, "sleep": { - "$ref": "#/definitions/nonNegativeNumber", + "$ref": "#/$defs/nonNegativeNumber", "markdownDescription": "Additional sleep time imposed by the script after this function completes." }, "tooltip": { @@ -511,7 +517,7 @@ "type": "object" }, "llsd-lsl-syntax-version": { - "$ref": "#/definitions/positiveInteger", + "$ref": "#/$defs/positiveInteger", "markdownDescription": "Only increment with file format changes." }, "types": { @@ -581,6 +587,6 @@ "llsd-lsl-syntax-version", "types" ], - "title": "Second Life LSL Definitions", + "title": "Second Life SLua Definitions", "type": "object" } From 7acd18af59306c5d1eae8ee8a21e443b16798093 Mon Sep 17 00:00:00 2001 From: tapple Date: Mon, 26 Jan 2026 07:50:57 -0800 Subject: [PATCH 090/102] validate constants --- slua_definitions.schema.json | 146 ++++++++++++----------------------- 1 file changed, 49 insertions(+), 97 deletions(-) diff --git a/slua_definitions.schema.json b/slua_definitions.schema.json index dc115f2..b9a4b71 100644 --- a/slua_definitions.schema.json +++ b/slua_definitions.schema.json @@ -27,105 +27,52 @@ "type": "number" }, "identifier": { - "maximum": 1.0, - "minimum": 0.0, + "pattern": "^[_a-zA-Z][_a-zA-Z0-9]*$", + "type": "string" + }, + "type": { + "markdownDescription": "A luau-format type definition", + "pattern": "^([ \n?&|,{}\\[\\]()\":a-zA-Z0-9_]|\\.\\.\\.|->)*$", "type": "string" + }, + "property": { + "markdownDescription": "A property or constant", + "additionalProperties": false, + "properties": { + "name": { "$ref": "#/$defs/identifier" }, + "type": { "$ref": "#/$defs/type" }, + "value": { + "markdownDescription": "The value of the constant.", + "type": ["integer", "string"] + }, + "comment": { + "markdownDescription": "A brief description of this constant.", + "type": "string" + }, + "slua-removed": { + "const": true, + "markdownDescription": "This property is only present in Luau, not SLua.", + "type": "boolean" + } + }, + "required": ["name", "type"], + "type": "object" } }, + "additionalProperties": false, "properties": { + "globalVariables": { + "items": { "$ref": "#/$defs/property" }, + "type": "array" + }, "constants": { - "additionalProperties": false, - "patternProperties": { - "^(?:[A-Z]+[0-9]*(?:_(?:[0-9]+|[A-Z]+[0-9]*))*)$": { - "properties": { - "additionalProperties": false, - "deprecated": { - "const": true, - "markdownDescription": "This constant has been deprecated.", - "type": "boolean" - }, - "slua-removed": { - "const": true, - "markdownDescription": "This constant is only present in LSL, not SLua.", - "type": "boolean" - }, - "private": { - "const": true, - "markdownDescription": "This constant should be omitted from the generated documentation.", - "type": "boolean" - }, - "tooltip": { - "markdownDescription": "A brief description of this constant.", - "type": "string" - }, - "type": { - "defaultSnippets": [ - { - "label": "float", - "body": "float" - }, - { - "label": "integer", - "body": "integer" - }, - { - "label": "key", - "body": "key" - }, - { - "label": "list", - "body": "list" - }, - { - "label": "quaternion", - "body": "quaternion" - }, - { - "label": "rotation", - "body": "rotation" - }, - { - "label": "string", - "body": "string" - }, - { - "label": "vector", - "body": "vector" - } - ], - "markdownDescription": "One of the valid types for this constant: [float, integer, key, list, rotation, string, vector].", - "oneOf": [ - { "const": "float" }, - { "const": "integer" }, - { "const": "key" }, - { "const": "list" }, - { - "$comment": "quaternion is an alias for rotation", - "const": "quaternion" - }, - { "const": "rotation" }, - { "const": "string" }, - { "const": "vector" } - ] - }, - "value": { - "markdownDescription": "The value of the constant.", - "type": [ - "integer", - "string" - ] - } - }, - "required": [ - "tooltip", - "type", - "value" - ], - "type": "object" - } - }, - "type": "object" + "items": { "$ref": "#/$defs/property" }, + "type": "array" + }, + "builtinConstants": { + "items": { "$ref": "#/$defs/property" }, + "type": "array" }, "controls": { "additionalProperties": false, @@ -580,12 +527,17 @@ } }, "required": [ + "version", + "baseClasses", + "typeAliases", + "classes", + "globalFunctions", + "modules", "constants", "controls", - "events", - "functions", - "llsd-lsl-syntax-version", - "types" + "builtinTypes", + "builtinConstants", + "builtinFunctions" ], "title": "Second Life SLua Definitions", "type": "object" From 570b953dee155c4c61d845324791f82ab5a96e57 Mon Sep 17 00:00:00 2001 From: tapple Date: Mon, 26 Jan 2026 08:14:13 -0800 Subject: [PATCH 091/102] renamed overoad to anonymous function --- gen_definitions.py | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/gen_definitions.py b/gen_definitions.py index 8434f50..52edc5d 100644 --- a/gen_definitions.py +++ b/gen_definitions.py @@ -448,8 +448,8 @@ class SLuaParameter: @dataclasses.dataclass -class SLuaFunctionOverload: - """Function overload signature""" +class SLuaFunctionAnon: + """Annonymous function signature""" parameters: List[SLuaParameter] returnType: str @@ -457,8 +457,8 @@ class SLuaFunctionOverload: @dataclasses.dataclass -class SLuaFunctionSignature: - """Function or method signature with optional overloads""" +class SLuaFunction: + """Full function or method signature with optional overloads""" name: str parameters: List[SLuaParameter] @@ -467,7 +467,7 @@ class SLuaFunctionSignature: comment: str = "" private: bool = False deprecated: bool = False - overloads: Optional[List[SLuaFunctionOverload]] = None + overloads: Optional[List[SLuaFunctionAnon]] = None def to_keywords_dict(self) -> dict: return _remove_worthless( @@ -519,7 +519,7 @@ class SLuaClassDeclaration: name: str properties: List[SLuaProperty] - methods: List[SLuaFunctionSignature] + methods: List[SLuaFunction] comment: str = "" def to_keywords_dict(self) -> dict: @@ -531,9 +531,9 @@ class SLuaModuleDeclaration: """Module declaration with properties and functions""" name: str - callable: Optional[SLuaFunctionSignature] + callable: Optional[SLuaFunction] properties: List[SLuaProperty] - functions: List[SLuaFunctionSignature] + functions: List[SLuaFunction] comment: str = "" def to_keywords_functions_dict(self) -> dict: @@ -565,7 +565,7 @@ class SLuaDefinitions(NamedTuple): controls: dict # same structure as LSLDefinitions.controls builtinTypes: dict # same structure as LSLDefinitions.types builtinConstants: List[SLuaProperty] - builtinFunctions: List[SLuaFunctionSignature] + builtinFunctions: List[SLuaFunction] # 2. SLua base classes. These only depend on Luau builtins baseClasses: List[SLuaClassDeclaration] @@ -573,7 +573,7 @@ class SLuaDefinitions(NamedTuple): # 3. SLua standard library. Depends on base classes classes: List[SLuaClassDeclaration] - globalFunctions: List[SLuaFunctionSignature] + globalFunctions: List[SLuaFunction] modules: List[SLuaModuleDeclaration] globalVariables: List[SLuaProperty] @@ -898,11 +898,9 @@ def _validate_class(self, data: any) -> SLuaClassDeclaration: raise ValueError(f"In class {class_.name}: {e}") from e return class_ - def _validate_function( - self, data: any, scope: Set[str], method: bool = False - ) -> SLuaFunctionSignature: + def _validate_function(self, data: any, scope: Set[str], method: bool = False) -> SLuaFunction: try: - func = SLuaFunctionSignature( + func = SLuaFunction( name=data["name"], typeParameters=data.get("typeParameters", []), parameters=[SLuaParameter(**p) for p in data.get("parameters", [])], From d650486f89f07d3c9a4b3e542908816a8efe47a5 Mon Sep 17 00:00:00 2001 From: tapple Date: Mon, 26 Jan 2026 08:38:35 -0800 Subject: [PATCH 092/102] validate functions --- slua_definitions.schema.json | 79 ++++++++++++++++++++++++++++++++++-- 1 file changed, 76 insertions(+), 3 deletions(-) diff --git a/slua_definitions.schema.json b/slua_definitions.schema.json index b9a4b71..40c9828 100644 --- a/slua_definitions.schema.json +++ b/slua_definitions.schema.json @@ -31,12 +31,12 @@ "type": "string" }, "type": { - "markdownDescription": "A luau-format type definition", + "markdownDescription": "A luau-format type definition.", "pattern": "^([ \n?&|,{}\\[\\]()\":a-zA-Z0-9_]|\\.\\.\\.|->)*$", "type": "string" }, "property": { - "markdownDescription": "A property or constant", + "markdownDescription": "A property or constant.", "additionalProperties": false, "properties": { "name": { "$ref": "#/$defs/identifier" }, @@ -57,8 +57,73 @@ }, "required": ["name", "type"], "type": "object" + }, + "function-parameter": { + "markdownDescription": "A function parameter.", + "additionalProperties": false, + "properties": { + "name": { "oneOf": [ + { "$ref": "#/$defs/identifier" }, + { "const": "...", "type": "string" } + ]}, + "type": { "$ref": "#/$defs/type" }, + "comment": { + "markdownDescription": "A brief description of this parameter.", + "type": "string" + } + }, + "required": ["name"], + "type": "object" + }, + "function-anon": { + "markdownDescription": "A plain function signature; no name or overloads.", + "additionalProperties": false, + "properties": { + "typeParameters": { + "items": { + "pattern": "^(\\.\\.\\.)?[_a-zA-Z][_a-zA-Z0-9]*(\\.\\.\\.)?$", + "type": "string" + }, + "type": "array" + }, + "parameters": { + "items": { "$ref": "#/$defs/function-parameter" }, + "type": "array" + }, + "returnType": { "$ref": "#/$defs/type" }, + "comment": { + "markdownDescription": "A brief description of this function.", + "type": "string" + } + }, + "required": [], + "type": "object" + }, + "function": { + "markdownDescription": "A full function signature.", + "additionalProperties": false, + "properties": { + "name": { "$ref": "#/$defs/identifier" }, + "typeParameters": { + "items": { + "pattern": "^(\\.\\.\\.)?[_a-zA-Z][_a-zA-Z0-9]*(\\.\\.\\.)?$", + "type": "string" + }, + "type": "array" + }, + "parameters": { + "items": { "$ref": "#/$defs/function-parameter" }, + "type": "array" + }, + "returnType": { "$ref": "#/$defs/type" }, + "comment": { + "markdownDescription": "A brief description of this function.", + "type": "string" + } + }, + "required": ["name"], + "type": "object" } - }, "additionalProperties": false, "properties": { @@ -66,6 +131,10 @@ "items": { "$ref": "#/$defs/property" }, "type": "array" }, + "globalFunctions": { + "items": { "$ref": "#/$defs/function" }, + "type": "array" + }, "constants": { "items": { "$ref": "#/$defs/property" }, "type": "array" @@ -74,6 +143,10 @@ "items": { "$ref": "#/$defs/property" }, "type": "array" }, + "builtinFunctions": { + "items": { "$ref": "#/$defs/function" }, + "type": "array" + }, "controls": { "additionalProperties": false, "patternProperties": { From 500d3377d9f1ee6a213848e74e16d2b36ecd92ba Mon Sep 17 00:00:00 2001 From: tapple Date: Mon, 26 Jan 2026 08:49:28 -0800 Subject: [PATCH 093/102] delete extra cruft from the lsl schema --- slua_definitions.schema.json | 455 +---------------------------------- 1 file changed, 11 insertions(+), 444 deletions(-) diff --git a/slua_definitions.schema.json b/slua_definitions.schema.json index 40c9828..02571f1 100644 --- a/slua_definitions.schema.json +++ b/slua_definitions.schema.json @@ -3,29 +3,6 @@ "$id": "http://raw.githubusercontent.com/secondlife/lsl-definitions/refs/heads/main/slua_definitions.schema.json", "$comment": "This schema defines keywords for the Server Lua Language (SLua) of Second Life.", "$defs": { - "nonNegativeInteger": { - "minimum": 0, - "type": "integer" - }, - "nonNegativeIntegerDefault0": { - "allOf": [ - { "$ref": "#/$defs/nonNegativeInteger" }, - { "default": 0 } - ] - }, - "nonNegativeNumber": { - "minimum": 0.0, - "type": "number" - }, - "positiveInteger": { - "exclusiveMinimum": 0, - "type": "integer" - }, - "zeroToOneNumber": { - "maximum": 1.0, - "minimum": 0.0, - "type": "number" - }, "identifier": { "pattern": "^[_a-zA-Z][_a-zA-Z0-9]*$", "type": "string" @@ -127,6 +104,11 @@ }, "additionalProperties": false, "properties": { + "version": { + "markdownDescription": "Only increment with file format changes.", + "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$", + "type": "string" + }, "globalVariables": { "items": { "$ref": "#/$defs/property" }, "type": "array" @@ -148,443 +130,28 @@ "type": "array" }, "controls": { + "markdownDescription": "The Luau keywords.", "additionalProperties": false, "patternProperties": { "^(?:[a-z]+)$": { "properties": { "tooltip": { - "markdownDescription": "A brief description of this control (keyword).", + "markdownDescription": "A brief description of this keyword.", "type": "string" } }, - "required": [ - "tooltip" - ], + "required": ["tooltip"], "type": "object" } }, "type": "object" }, - "events": { - "additionalProperties": false, - "patternProperties": { - "^[a-z_]+$": { - "additionalProperties": false, - "properties": { - "arguments": { - "items": { - "additionalProperties": false, - "patternProperties": { - "^(?:[A-Za-z]+(?:_[A-Za-z]+)*)$": { - "properties": { - "tooltip": { - "markdownDescription": "A brief description of this event argument.", - "type": "string" - }, - "type": { - "defaultSnippets": [ - { - "label": "float", - "body": "float" - }, - { - "label": "integer", - "body": "integer" - }, - { - "label": "key", - "body": "key" - }, - { - "label": "list", - "body": "list" - }, - { - "label": "quaternion", - "body": "quaternion" - }, - { - "label": "rotation", - "body": "rotation" - }, - { - "label": "string", - "body": "string" - }, - { - "label": "vector", - "body": "vector" - } - ], - "markdownDescription": "One of the valid types for this event argument: [float, integer, key, list, rotation, string, vector].", - "oneOf": [ - { "const": "float" }, - { "const": "integer" }, - { "const": "key" }, - { "const": "list" }, - { - "$comment": "quaternion is an alias for rotation", - "const": "quaternion" - }, - { "const": "rotation" }, - { "const": "string" }, - { "const": "vector" } - ] - } - }, - "required": [ - "type" - ], - "type": "object" - } - }, - "type": "object" - }, - "markdownDescription": "An array of event arguments.", - "minItems": 0, - "type": "array", - "uniqueItems": true - }, - "detected-semantics": { - "const": true, - "markdownDescription": "Uses llDetected* in LSL and {DetectedEvent} in SLua.", - "type": "boolean" - }, - "deprecated": { - "const": true, - "markdownDescription": "This event has been deprecated.", - "type": "boolean" - }, - "slua-deprecated": { - "const": true, - "markdownDescription": "This event has been deprecated in SLua.", - "type": "boolean" - }, - "slua-removed": { - "const": true, - "markdownDescription": "This event has been removed in SLua.", - "type": "boolean" - }, - "tooltip": { - "markdownDescription": "A brief description of this event.", - "type": "string" - } - } - } - }, - "type": "object" - }, - "functions": { + "builtinTypes": { + "markdownDescription": "The Luau builtin types.", "additionalProperties": false, "patternProperties": { - "^ll[A-Zs](?:[A-Z0-9]*[a-z]*)+$": { - "additionalProperties": false, - "properties": { - "type-arguments": { - "items": { - "additionalProperties": false, - "patternProperties": { - "^(?:[A-Za-z]+)$": { - "markdownDescription": "A type variable name for slua typechecking." - } - }, - "type": "string" - }, - "markdownDescription": "An array of type variable names for slua typechecking.", - "type": "array", - "uniqueItems": true - }, - "arguments": { - "items": { - "additionalProperties": false, - "patternProperties": { - "^(?:[A-Za-z]+(?:[A-z0-9-_]+)*)$": { - "additionalProperties": false, - "properties": { - "bool-semantics": { - "const": true, - "markdownDescription": "This function argument's integer value represents a boolean value.", - "type": "boolean" - }, - "index-semantics": { - "const": true, - "markdownDescription": "This function argument's integer value represents a zero-based index.", - "type": "boolean" - }, - "tooltip": { - "markdownDescription": "A brief description of this function argument.", - "type": "string" - }, - "type": { - "defaultSnippets": [ - { - "label": "float", - "body": "float" - }, - { - "label": "integer", - "body": "integer" - }, - { - "label": "key", - "body": "key" - }, - { - "label": "list", - "body": "list" - }, - { - "label": "quaternion", - "body": "quaternion" - }, - { - "label": "rotation", - "body": "rotation" - }, - { - "label": "string", - "body": "string" - }, - { - "label": "vector", - "body": "vector" - } - ], - "markdownDescription": "One of the valid types for this function argument:\n- float\n- integer\n- key\n- list\n- rotation\n- string\n- vector", - "oneOf": [ - { "const": "float" }, - { "const": "integer" }, - { "const": "key" }, - { "const": "list" }, - { - "$comment": "quaternion is an alias for rotation", - "const": "quaternion" - }, - { "const": "rotation" }, - { "const": "string" }, - { "const": "vector" } - ] - }, - "slua-type": { - "markdownDescription": "A more specific argument type for slua type-checking.", - "type": "string" - } - }, - "required": [ - "type" - ], - "type": "object" - } - }, - "type": "object" - }, - "markdownDescription": "An array of function arguments.", - "type": "array", - "uniqueItems": true - }, - "bool-semantics": { - "const": true, - "markdownDescription": "The returned integer value represents a boolean value.", - "type": "boolean" - }, - "deprecated": { - "const": true, - "markdownDescription": "This function has been deprecated.", - "type": "boolean" - }, - "detected-semantics": { - "const": true, - "markdownDescription": "This function is wrapped in the DetectedEvent class.", - "type": "boolean" - }, - "energy": { - "$ref": "#/$defs/nonNegativeNumber", - "markdownDescription": "The script energy consumed by this function." - }, - "experience": { - "const": true, - "markdownDescription": "This function requires an experience to be set for the script to compile.", - "type": "boolean" - }, - "func-id": { - "$comment": "llSin has 'func-id: 0', so we must include zero", - "$ref": "#/$defs/nonNegativeInteger", - "markdownDescription": "The LSO function identifier." - }, - "god-mode": { - "const": true, - "markdownDescription": "This function can only be executed in god mode.", - "type": "boolean" - }, - "index-semantics": { - "const": true, - "markdownDescription": "The returned integer value represents a zero-based index.", - "type": "boolean" - }, - "linden-experience": { - "const": true, - "markdownDescription": "This function requires a Linden-owned experience.", - "type": "boolean" - }, - "mono-sleep": { - "$ref": "#/$defs/nonNegativeNumber", - "markdownDescription": "Sleep in the mono-script runtime." - }, - "must-use": { - "const": true, - "markdownDescription": "This functions return value should not be discarded but further used.", - "type": "boolean" - }, - "native": { - "const": true, - "markdownDescription": "This function must use a native implementation for non-LSO VMs.", - "type": "boolean" - }, - "private": { - "const": true, - "markdownDescription": "This function should be omitted from the generated documentation.", - "type": "boolean" - }, - "pure": { - "const": true, - "markdownDescription": "This function is guaranteed to have no side effects.", - "type": "boolean" - }, - "return": { - "default": "void", - "defaultSnippets": [ - { - "label": "float", - "body": "float" - }, - { - "label": "integer", - "body": "integer" - }, - { - "label": "key", - "body": "key" - }, - { - "label": "list", - "body": "list" - }, - { - "label": "quaternion", - "body": "quaternion" - }, - { - "label": "rotation", - "body": "rotation" - }, - { - "label": "string", - "body": "string" - }, - { - "label": "vector", - "body": "vector" - }, - { - "label": "void", - "body": "void" - } - ], - "markdownDescription": "One of the valid return types for functions:\n\n- float\n- integer\n- key\n- list\n- rotation\n- string\n- vector\n- void\n\nIf omitted, it is assumed to be void.", - "oneOf": [ - { "const": "float" }, - { "const": "integer" }, - { "const": "key" }, - { "const": "list" }, - { - "$comment": "quaternion is an alias for rotation", - "const": "quaternion" - }, - { "const": "rotation" }, - { "const": "string" }, - { "const": "vector" }, - { "const": "void" } - ] - }, - "slua-deprecated": { - "const": true, - "markdownDescription": "This function is deprecated in SLua.", - "type": "boolean" - }, - "slua-removed": { - "const": true, - "markdownDescription": "In SLua, this function has been removed from ll module and only exists in llcompat.", - "type": "boolean" - }, - "slua-return": { - "markdownDescription": "A more specific return type for slua type-checking.", - "type": "string" - }, - "sleep": { - "$ref": "#/$defs/nonNegativeNumber", - "markdownDescription": "Additional sleep time imposed by the script after this function completes." - }, - "tooltip": { - "markdownDescription": "A brief description of this function.", - "type": "string" - } - }, - "required": [ - "tooltip" - ] - } - }, - "type": "object" - }, - "llsd-lsl-syntax-version": { - "$ref": "#/$defs/positiveInteger", - "markdownDescription": "Only increment with file format changes." - }, - "types": { - "additionalProperties": false, - "defaultSnippets": [ - { - "label": "float", - "body": "float" - }, - { - "label": "integer", - "body": "integer" - }, - { - "label": "key", - "body": "key" - }, - { - "label": "list", - "body": "list" - }, - { - "label": "quaternion", - "body": "quaternion" - }, - { - "label": "rotation", - "body": "rotation" - }, - { - "label": "string", - "body": "string" - }, - { - "label": "vector", - "body": "vector" - } - ], - "markdownDescription": "The valid LSL storage types:\n\n- float\n- integer\n- key\n- list\n- rotation\n- string\n- vector", - "patternProperties": { - "^(?:float|integer|key|list|quaternion|rotation|string|vector)$": { + "^[a-z]*": { "properties": { - "private": { - "const": true, - "markdownDescription": "This type should be omitted from the generated documentation.", - "type": "boolean" - }, "tooltip": { "markdownDescription": "A brief description of this type.", "type": "string" From ff31ecb8d606fff4e8059248e6c974f6134a6c4e Mon Sep 17 00:00:00 2001 From: tapple Date: Mon, 26 Jan 2026 08:54:26 -0800 Subject: [PATCH 094/102] validate classes --- slua_definitions.schema.json | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/slua_definitions.schema.json b/slua_definitions.schema.json index 02571f1..3b6c5da 100644 --- a/slua_definitions.schema.json +++ b/slua_definitions.schema.json @@ -100,6 +100,27 @@ }, "required": ["name"], "type": "object" + }, + "class": { + "markdownDescription": "A type with properties and methods.", + "additionalProperties": false, + "properties": { + "name": { "$ref": "#/$defs/identifier" }, + "properties": { + "items": { "$ref": "#/$defs/property" }, + "type": "array" + }, + "methods": { + "items": { "$ref": "#/$defs/function" }, + "type": "array" + }, + "comment": { + "markdownDescription": "A brief description of this type.", + "type": "string" + } + }, + "required": ["name"], + "type": "object" } }, "additionalProperties": false, @@ -109,6 +130,14 @@ "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$", "type": "string" }, + "baseClasses": { + "items": { "$ref": "#/$defs/class" }, + "type": "array" + }, + "classes": { + "items": { "$ref": "#/$defs/class" }, + "type": "array" + }, "globalVariables": { "items": { "$ref": "#/$defs/property" }, "type": "array" From a95dc6601174b3a43755d67d31bb313651f8c807 Mon Sep 17 00:00:00 2001 From: tapple Date: Mon, 26 Jan 2026 08:58:26 -0800 Subject: [PATCH 095/102] validate type aliases --- slua_definitions.schema.json | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/slua_definitions.schema.json b/slua_definitions.schema.json index 3b6c5da..fc90fb6 100644 --- a/slua_definitions.schema.json +++ b/slua_definitions.schema.json @@ -35,6 +35,25 @@ "required": ["name", "type"], "type": "object" }, + "type-alias": { + "markdownDescription": "A type alias.", + "additionalProperties": false, + "properties": { + "name": { "$ref": "#/$defs/identifier" }, + "definition": { "$ref": "#/$defs/type" }, + "comment": { + "markdownDescription": "A brief description of this alias.", + "type": "string" + }, + "export": { + "const": true, + "markdownDescription": "Whether this type is available to users.", + "type": "boolean" + } + }, + "required": ["name", "definition"], + "type": "object" + }, "function-parameter": { "markdownDescription": "A function parameter.", "additionalProperties": false, @@ -134,6 +153,10 @@ "items": { "$ref": "#/$defs/class" }, "type": "array" }, + "typeAliases": { + "items": { "$ref": "#/$defs/type-alias" }, + "type": "array" + }, "classes": { "items": { "$ref": "#/$defs/class" }, "type": "array" From fa06281e1a82f3d94077473a986f5da542ef3049 Mon Sep 17 00:00:00 2001 From: tapple Date: Mon, 26 Jan 2026 09:02:51 -0800 Subject: [PATCH 096/102] rename module properties to constants --- gen_definitions.py | 11 ++++++----- slua_definitions.yaml | 10 +++++----- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/gen_definitions.py b/gen_definitions.py index 52edc5d..2ef6a15 100644 --- a/gen_definitions.py +++ b/gen_definitions.py @@ -499,6 +499,7 @@ class SLuaTypeAlias: definition: str comment: str = "" export: bool = False + """Whether this type is available to users""" def to_keywords_dict(self) -> dict: definition = self.to_luau_def() @@ -532,7 +533,7 @@ class SLuaModuleDeclaration: name: str callable: Optional[SLuaFunction] - properties: List[SLuaProperty] + constants: List[SLuaProperty] functions: List[SLuaFunction] comment: str = "" @@ -554,7 +555,7 @@ def to_keywords_functions_dict(self) -> dict: def to_keywords_constants_dict(self) -> dict: return { f"{self.name}.{prop.name}": prop.to_keywords_dict() - for prop in sorted(self.properties, key=lambda x: x.name) + for prop in sorted(self.constants, key=lambda x: x.name) } @@ -851,7 +852,7 @@ def _validate_module(self, data: any) -> SLuaModuleDeclaration: name=data["name"], comment=data.get("comment", ""), callable=None, - properties=[], + constants=[], functions=[], ) try: @@ -864,9 +865,9 @@ def _validate_module(self, data: any) -> SLuaModuleDeclaration: if module.callable.name != module.name: raise ValueError("module.callable.name must match module.name") module_scope.clear() - module.properties = [ + module.constants = [ self._validate_property(prop, module_scope, const=True) - for prop in data.get("properties", []) + for prop in data.get("constants", []) ] module.functions = [ self._validate_function(function, module_scope) diff --git a/slua_definitions.yaml b/slua_definitions.yaml index b158f4d..f06261a 100644 --- a/slua_definitions.yaml +++ b/slua_definitions.yaml @@ -994,7 +994,7 @@ modules: - name: json type: string returnType: any - properties: + constants: - name: 'null' comment: A constant to pass for null to json encode type: any @@ -1334,7 +1334,7 @@ modules: comment: A number. type: number returnType: boolean - properties: + constants: - name: pi comment: The value of pi type: number @@ -1479,7 +1479,7 @@ modules: comment: Input quaternion. type: quaternion returnType: vector - properties: + constants: - name: identity comment: Identity quaternion constant. type: quaternion @@ -1936,7 +1936,7 @@ modules: comment: Starting index (optional). type: number? returnType: number? - properties: + constants: - name: charpattern comment: Pattern that matches exactly one UTF-8 byte sequence type: string @@ -2114,7 +2114,7 @@ modules: comment: Interpolation factor. type: number returnType: vector - properties: + constants: - name: zero comment: Constant vector with all components set to 0. type: vector From aea8d489d93974fb357f2e3d701d9c7f5bc37670 Mon Sep 17 00:00:00 2001 From: tapple Date: Mon, 26 Jan 2026 09:04:37 -0800 Subject: [PATCH 097/102] renamed ModuleDeclaration to Module --- gen_definitions.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gen_definitions.py b/gen_definitions.py index 2ef6a15..dddf0cb 100644 --- a/gen_definitions.py +++ b/gen_definitions.py @@ -528,8 +528,8 @@ def to_keywords_dict(self) -> dict: @dataclasses.dataclass -class SLuaModuleDeclaration: - """Module declaration with properties and functions""" +class SLuaModule: + """Module declaration with constants and functions""" name: str callable: Optional[SLuaFunction] @@ -575,7 +575,7 @@ class SLuaDefinitions(NamedTuple): # 3. SLua standard library. Depends on base classes classes: List[SLuaClassDeclaration] globalFunctions: List[SLuaFunction] - modules: List[SLuaModuleDeclaration] + modules: List[SLuaModule] globalVariables: List[SLuaProperty] @@ -847,8 +847,8 @@ def _parse_dict(self, def_dict: dict) -> SLuaDefinitions: return self.definitions - def _validate_module(self, data: any) -> SLuaModuleDeclaration: - module = SLuaModuleDeclaration( + def _validate_module(self, data: any) -> SLuaModule: + module = SLuaModule( name=data["name"], comment=data.get("comment", ""), callable=None, From 592e960d16d2226214289c98a1577f930f556d7a Mon Sep 17 00:00:00 2001 From: tapple Date: Mon, 26 Jan 2026 09:06:25 -0800 Subject: [PATCH 098/102] validate modules --- slua_definitions.schema.json | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/slua_definitions.schema.json b/slua_definitions.schema.json index fc90fb6..160e59d 100644 --- a/slua_definitions.schema.json +++ b/slua_definitions.schema.json @@ -140,6 +140,28 @@ }, "required": ["name"], "type": "object" + }, + "module": { + "markdownDescription": "A table with constants and functions.", + "additionalProperties": false, + "properties": { + "name": { "$ref": "#/$defs/identifier" }, + "callable": { "$ref": "#/$defs/function" }, + "constants": { + "items": { "$ref": "#/$defs/property" }, + "type": "array" + }, + "functions": { + "items": { "$ref": "#/$defs/function" }, + "type": "array" + }, + "comment": { + "markdownDescription": "A brief description of this type.", + "type": "string" + } + }, + "required": ["name", "comment"], + "type": "object" } }, "additionalProperties": false, @@ -169,6 +191,10 @@ "items": { "$ref": "#/$defs/function" }, "type": "array" }, + "modules": { + "items": { "$ref": "#/$defs/module" }, + "type": "array" + }, "constants": { "items": { "$ref": "#/$defs/property" }, "type": "array" From 8a0ea3140b611816f634430662f5201304a791d1 Mon Sep 17 00:00:00 2001 From: tapple Date: Mon, 26 Jan 2026 09:11:03 -0800 Subject: [PATCH 099/102] fix validation errors --- slua_definitions.schema.json | 16 +++++++++++++++- slua_definitions.yaml | 1 - 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/slua_definitions.schema.json b/slua_definitions.schema.json index 160e59d..d16a892 100644 --- a/slua_definitions.schema.json +++ b/slua_definitions.schema.json @@ -20,7 +20,7 @@ "type": { "$ref": "#/$defs/type" }, "value": { "markdownDescription": "The value of the constant.", - "type": ["integer", "string"] + "type": ["number", "string"] }, "comment": { "markdownDescription": "A brief description of this constant.", @@ -112,6 +112,20 @@ "type": "array" }, "returnType": { "$ref": "#/$defs/type" }, + "overloads": { + "items": { "$ref": "#/$defs/function-anon" }, + "type": "array" + }, + "deprecated": { + "const": true, + "markdownDescription": "Function is deprecated.", + "type": "boolean" + }, + "private": { + "const": true, + "markdownDescription": "Don't include in documentation.", + "type": "boolean" + }, "comment": { "markdownDescription": "A brief description of this function.", "type": "string" diff --git a/slua_definitions.yaml b/slua_definitions.yaml index f06261a..f0da3e0 100644 --- a/slua_definitions.yaml +++ b/slua_definitions.yaml @@ -96,7 +96,6 @@ baseClasses: - name: __mul comment: 'Multiplication: vector * vector / number -> vector (Scale), vector * quaternion -> vector (Rotation)' - luaReturnType: vector parameters: - name: self - name: other From a97a5a20ee7093ee832fe9263bb4a07b519d6b34 Mon Sep 17 00:00:00 2001 From: tapple Date: Mon, 26 Jan 2026 09:58:15 -0800 Subject: [PATCH 100/102] reverted c_compat --- gen_definitions.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gen_definitions.py b/gen_definitions.py index dddf0cb..61e58d8 100644 --- a/gen_definitions.py +++ b/gen_definitions.py @@ -1046,9 +1046,9 @@ def dump_syntax(definitions: LSLDefinitions, pretty: bool = False) -> bytes: } if pretty: - return llsd.format_pretty_xml(syntax, indent=3, c_compat=True, sort_maps=False) + return llsd.format_pretty_xml(syntax, indent=3, sort_maps=False) else: - return llsd.format_xml(syntax, c_compat=True, sort_maps=True) + return llsd.format_xml(syntax, sort_maps=True) def dump_slua_syntax( @@ -1105,9 +1105,9 @@ def dump_slua_syntax( syntax["constants"][const.name] = const.to_slua_dict(parser) if pretty: - return llsd.format_pretty_xml(syntax, indent=3, c_compat=True, sort_maps=False) + return llsd.format_pretty_xml(syntax, indent=3, sort_maps=False) else: - return llsd.format_xml(syntax, c_compat=True, sort_maps=True) + return llsd.format_xml(syntax, sort_maps=True) def _write_if_different(filename: str, data: Union[bytes, str]): From 452e3586367864dd7256521d5d52210e27618a18 Mon Sep 17 00:00:00 2001 From: tapple Date: Mon, 26 Jan 2026 10:29:41 -0800 Subject: [PATCH 101/102] downgrade the llsd requirement to the currently released one --- gen_definitions.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gen_definitions.py b/gen_definitions.py index 61e58d8..fc6c527 100644 --- a/gen_definitions.py +++ b/gen_definitions.py @@ -1046,9 +1046,9 @@ def dump_syntax(definitions: LSLDefinitions, pretty: bool = False) -> bytes: } if pretty: - return llsd.format_pretty_xml(syntax, indent=3, sort_maps=False) + return llsd.LLSDXMLPrettyFormatter(indent_atom=b" ").format(syntax) else: - return llsd.format_xml(syntax, sort_maps=True) + return llsd.format_xml(syntax) def dump_slua_syntax( @@ -1105,9 +1105,9 @@ def dump_slua_syntax( syntax["constants"][const.name] = const.to_slua_dict(parser) if pretty: - return llsd.format_pretty_xml(syntax, indent=3, sort_maps=False) + return llsd.LLSDXMLPrettyFormatter(indent_atom=b" ").format(syntax) else: - return llsd.format_xml(syntax, sort_maps=True) + return llsd.format_xml(syntax) def _write_if_different(filename: str, data: Union[bytes, str]): From 0d30824be0ec2812b712a80067b5f8877dd7bc8c Mon Sep 17 00:00:00 2001 From: tapple Date: Mon, 26 Jan 2026 14:25:23 -0800 Subject: [PATCH 102/102] fix CICD --- .github/workflows/validate.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/validate.yaml b/.github/workflows/validate.yaml index d1d7538..4644399 100644 --- a/.github/workflows/validate.yaml +++ b/.github/workflows/validate.yaml @@ -58,7 +58,7 @@ jobs: - name: Check if SLua syntax generation produces valid output run: | # Generate syntax to a temporary file to verify it's valid - gen-lsl-definitions ./lsl_definitions.yaml slua-syntax ./slua_definitions.yaml /tmp/slua_syntax_output.llsd + gen-lsl-definitions ./lsl_definitions.yaml slua_syntax ./slua_definitions.yaml /tmp/slua_syntax_output.llsd # Check that the output file was created and is not empty if [ ! -s /tmp/slua_syntax_output.llsd ]; then echo "Error: SLua Syntax generation produced empty output"