Home   Help Search Login Register  

Author Topic: String, String! Lalala! E'rybody now sing it!  (Read 2843 times)

0 Members and 1 Guest are viewing this topic.

Offline General Barron

  • Former Staff
  • ****
  • Semper Fi!
Re:String, String! Lalala! E'rybody now sing it!
« Reply #15 on: 15 Nov 2004, 21:09:13 »
Okay, if that is all you want to do, then I don't really get why you were asking something about strings at first....

Anyway, all you need is:

"blah" createUnit [blah-blah,blah,"GAT = this", blahblah,blah]

Notice two things here: first off, you had the assignment statement backwards (you were trying to put "_GAT" into "this", but you want to do it the other way around). Secondly, the code in the quotes ("GAT = this") is not run as part of the script; it is run in it's own little "init field" world. Since it isn't part of any script, it wouldn't make sense to use a local variable; just like it wouldn't make sense to put "_g1 = group this" in a unit's init field. So instead you need to use a global variable.

Does that answer your question?
HANDSIGNALS COMMAND SYSTEM-- A realistic squad-control modification for OFP
kexp.org-- The best radio station in the world, right here at home! Listen to John Richards!

Offline dmakatra

  • Members
  • *
  • Better known as Armsty
Re:String, String! Lalala! E'rybody now sing it!
« Reply #16 on: 15 Nov 2004, 21:19:04 »
Oi. :P ;D

Heheheheheh... :-[

The problemo is, that now the init field will look, for example, like this:

"ind2" = this

Like, ind2 in a string right?

Secondly, I need GAT again. To add in an array.

Or I can just f00k it 'cause I'm tired of this shite. I'll just make 72 condition lines instead. How does that sound? :P

:beat: *Gets Shot* :beat:

Offline Igor Drukov

  • Contributing Member
  • **
  • Conscientious Subjector
Re:String, String! Lalala! E'rybody now sing it!
« Reply #17 on: 15 Nov 2004, 21:36:48 »
I'm willing to help, just like General Barron, but I just can't figure out what it is that you exactly want ::).
It looks like an interesting question, there seems to be an answer, but somehow this is all messed up.
Could you tell us your plans ? We won't repeat them  ;D.

Offline dmakatra

  • Members
  • *
  • Better known as Armsty
Re:String, String! Lalala! E'rybody now sing it!
« Reply #18 on: 15 Nov 2004, 21:56:35 »
Im just creating a bunch o' soldiers really. I need some variables for their names, so I create them with the help o' good old format. When I've done that, I create the soldier itself using createunit, put "GAT = this" in the init field and finally I put the variable in a big array.

:beat: *Gets Shot* :beat:

Offline General Barron

  • Former Staff
  • ****
  • Semper Fi!
Re:String, String! Lalala! E'rybody now sing it!
« Reply #19 on: 15 Nov 2004, 22:21:24 »
Okay, you are still confusing me.... I think I understand you, but then you say something else, so I don't know what you are trying to do.... ??? ??? ??? I'm afraid I can't help you if I don't understand what you are trying to do.
HANDSIGNALS COMMAND SYSTEM-- A realistic squad-control modification for OFP
kexp.org-- The best radio station in the world, right here at home! Listen to John Richards!

Offline Mud_Spike

  • Contributing Member
  • **
Re:String, String! Lalala! E'rybody now sing it!
« Reply #20 on: 15 Nov 2004, 23:25:35 »
Maybe all you need is something like..
in init.sqs:
Code: [Select]
spawned = []
And then for your createUnit madness:
Code: [Select]
"soldierEB" createUnit [somePos, predefinedGrp, "spawned = spawned + [this]"]
Should work

Offline dmakatra

  • Members
  • *
  • Better known as Armsty
Re:String, String! Lalala! E'rybody now sing it!
« Reply #21 on: 16 Nov 2004, 11:41:57 »
Hmmm... That's an intresting thought... I can change the variable once in the array... but then I have to do those 72 condition checks anyway. Might as well do it before.

Unless anyone got a better idea, I'm going for the 72 condition thing. :)

:beat: *Gets Shot* :beat:

Offline KTottE

  • Former Staff
  • ****
Re:String, String! Lalala! E'rybody now sing it!
« Reply #22 on: 16 Nov 2004, 12:08:30 »
What is the end result you're trying to achieve, what kind of information do you need and why do you need it?
"Life is not a journey to the grave with the intention of arriving safely in a pretty and well preserved body, but rather to skid in broadside, thoroughly used up, totally worn out, and loudly proclaiming 'WOW What a Ride!'"

Offline dmakatra

  • Members
  • *
  • Better known as Armsty
Re:String, String! Lalala! E'rybody now sing it!
« Reply #23 on: 16 Nov 2004, 14:37:54 »
I don't know how much further I can explain it than this:

Im just creating a bunch of soldiers really. I need some variables for their names, so I create them with the help of good old format. When I've done that, I create the soldier itself using createunit, put "GAT = this" in the init field and finally I put the variable in a big array.

 :-\

