You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
GML has some peculiar quirks regarding scope that make library authorship a challenge. Specifically, there are at least three situations in which a variable name is always reserved, and will override local and object variables when referenced. These are:
For any expression where a library references a variable name as a value, for example type in the expressions thisType = type and thisType = structOrId.type, any of the above 3 cases will result in behaviour undefined by the library, where thisType will be assigned the value of the asset reference, function reference, or globalvar value of type instead of the value of the variable of the same name within the scope of reference as expected.
There is no great solution for this so Input will settle for a compromise: library variables are prefixed with two underscores (usually reserved to indicate "private" variables) even when they are exposed by the API as public struct members, as for example with input bindings.
This change is a large effort that touches many corners of the project and will be rolled out gradually.
The text was updated successfully, but these errors were encountered:
offalynne
changed the title
__privatise class fields
Rename public variables to avoid conflict with library user scope
May 27, 2024
offalynne
changed the title
Rename public variables to avoid conflict with library user scope
Rename public vars to avoid conflict with user scope
May 27, 2024
offalynne
changed the title
Rename public vars to avoid conflict with user scope
Rename public vars to avoid conflict with library user scope
May 27, 2024
GML has some peculiar quirks regarding scope that make library authorship a challenge. Specifically, there are at least three situations in which a variable name is always reserved, and will override local and object variables when referenced. These are:
globalvar
name (Deprecated)For any expression where a library references a variable name as a value, for example
type
in the expressionsthisType = type
andthisType = structOrId.type
, any of the above 3 cases will result in behaviour undefined by the library, wherethisType
will be assigned the value of the asset reference, function reference, or globalvar value oftype
instead of the value of the variable of the same name within the scope of reference as expected.There is no great solution for this so Input will settle for a compromise: library variables are prefixed with two underscores (usually reserved to indicate "private" variables) even when they are exposed by the API as public struct members, as for example with input bindings.
This change is a large effort that touches many corners of the project and will be rolled out gradually.
The text was updated successfully, but these errors were encountered: