Forum Jump :

Author Message


Posts: 26
Rank:


Level: Member

Country: us
Location: Dallas, Tx
Occupation:
Age: 46
In-game name:

 
#1 Posted at 2012-03-16 12:58        
     
This problem is in relation to my previous troubles, but I've narrowed it down
to this one issue, if anyone can give me some insight into this matter...

Hypothetically

If in my init.sqs file I have defined a publicvariable...

E25Flg = 5;
publicvariable "E25Flg";

E26Flg = 10;
publicvariable "E26Flg";

...then let's say I have another file called Test.sqf...

_i = 26;

//How can I use the local variable _i to create the already existing
//name E26Flg, without physically typing it in?

TempVar = Call Format["E%1Flg",_i];

//If _i=2, then I need to access E02Flg, and alter it's value as well.
//If _i=5, then I need to access E05Flg, and alter it's value too.

//...and so on, is there a way I can accomplish this without 
//specifically referring to each individual Flg?

//...to make matters worse than they are, I may need to alter the
//original values as well, such as this...

TempVar = 30;
publicvariable "TempVar";


Are there any solutions to this problem, would really help me out big time...

This post was edited by harold5187 (2012-03-17 03:47, ago)

As many of us do, I as well, come from a Flashpoint, Resistance and Arma background. I was a member of the original DSF clan for about two months, back when Hatcher was in charge, along with Deaddog, Joker, Thatcher, two german dudes, and my callsign was, and still is FullMetal.

Author Message

palyarmerc  

I live inside the editor


Posts: 753
Rank:


Level: Member

Country: uk
Location:
Occupation: *Retired from ArmA*
Age:
In-game name: Paly

 
#2 Posted at 2012-03-16 16:18        
     
_TempVar = [];
for "_i" from 0 to 26 do {
_newVar = call Format["E%1Flg",_i];
_TempVar = _TempVar + [_newVar];
};

...something like that...but I'm no scripter

....that's all folks....!

Advertisement


Author Message


Posts: 26
Rank:


Level: Member

Country: us
Location: Dallas, Tx
Occupation:
Age: 46
In-game name:

 
#3 Posted at 2012-03-16 22:59        
     
Thanks for the reply Palyarmerc, but what does your code segment do? I'm not even sure if
I'm using the Call Format command to achieve my goals? Perhaps I should be using
the getvariable, or some other command?

If you have time, can you kinda explain what your segment does, so I can get a picture
in my mind as to what it's doing, to compaire it with what I need?

Thanks again, for your reply...

As many of us do, I as well, come from a Flashpoint, Resistance and Arma background. I was a member of the original DSF clan for about two months, back when Hatcher was in charge, along with Deaddog, Joker, Thatcher, two german dudes, and my callsign was, and still is FullMetal.

Author Message

palyarmerc  

I live inside the editor


Posts: 753
Rank:


Level: Member

Country: uk
Location:
Occupation: *Retired from ArmA*
Age:
In-game name: Paly

 
#4 Posted at 2012-03-17 12:17        
     
I don't know really, but this is something I worked on this morning that might give you some more ideas..

Place some flagpoles on the map and run this script.


....that's all folks....!

Author Message


Posts: 26
Rank:


Level: Member

Country: us
Location: Dallas, Tx
Occupation:
Age: 46
In-game name:

 
#5 Posted at 2012-03-18 07:27        
     
Thankyou for the example, I studied it, it comes close, but what I really need is this...

For a better understanding of the problem, you may want to read my other post
entitled "Converting sqs to sqf, my script no longer works"

It's hard to explain... But I'll try...

I already have 20 public variables defined in my init.sqs

E01Flg = 0;
publicvariable "E01Flg";

E02Flg = 0;
publicvariable "E02Flg";

E03Flg = 0;
publicvariable "E03Flg";

Etc...

I am trying to access those variables using the same manner that you are, but I'm getting
a scalar bool error which means the value stored in _TempVar...

_i = 10;  //for example for E10Flg

_TempVar = [] call compile format ["E%1Flg",_i];

_TempVar = 1;
publicvariable _TempVar;  //...trying to assign the value 1 to E10Flg

...is not reaching the public variable E10Flg.

If I could indirectly access a public variable in such a manner
than it's uses would be astounding, if only I could unlock what
I'm doing wrong.

(1) See if you can create a public variable in an init.sqs file...
(2) Then try and access it through a counter variable
(3) Then attempt to change the original value stored in that variable.
(4) Then try to broadcast it again with publicvariable.

If you can fix that, I'll be so greatful, I'll even add you to the
top credits of the mission I am working on...

As many of us do, I as well, come from a Flashpoint, Resistance and Arma background. I was a member of the original DSF clan for about two months, back when Hatcher was in charge, along with Deaddog, Joker, Thatcher, two german dudes, and my callsign was, and still is FullMetal.

Author Message

palyarmerc  

I live inside the editor


Posts: 753
Rank:


Level: Member

Country: uk
Location:
Occupation: *Retired from ArmA*
Age:
In-game name: Paly

 
#6 Posted at 2012-03-18 10:32        
     
Well, it might pay to look at PublicVariables anyway. It's not good to send them out too much.

Anyway, as far as I can remember

_TempVar = 1;
newvalue = _tempVar;
publicvariable "newvalue";

....that's all folks....!