OFPEC Forum

Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: Linker Split on 15 Jan 2008, 23:25:04

Title: CtrlSetText problems
Post by: Linker Split on 15 Jan 2008, 23:25:04
I've started to make our BHD MOD control dialog, but I have not a problem, but a stop:
I need to change the text for every buttons in my dialog (circa 12) every time the dialog itself is called and checks for units under my command.
I'll try to explain it:
If you have 4 soldiers under your command, when I call the dialog, 4 of the 12 buttons should change their text into my units' names.
That can be done via command ctrlSetText, and the sintax for it is:
Code: [Select]
ctrlSetText [idc,"text"]
To make it easy and quickly, I did the following:
Since every buttons in my dialog have an IDC that starts from 10 and ends with 19, I used this method to call every button and change their text:

Code: [Select]
_player = _this select 0
_grp = group _player
_count = count (units _grp)
_n = 0
#START

_number = format["1%1",_n]
ctrlSetText [(_number),"Soldier 1"]

? (_n >= _count) : exit

_n = (_n+1)

In this way, I don't have to create all the labels according with the number of soldiers under my command, but i simply put a variable _n that SHOULD be passed to the ctrlSetText command as a number (via format command)

i say SHOULD, cause it doesn't happen!

Why?? :weeping:
As you can see, _number is a real number:
Code: [Select]
_number = format["1%1",_n]doesn't ctrlSetText use also variables that represent numbers as IDC?

can someone help me???
pls....

Linker Split
Title: Re: CtrlSetText problems
Post by: Mandoble on 15 Jan 2008, 23:36:50
Whatever format command returns is always an string, not a number.

parseNumber command (http://www.ofpec.com/COMREF/index.php?action=list&game=All&letter=p#671)

Code: [Select]
_number = parseNumber format["1%1",_n]
Title: Re: CtrlSetText problems
Post by: Linker Split on 16 Jan 2008, 00:04:36
thanks Mandoble, it was a so easy problem for youuuu   :D that you moved it to the this section of the forum!  :P
Title: Re: CtrlSetText problems
Post by: Linker Split on 17 Jan 2008, 00:20:12
Ok now there's a problem with the command ButtonSetAction... when i want to pass the script to execute for each soldier, I used tis method:

Code: [Select]
_count = count (units group player)
_n = parseNumber format ["%1",0]

#START

_BUTTON_ACTIVE = parseNumber format ["1%1",_n]
ButtonSetAction [(_BUTTON_ACTIVE),"[(units group player) select _n] exec format [""Scripts\info_%1.sqs"",_n]"]

? (_n >= _count) : exit
_n=_n+1

goto "START"

This doesn't seem to work, it seems to me that the buttonSetAction command doesn't accept some variables that represents some numbers...
how can I do it?

I'm using it cause I want to check how many units are in my group, then change the commands to assign to the buttons (one for each units, that's why I'm looping it with an increasing variable _n, and hide the unused ones (the ones that are not assigned to anyone)
Title: Re: CtrlSetText problems
Post by: Mandoble on 17 Jan 2008, 13:01:06
Code: [Select]
ButtonSetAction [(_BUTTON_ACTIVE),"[(units group player) select _n] exec format [""Scripts\info_%1.sqs"",_n]"]
_n is local to the scope of the script you are executing, so when you click that button, the code present there will not be able to resolve the value of any _n.

Try the following:
Code: [Select]
ButtonSetAction [(_BUTTON_ACTIVE), format["[(units group player) select %1] exec ""Scripts\info_%1.sqs""", _n]];