OFPEC Forum

Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: L!nk on 17 Mar 2008, 16:31:16

Title: ctrlSetText error...Solved!!
Post by: L!nk on 17 Mar 2008, 16:31:16
Ok, this puzzles me alot.
All I want to do is make a RscText update after I subracted it from something.

Here is my "description.ext"
Code: [Select]
class Txt_Money : RscText
{
idc = 212;
text = "Money: $%1";
x = 0.35; y = 0.21; w = 0.3; h = 0.03;
};
Here is my "dialogBuy.sqf"
Code: [Select]
_dialog = createDialog "MHQBuild_Dialog";
money = 2000;
ctrlSetText [212,format ["%1",money]];
Here is my "buttonBuy.sqf"
Code: [Select]
price = 50;
money = money - price;
This is the order it runs:
"dialogBuy.sqf"
"buttonBuy.sqf"
"dialogBuy.sqf"

Seems like a game bug or something, though Cleanrock fixed this is his updating of dialogs in his missions. I looked at it but can't find his technique.

PLEASE HELP,
L!nk
Title: Re: ctrlSetText error
Post by: Mandoble on 17 Mar 2008, 16:35:53
Help with what? what's the error you get and where?
Title: Re: ctrlSetText error
Post by: Wolfrug on 17 Mar 2008, 16:39:44
Well umm. First of all, the RscText will only display the number (which will always be 2000), not the "Money : $" part. You need to put that into the equation as well for the whole deal : à la

Code: [Select]
ctrlSetText [212,"Money: $ " + (format ["%1",money])];
And secondly, the reason it will always display as 2000 lies in the fact that in "dialogbuy.sqs" you define money = 2000. It doesn't matter that you subtract anything from it, since in the next iteration of "dialogbuy.sqs" (which just updates the rsctext) you define money = 2000 again. :)

I suggest defining money in the init.sqf or similar initialization script to avoid this kind of weirdness. :)

Wolfrug out.
Title: Re: ctrlSetText error
Post by: L!nk on 17 Mar 2008, 16:51:21
Sry, when the dialog is created for the second time, this text did not change. Its still the same (2000).

The "money = 2000;" is set beforehand. Sorry!

I know it wont display "Money: $2000", but thats not my problem. It is supose to update and it doesn't.
Title: Re: ctrlSetText error
Post by: L!nk on 17 Mar 2008, 17:12:29
OK, here is my original code copied directly from my mission:

DialogBuild.sqf:
Code: [Select]
//------------------------------------------------------------
//Link_CTI
//------------------------------------------------------------
_dialog = createDialog "MHQBuild_Dialog";

ctrlSetText [212,format [ctrlText 212,(call compile format["ArrMone_Si%1_%2", LinkCTI_PlayerSide,LinkCTI_PlayerGroup])]]; // This text WON'T UPDATE after it is subracted in "ButtonBuild.sqf"
ButtonBuild.sqf:
Code: [Select]
//------------------------------------------------------------
//Link_CTI
//------------------------------------------------------------

_selected = _this select 0; // when a list entry is double clicked, this is the clicked entry index.

_price = (((call compile format["ArrType_Si%1_Buil", LinkCTI_PlayerSide]) select _selected) select 5);
_money = (call compile format["ArrMone_Si%1_%2", LinkCTI_PlayerSide,LinkCTI_PlayerGroup]);

if (_money >= _price) then
{
// update array
if (LinkCTI_PlayerSide == 0) then {ArrMone_Si0 set [LinkCTI_PlayerGroup,(_money - _price)]};
if (LinkCTI_PlayerSide == 1) then {ArrMone_Si1 set [LinkCTI_PlayerGroup,(_money - _price)]};
LinkCTI_ArrMone = [ArrMone_Si0,ArrMone_Si1];
closeDialog 0;
};
// Everything works is this file. The array entry is updated and subracted and everything!

In the situation of my testing:
LinkCTI_PlayerSide = 1;
LinkCTI_PlayerGroup = 1;

LinkCTI_ArrMone is a array with the amount of money for the group.
LinkCTI_ArrType is a array that only has to do with my buildings (cost of building)
Title: Re: ctrlSetText error
Post by: Mandoble on 17 Mar 2008, 17:16:07
Try this:
Code: [Select]
_dialog = createDialog "MHQBuild_Dialog";
Sleep 0.5;
money = 2000;
ctrlSetText [212,format ["%1",money]];
Title: Re: ctrlSetText error
Post by: L!nk on 17 Mar 2008, 18:17:01
Already tried sleep.

Maybe this??
http://www.ofpec.com/forum/index.php?topic=30863.msg211751#msg211751
Title: Re: ctrlSetText error
Post by: L!nk on 17 Mar 2008, 21:54:56
Works 100% now
LOL, no idea why...

L!nk
Title: Re: ctrlSetText error...Solved!!
Post by: Mandoble on 17 Mar 2008, 21:59:38
Just consider each time you modify description.ext file, you need to reload the mission again in the editor to make the changes effective. Might be that was all the problem.
Title: Re: ctrlSetText error...Solved!!
Post by: h- on 18 Mar 2008, 03:54:25
L!nk, no consecutive posting please.
If you have something to add after a short period of time modify your post instead of replying to yourself..
Title: Re: ctrlSetText error...Solved!!
Post by: L!nk on 18 Mar 2008, 19:47:24
NOTED!!!