:beat: *Gets Shot* :beat:

Offline General Barron

  • Former Staff
  • ****
  • Semper Fi!
Re:String, String! Lalala! E'rybody now sing it!
« Reply #24 on: 16 Nov 2004, 22:33:14 »
Quote
Im just creating a bunch of soldiers really. I need some variables for their names, so I create them with the help of good old format. When I've done that, I create the soldier itself using createunit, put "GAT = this" in the init field and finally I put the variable in a big array.
That doesn't explain WHY you are putting "GAT=this" in their init field, nor does it explain WHY you are using the format command, or WHAT you are using it for. It also doesn't really explain what you mean by this:
Quote
I'm going for the 72 condition thing.


So the only thing I can understand is that you want to create a bunch of units and put them in an array. In that case, just follow Mud_Spike's advise. If you want any more advise though, you are really going to need to give a full explaination of what you are trying to do.  :-\
HANDSIGNALS COMMAND SYSTEM-- A realistic squad-control modification for OFP
kexp.org-- The best radio station in the world, right here at home! Listen to John Richards!

Offline dmakatra

  • Members
  • *
  • Better known as Armsty
Re:String, String! Lalala! E'rybody now sing it!
« Reply #25 on: 16 Nov 2004, 22:46:35 »
Gaaah! English is hard. :P

I did the 72 cond thingy earlier today, so the problems solved really. But I'll keep it open.

OK, I'll try to explain.

I am creating some soldiers with createunit. Now, I need to have some names to these soldiers, but they are 72 of them, so I used the format command to create some names, variables. Like a different set of strings to create the final variable, in this case only two. When I created the variables with the format command, it returned a string, so I need to convert it to a non-quoted undefined variable. When I finally reached the createunit part, I put this=GAT (or GAT=this, I'm tired today :P ) in the init field to define that soldier as, for example, ind2, comming from format %1 = ind, %2 = 2. Then I add them to an array.

No need to put down any effort into it now anyway, as it's working and I don't wanna mess with that script right now because everything that can go wrong has gone wrong with that script. Even though it's not fancy code, at least it's working now. :D

:beat: *Gets Shot* :beat:

Offline General Barron

  • Former Staff
  • ****
  • Semper Fi!
Re:String, String! Lalala! E'rybody now sing it!
« Reply #26 on: 17 Nov 2004, 02:53:03 »
Okay, now I understand what you are trying to do. :) Even though you have it working, you may want to change it to this method, because if you decide to add or remove guys later, things will be much easier.

I pretty much answered your Q already, but you are so stuck on doing things your way, even though it doesn't work, that you can't see that. :P But actually now that I see what you are trying to do, the answer is even easier:

Alright, so first off, you make a string with your variable name, like you already have done. In your case, it comes from 2 variables, right? _id1 & _id2 or something like that. Now, that is just a string that is stored in a variable, NOT a variable. BUT, in the createunit command, it will execute a string as though it is a line of code! So, using the format command, we can do exactly what you want.

Basically, you want the "init" field of your unit to look like this:

"(_id1+_id2) = this"

Only, you want the value of _id1 and _id2 to be in there, because together they make your variable name. So you just need to use the format command like this:

format["%1%2 = this", _id1, _id2]

Then you just plop this into the "init" part of the createunit command like so:

Code: [Select]
"soldierEB" createUnit [somePos, predefinedGrp, format["%1%2 = this", _id1, _id2]]For example, if you had _id1 = "guy", and _id2 = "01", then this would be put in the createUnit command, where the "format" stuff is right now:

"guy01 = this"

-----------------------

Now, when you want to reference that guy again, you are going to have to kinda do the same trick. Only there is no "init string" to use. BUT there is the "CALL" command, which will execute a string as if it were a line of code. So, lets say we wanted to use "guy01" in some other script. We could get him into a local variable, just like this:

Code: [Select]
_id1 = "guy"
_id2 = "01"

_man = null
call format["_man = %1%2", _id1, _id2]

Now "_man" has "guy01" in it. Neat huh?

Anyway, I learned this trick from Dinger over at the CoC, so big thanks to him, because I never would have thought of it myself. :)
« Last Edit: 17 Nov 2004, 02:55:24 by General Barron »
HANDSIGNALS COMMAND SYSTEM-- A realistic squad-control modification for OFP
kexp.org-- The best radio station in the world, right here at home! Listen to John Richards!

Offline dmakatra

  • Members
  • *
  • Better known as Armsty
Re:String, String! Lalala! E'rybody now sing it!
« Reply #27 on: 17 Nov 2004, 15:05:20 »
Neat! ;D

Many thanks Barron, and of course Dinger. ;)
I will introduce this when I get back to bug hunting. Right now I just wanna fix the backbone of the mission and then my current method works fine, for now. :)

:beat: *Gets Shot* :beat: