Sertica 18 Posted February 4, 2020 Quote 10:21:43 Error in expression <ique groupId _x; _westGroupsTargetQuant count (leader _x) targets [true]; _list > 10:21:43 Error position: <count (leader _x) targets [true]; _list > 10:21:43 Error count: Type Array, expected code 10:21:43 File H:\Storage\Win7-64\C - Home Basic\Arma 3\missions\The%20Trees%20Have%20Eyes.Altis\text.sqf..., line 22 info = { disableSerialization; _ctrl = ((findDisplay 46) displayCtrl 9999); if (!isNull _ctrl) then {ctrlDelete _ctrl}; [] spawn { disableSerialization; _ctrl = (findDisplay 46) ctrlCreate ["RscStructuredText", 9999]; _ctrl ctrlSetPosition [-0.5, -0.5, 0.25, 5]; _ctrl ctrlSetTextColor [0, 0, 0, 1]; _ctrl ctrlSetbackgroundColor [1, 1, 1, 0.1] ; _ctrl ctrlCommit 0; _westGroups = []; _westGroupsTargetQuant = []; _list = []; while {true} do { { if (side _x == west) then { _westGroups pushBackUnique groupId _x; _westGroupsTargetQuant count (leader _x) targets [true]; _list pushBack ("Group "+(groupId _x)+" targets: "+str(count (leader _x) targets [true])+"<br/>"); } } forEach allGroups; _ctrl ctrlSetStructuredText parsetext (_list joinString ""); sleep 5; } } } I don't know why it says "Type Array, expected code". That line is intended to concatenate a bunch of stuff into a row of text. Share this post Link to post Share on other sites
Harzach 2516 Posted February 4, 2020 Just a quick look, but shouldn't _westGroupsTargetQuant count (leader _x) targets [true]; _list pushBack ("Group "+(groupId _x)+" targets: "+str(count (leader _x) targets [true])+"<br/>"); be _westGroupsTargetQuant = count (leader _x) targets [true]; _list pushBack ("Group "+(groupId _x)+" targets: "+str _westGroupsTargetQuant +"<br/>"); Share this post Link to post Share on other sites
Sertica 18 Posted February 4, 2020 I cut it down to get rid of errors. info = { disableSerialization; _ctrl = ((findDisplay 46) displayCtrl 9999); if (!isNull _ctrl) then {ctrlDelete _ctrl}; [] spawn { disableSerialization; _ctrl = (findDisplay 46) ctrlCreate ["RscStructuredText", 9999]; _ctrl ctrlSetPosition [-0.5, -0.5, 0.25, 5]; _ctrl ctrlSetTextColor [0, 0, 0, 1]; _ctrl ctrlSetbackgroundColor [1, 1, 1, 0.1]; _ctrl ctrlCommit 0; _list = []; while {true} do { { if (side _x == west) then { _targetQuant = count ((leader _x) targets [true]); _list pushBack ("Group "+(groupId _x)+" targets: "+(str _targetQuant)+"<br/>"); } } forEach allGroups; _ctrl ctrlSetStructuredText parsetext (_list joinString ""); _list resize 0; sleep 5; } } } Then I have this in the init field: call compile preprocessFileLineNumbers ("text.sqf"); null = [] spawn info; But nothing is showing on the screen. I mostly hacked this code from the vision test script. I don't entirely understand how this control stuff works. Share this post Link to post Share on other sites
Harzach 2516 Posted February 4, 2020 6 minutes ago, Sertica said: I mostly hacked this code from the vision test script. I don't entirely understand how this control stuff works. Me either, though I do know by experience that the act of repurposing existing code is fraught with peril. Sometimes you get lucky, but most of the time you end up more confused than you started. Share this post Link to post Share on other sites
gc8 974 Posted February 4, 2020 have you tried that the text control is on the screen? A test could reveal that: _ctrl ctrlSetStructuredText parsetext "Test test test"; Share this post Link to post Share on other sites
gc8 974 Posted February 4, 2020 Tested your script and I was right, the control is off the screen fix: _ctrl ctrlSetPosition [0.5, 0.5, 0.25, 5]; that puts it on center, adjust from there 1 Share this post Link to post Share on other sites
Sertica 18 Posted February 4, 2020 4 hours ago, gc8 said: Tested your script and I was right, the control is off the screen fix: _ctrl ctrlSetPosition [0.5, 0.5, 0.25, 5]; that puts it on center, adjust from there 🤔 I changed my setPos line to those numbers and I'm still not seeing it. You must be doing something else different. 5 hours ago, Harzach said: Me either, though I do know by experience that the act of repurposing existing code is fraught with peril. Sometimes you get lucky, but most of the time you end up more confused than you started. True, but there is not really a Khan Academy for everything. Share this post Link to post Share on other sites
gc8 974 Posted February 5, 2020 9 hours ago, Sertica said: I changed my setPos line to those numbers and I'm still not seeing it. You must be doing something else different. Here's the whole script that I put in init.sqf : info = { disableSerialization; _ctrl = ((findDisplay 46) displayCtrl 9999); if (!isNull _ctrl) then {ctrlDelete _ctrl}; [] spawn { disableSerialization; _ctrl = (findDisplay 46) ctrlCreate ["RscStructuredText", 9999]; _ctrl ctrlSetPosition [0.5, 0.5, 0.25, 5]; _ctrl ctrlSetTextColor [0, 0, 0, 1]; _ctrl ctrlSetbackgroundColor [1, 1, 1, 0.1]; _ctrl ctrlCommit 0; _list = []; while {true} do { { if (side _x == west) then { _targetQuant = count ((leader _x) targets [true]); _list pushBack ("Group "+(groupId _x)+" targets: "+(str _targetQuant)+"<br/>"); } } forEach allGroups; _ctrl ctrlSetStructuredText parsetext (_list joinString ""); _ctrl ctrlSetPosition [0.5, 0.5, ctrlTextWidth _ctrl, ctrlTextHeight _ctrl]; // Addition, precise size! _ctrl ctrlCommit 0; _list resize 0; sleep 5; }; }; }; call info; // Start the script! I also changed it so that the text control is resized to necessary size Share this post Link to post Share on other sites
Sertica 18 Posted February 5, 2020 It only works for me from local exec. Like [] spawn info or call info in the file does nothing, but the text shows after I local exec the same command. Share this post Link to post Share on other sites
gc8 974 Posted February 5, 2020 30 minutes ago, Sertica said: It only works for me from local exec. Like [] spawn info or call info in the file does nothing, but the text shows after I local exec the same command. are you running dedicated server? Edit: local execute is correct way because the script is supposed to run on client in order to work Share this post Link to post Share on other sites
Sertica 18 Posted February 5, 2020 It is for use only in Eden Editor. I'm making a high command ai for a persistent mission. The displays are to see what the task groups and HC is thinking while I watch in Zeus. Target spotting is one of the data sources for decision making. Share this post Link to post Share on other sites
killzone_kid 1329 Posted February 6, 2020 On 2/4/2020 at 3:24 PM, Sertica said: _westGroupsTargetQuant count (leader _x) targets [true]; This is pretty nonsensical. You either count ARRAY - simply count array or CODE count ARRAY - count array with condition The given expression is neither. The interpreter thinks it might be the former so it tells you it should be CODE Share this post Link to post Share on other sites
Harzach 2516 Posted February 6, 2020 9 minutes ago, killzone_kid said: This is pretty nonsensical. You either count ARRAY - simply count array or CODE count ARRAY - count array with condition The given expression is neither. The interpreter thinks it might be the former so it tells you it should be CODE I know I'm a hack, but I think we got that part sorted within the first few replies 🙂 Share this post Link to post Share on other sites
killzone_kid 1329 Posted February 6, 2020 1 hour ago, Harzach said: I know I'm a hack, but I think we got that part sorted within the first few replies you think this equally nonsensical expression On 2/4/2020 at 3:42 PM, Harzach said: _westGroupsTargetQuant = count (leader _x) targets [true] somehow resolves it or makes it better? Share this post Link to post Share on other sites
Harzach 2516 Posted February 6, 2020 56 minutes ago, killzone_kid said: you think this equally nonsensical expression somehow resolves it or makes it better? Welp, I'll go ahead and guess the answer is "no." Looks like we're missing a set of parentheses. _westGroupsTargetQuant = count ((leader _x) targets [true]); Variable equals number of targets known by leader of group. Here's my tested and working debug code: 0 = [] spawn { _grps = allGroups select {side _x isEqualTo west}; while {true} do { sleep 1; { _tgts = count ((leader _x) targets [true]); hint str _tgts;; } forEach _grps; }; }; Feel free to just tell me what I'm missing, I'm getting too old for the rhetorical question routine. Share this post Link to post Share on other sites
Sertica 18 Posted February 7, 2020 On 2/5/2020 at 6:16 AM, gc8 said: Edit: local execute is correct way because the script is supposed to run on client in order to work To be clear I'm talking about the debug local exec where you type the command during editor test. I'm downloading an IDE to avoid these typo errors like the missing assignment. I assumed there wouldn't be one for a game, but hooray there is! Share this post Link to post Share on other sites
gc8 974 Posted February 7, 2020 4 hours ago, Sertica said: To be clear I'm talking about the debug local exec where you type the command during editor test. I was also referring to the debug console, which you can use during mission or in editor... Share this post Link to post Share on other sites
Sertica 18 Posted February 7, 2020 3 hours ago, gc8 said: I was also referring to the debug console, which you can use during mission or in editor... I'm not sure what your point is about dedicated server. Greenfist's init.sqf uses [] spawn on the the text script. I did the same but it does not work while his does. Share this post Link to post Share on other sites
gc8 974 Posted February 8, 2020 11 hours ago, Sertica said: I'm not sure what your point is about dedicated server Just saying you need to run such script on client and never on server also when calling the info function it does not matter whether you use spawn or call Share this post Link to post Share on other sites