Home   Help Search Login Register  

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

0 Members and 1 Guest are viewing this topic.

Offline dmakatra

  • Members
  • *
  • Better known as Armsty
String, String! Lalala! E'rybody now sing it!
« on: 13 Nov 2004, 21:32:55 »
Sing it!

dmakatra went for a bit o' scripting and other marbles
He used the format command to make some variables
He made about a hundred or so
And he ran into problems, oh no!


Chorus:
String String String!
I Think I'll Faint
String String String!
I Just Wanna Die


He turned and thought "what's this thing?"
Format returns a bleeding string!
How can he turn the string so without qoutes?
Please help me and I'll show you a guy that votes


Chorus

For those with no humour: I have a string, how can I turn it "unqouted"?

:beat: *Gets Singed* :beat:
« Last Edit: 13 Nov 2004, 21:34:02 by dmakatra »

DBR_ONIX

  • Guest
Re:String, String! Lalala! E'rybody now sing it!
« Reply #1 on: 13 Nov 2004, 21:39:11 »
No. 1 : You have waay to much free time..
No 2 : Ain't there a funtion in the function list thingy that does this
No 3 : The FORMAT command?
- Ben

Offline dmakatra

  • Members
  • *
  • Better known as Armsty
Re:String, String! Lalala! E'rybody now sing it!
« Reply #2 on: 13 Nov 2004, 21:41:30 »
1) I was just so bored of all the n00bies asking so boring. Besides it was quite funny to write it as well. ;D
2) I could only find a String2Number function, and that doesn't work, as it's a variable.
3) yea, like hint format ["%1", WHAHAHAHHAHAHAHA]. You must have used it?

:beat: *Gets Shot* :beat:

DBR_ONIX

  • Guest
Re:String, String! Lalala! E'rybody now sing it!
« Reply #3 on: 13 Nov 2004, 21:44:50 »
1 : Touche..
2 : Look at the funtion.. Maybe you could change it about a bit
3 : Maybe
newshineyvarible = FOMRAT [%1,oldcrappyvariblenoonelikes]

- Ben

Offline dmakatra

  • Members
  • *
  • Better known as Armsty
Re:String, String! Lalala! E'rybody now sing it!
« Reply #4 on: 13 Nov 2004, 21:49:30 »
I'm not really good with funcies. I tried, but just turned up all error messaged.

:beat: *Gets Errored* :beat:

Offline General Barron

  • Former Staff
  • ****
  • Semper Fi!
Re:String, String! Lalala! E'rybody now sing it!
« Reply #5 on: 13 Nov 2004, 22:58:25 »
I don't get your question... normally strings aren't displayed with quotes. Only time I can think that they would be, is if you used the format command to look at an array containing strings...

For example, if I wrote:

_string = "Hello"
hint _string

A hint box would appear that says:

Hello

Without any quotes.... Perhaps some more info would be helpful.
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 Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Re:String, String! Lalala! E'rybody now sing it!
« Reply #6 on: 13 Nov 2004, 23:01:59 »
he wants to turn a string into something that is not a string
_string = "hello" vs. _string = hello

Offline dmakatra

  • Members
  • *
  • Better known as Armsty
Re:String, String! Lalala! E'rybody now sing it!
« Reply #7 on: 13 Nov 2004, 23:19:07 »
Yea, that's what I want.

:beat: *Gets Shot* :beat:

Offline General Barron

  • Former Staff
  • ****
  • Semper Fi!
Re:String, String! Lalala! E'rybody now sing it!
« Reply #8 on: 13 Nov 2004, 23:56:43 »
Okay, so let me get this straight... you want to turn a string into a variable name?

So instead of:
_string = "hello"

You want something like:

hello = "blah"
_string = hello

Only the variable name "hello" could be something different each time the script is run?
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 #9 on: 14 Nov 2004, 00:16:36 »
Yea kinda. Look. This is how it looks in the script:

Code: [Select]
Blah, blah, blah

_GAT = format ["%1%2", _id, _i2]
? id == gua : [_GAT] exec "ATTS.sqs"

Blah, blah, blah, blah, blah

Now, this will return _GAT as, for example "ind2", but instead I want ind2.

Any help appriciated.

:beat: *Gets Shot* :beat:

Offline General Barron

  • Former Staff
  • ****
  • Semper Fi!
Re:String, String! Lalala! E'rybody now sing it!
« Reply #10 on: 14 Nov 2004, 00:27:54 »
Um... okay, that code didn't really help at all, but it looks like you want to do what I'm taking about. I assume that you want _GAT to be assigned the value that is in the variable ind2, for example?

If so, you are on the right track. But you are just making a string out of _id and _i2, and putting that into _GAT. What you need to do looks like this:

call format ["_GAT = %1%2", _id, _i2]

That will make a string that would look like (for example):

"_GAT = ind2"

Then using the "call" command, you execute that string as though it were a line of script. HOWEVER, you must first create the variable _GAT, before you assign it a value in this way! So, depending on what value is supposed to go into _GAT, your first line could be something like:

_GAT = 0
_GAT = player
_GAT = ""
  or maybe just this would work in all cases:
_GAT = null
  Then you would do the rest:

call format ["_GAT = %1%2", _id, _i2]
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 #11 on: 14 Nov 2004, 00:47:21 »
OK, I will try that tomorrow when I wake up. Untill then, you'll have to do with a toothbrush!

http://i.cnn.net/cnn/2003/TECH/ptech/01/22/toothbrush.king/top.toothbrush.cnn.jpg

Thanks! :)

:beat: *Gets Shot* :beat:

Offline dmakatra

  • Members
  • *
  • Better known as Armsty
Re:String, String! Lalala! E'rybody now sing it!
« Reply #12 on: 14 Nov 2004, 19:27:22 »
 :-\

Returns Scalar-Bool-Array-Whatever-Error. :(

_GAT = player
call format ["_GAT = %1%2", _id, _i2]

Is what I used (I tried with global variable too) . And I used this to check what it returned:

titletext [ format ["%1 - %2 - %3", _GAT, _id, _i2], "PLAIN"]

_id and _i2 worked as it should, _GAT fucked up. :-\

:beat: *Gets Shot* :beat:

Offline General Barron

  • Former Staff
  • ****
  • Semper Fi!
Re:String, String! Lalala! E'rybody now sing it!
« Reply #13 on: 15 Nov 2004, 03:02:07 »
I'm still not sure if I even know what you are trying to do.

Quote
I assume that you want _GAT to be assigned the value that is in the variable ind2, for example?

Am I correct here, or are you trying to do something else?
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 #14 on: 15 Nov 2004, 15:10:53 »
I'm not entirley sure what you mean either.

I'll explain further. I'm using the createunit command to create some n00bies. what I want are some variable names for em, which I'm gonna use. So I make some variables up, which really aren't assigned to anything untill later. So the script will be something like:

_GAT = player
call format ["_GAT = %1%2", _id, _i2]

Blah, Blah, Blag

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

:beat: *Gets Shot* :beat:

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: