Page MenuHomeFeedback Tracker

Using <LOCATION> getVariable [<STRING>, <ANY>] will throw "Generic Error"
Closed, ResolvedPublic

Description

Currently, the getVariable command wont work as expected on locations with its alternative syntax (without a default value --> only string, it will work as expected)

Details

Legacy ID
603081175
Severity
None
Resolution
No Bug
Reproducibility
Always
Category
Scripting
Steps To Reproduce

Execute following code somewhere in your environment

GVAR_GVARS_missionContext = createLocation ["NameVillage", [0, 0, 0], 0, 0];
GVAR_GVARS_missionContext getVariable [ "MissionReady" , false ]

Event Timeline

X39 edited Steps To Reproduce. (Show Details)Jan 1 2016, 6:30 AM
X39 set Category to Scripting.
X39 set Reproducibility to Always.
X39 set Severity to None.
X39 set Resolution to No Bug.
X39 set Legacy ID to 603081175.May 8 2016, 1:24 PM
X39 edited a custom field.
commy2 added a subscriber: commy2.May 8 2016, 1:24 PM

Can confirm this issue. RPT says:

11:46:45 Error in expression <LOC getVariable ["Test", 2]>
11:46:45 Error position: <getVariable ["Test", 2]>
11:46:46 Error Generic error in expression

for me.

Wiki claims that the alternative syntax is supposed to work with locations:

Syntax:

varspace getVariable [name, defaultValue]

Parameters:

    varspace: [Namespace]], Object, Display, Control, Group, Location, Task or Team Member

https://community.bistudio.com/wiki/getVariable

This is not a bug but rather a copy paste mistake on wiki. You can always check supported syntax either using in game help F1 or by looking it up with supportInfo command.

X39 added a subscriber: X39.May 8 2016, 1:24 PM
X39 added a comment.Jan 1 2016, 4:33 PM

tbh this is the biggest BS i have ever had to read

the alternative syntax adds a default value thus it is not a C&P mistake on the wiki but more that somebody at BI forgot to C&P the default part for locations

i cannot see a valid reason why locations should not have default values in getVariable

TASK and LOCATION both support only STRING argument:

"b:TASK getvariable STRING"
"b:LOCATION getvariable STRING"

This is why both throw error when ARRAY is passed. Both variants are also pretty old and alt syntax was simply never implemented. I resolved this ticket because according to its content, this is not a bug. But feel free to make a feature request to extend functionality.