Page MenuHomeFeedback Tracker

getVariable on a task does not return previously assigned value
Acknowledged, WishlistPublic

Description

Tasks used to be eligible as a target for setVariable/getVariable and are still documented as such (https://community.bistudio.com/wiki/getVariable).

I used this in some mission designs but they are now throwing an error when trying to call getVariable. setVariable seems to be fine.

[Edit]
Per Killzone Kid's note, getVariable against a task apparently doesn't support an array (so key,default) argument. I've updated the steps to reproduce.

Details

Legacy ID
2364572505
Severity
None
Resolution
Open
Reproducibility
Always
Category
Scripting
Steps To Reproduce

testTask = player createSimpletask ["Test Task"];
testTask setVariable ["Test",1];
diag_log format["%1: %2",time,(testTask getVariable "Test")];

Output is as follows:

"7.904: <null>"

Additional Information

This was the original "steps to reproduce" that worked "way back" (sometime in 2014) and now throws an error. Since the wiki says getVariable against a Task object can't take an array, I've changed the report but wanted to leave this in case it is helpful.

testTask = player createSimpletask ["Test Task"];
testTask setVariable ["TestValue",1];
testTask getVariable ["TestValue",0];

Throws at getVariable
Error Generic error in expression

Event Timeline

cameroon edited Steps To Reproduce. (Show Details)Jul 26 2015, 5:13 PM
cameroon edited Additional Information. (Show Details)
cameroon set Category to Scripting.
cameroon set Reproducibility to Always.
cameroon set Severity to None.
cameroon set Resolution to Open.
cameroon set Legacy ID to 2364572505.May 8 2016, 12:27 PM

Wiki doesnt say you can
task getVariable ARRAY

Ok, that's true the wiki doesn't say that getVariable against a task supports a default value, though it did work that way before.

But even using only the syntax that the wiki has, it's still broken:

testTask = player createSimpletask ["Test Task"];
testTask setVariable ["Test",1];
diag_log format["%1: %2",time,(testTask getVariable "Test")];

Output is as follows:

"7.904: <null>"

--

I'll update the Steps to Reproduce to use syntax the wiki says should work

"though it did work that way before."

It didn't because it couldn't. Both Arma2 OA and Arma 3 have the following syntax for get/setvariable with task:

"b:TASK setvariable ARRAY"
"b:TASK getvariable STRING"

As you can see, it never had TASK getvariable ARRAY

Also, I just tested set/getvar in A2OA and it doesn't work there either. Basically this functionality is broken for a long time.

I was actively using it in an Arma 3 mission where it was working. That was in 2014 at some point, not sure exactly when because I've been away from A3 for awhile.

I'm pretty sure I even remember reading a note at some point about getVar/setVar being added for tasks, though I can't remember where.

I'm pretty sure you are confusing this with something else. Open Arma 2 OA and try it. Same syntax, same broken functionality. It has been like this for ages.

I believe you that it doesn't work in A2, but I only built the mission in A3 - after one of the game mode updates. The one where the AI could request transport after the helicopters DLC.

I was flying the mission with no errors and with everything working in the scripts, otherwise I wouldn't have come to report it.

When I'm back at a computer with some time I'll see if I can find the note that you can setVar/getVar on tasks, but ultimately its broken now/still and should be fixed.