Home   Help Search Login Register  

Author Topic: ctrlSetText error...Solved!!  (Read 2129 times)

0 Members and 1 Guest are viewing this topic.

Offline L!nk

  • Members
  • *
ctrlSetText error...Solved!!
« 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
« Last Edit: 17 Mar 2008, 21:55:26 by L!nk »

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: ctrlSetText error
« Reply #1 on: 17 Mar 2008, 16:35:53 »
Help with what? what's the error you get and where?

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: ctrlSetText error
« Reply #2 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.
"When 900 years YOU reach, look as good you will not!"

Offline L!nk

  • Members
  • *
Re: ctrlSetText error
« Reply #3 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.

Offline L!nk

  • Members
  • *
Re: ctrlSetText error
« Reply #4 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)
« Last Edit: 17 Mar 2008, 17:15:05 by L!nk »

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: ctrlSetText error
« Reply #5 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]];

Offline L!nk

  • Members
  • *
Re: ctrlSetText error
« Reply #6 on: 17 Mar 2008, 18:17:01 »
« Last Edit: 17 Mar 2008, 18:19:54 by L!nk »

Offline L!nk

  • Members
  • *
Re: ctrlSetText error
« Reply #7 on: 17 Mar 2008, 21:54:56 »
Works 100% now
LOL, no idea why...

L!nk

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: ctrlSetText error...Solved!!
« Reply #8 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.

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: ctrlSetText error...Solved!!
« Reply #9 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..
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline L!nk

  • Members
  • *
Re: ctrlSetText error...Solved!!
« Reply #10 on: 18 Mar 2008, 19:47:24 »
NOTED!!!