OFPEC Forum
Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started 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"
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"
_dialog = createDialog "MHQBuild_Dialog";
money = 2000;
ctrlSetText [212,format ["%1",money]];
Here is my "buttonBuy.sqf"
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
-
Help with what? what's the error you get and where?
-
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
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.
-
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.
-
OK, here is my original code copied directly from my mission:
DialogBuild.sqf:
//------------------------------------------------------------
//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:
//------------------------------------------------------------
//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)
-
Try this:
_dialog = createDialog "MHQBuild_Dialog";
Sleep 0.5;
money = 2000;
ctrlSetText [212,format ["%1",money]];
-
Already tried sleep.
Maybe this??
http://www.ofpec.com/forum/index.php?topic=30863.msg211751#msg211751
-
Works 100% now
LOL, no idea why...
L!nk
-
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.
-
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..
-
NOTED!!!