Home   Help Search Login Register  

Author Topic: We all start somewhere.  (Read 463 times)

0 Members and 1 Guest are viewing this topic.

Isaioux2x

  • Guest
We all start somewhere.
« on: 11 Apr 2004, 00:49:51 »
So, i'm learning the basics of scripting. I've been playing Operation Flashpoint for months. Now, here's my problem. (Reminding you that we all start somewhere)

I just did something simple to throw my friend up into the air. When he pissed me off during a mulitplayer game.

_denlou setPos [getPos _denlou select 0, getPos _denlou select 1, 50]
then I could just do
_denlou setPos [1,1,1]

See, with the first one. I know I have to use select 0 , 1 etc. But i'm not quite sure WHY I have to use that. Could someone enlighten me?


Also, another thing

The only advantages i've been able to see between

_denlou = _this select 0
_man1 = denlou

Is that with the first I don't have to edit the script each time I want to use it, correct?

Also, I don't have to specify variables for player names at all do I?

I could just get away with denlou setPos [xxxxxxxx]
without using any of the above mentioned?

Basically I don't understand when I should use the selects  and when I shouldn't
« Last Edit: 11 Apr 2004, 01:10:36 by Isaioux2x »

Offline myke13021

  • Contributing Member
  • **
  • Myke
Re:We all start somewhere.
« Reply #1 on: 11 Apr 2004, 01:32:54 »
First of all...welcome to the Forum.

And now here some replies to your questions  ;D

the getpos command reveals 3 different values, 1 for x coordinates, 1 for y coordinates and 1 for z coordinates.

so in your example with select 0 and select 1, you'll get the coordinates of the object (denlou in your example) and with the value 50, you put it 50 meters above ground.

A setpos command with [1,1,1] would set the object on the top left corner of the map....which is ocean only i think  ;)


about the use of loval variables in a script is the following to say.
In general, for map making, it can be useful if you make more general scripts. As example, if you make a script for deleting dead bodies (lag eliminator), you make one script and get the variables with the exec command.

let me explain this a little closer.

in this script you want to delete a loon which is dead. You can define this loon in 2 ways. 1st. you could make a script for each loon or, 2nd. you make one script and replace the loon with a variable.

In the second case, the script would start with the following line:

_guy = _this select 0

as you see, _guy is a local variable..but how do we get the loon's name in there? easy, with the exec command.

usually you call scripts with command line like this

[this] exec "myscript.sqs"

the part between the brackets is the interesting part...there you can pass variables to the script...like this

[denlou] exec "myscript.sqs"

now the local variable _guy will have the value "denlou", and all the following into the script you can make happen to denlou by just using _guy...as example

_guy setpos [getpos _guy select 0, getpos _guy select 1, +50]

Well...i think you have enough now to work with.
I hope i was able to explain it in a way you understand...if not, then i guess it is more cause my bad english and not you intellect  ;D

Isaioux2x

  • Guest
Re:We all start somewhere.
« Reply #2 on: 11 Apr 2004, 02:33:06 »
Yeah, I understand most of that. As far as

[denlou] exec "whatever.sqs"

_guy = _this select 0

---

Yeah, I already know how that part works. I was just wondering if the only advantage in that was that it makes your scripts more portable.

---

Here's where I start to loose track.
This is an example from one of the many scripts i've butchered (sorry I don't remember the author, it was taken from a carbomb script here)

_AmmoType = "Shell120"
_Explosion = getPos _guy
_cx = _Explosion select 0 (Question, where is select 0 getting the info from?)
_cz = _Explosion select 1 (Question, where is select 1 getting the info from?)
_cy = _Explosion select 2 (Question, where is select 2 getting the info from?)

I think i'm slowly having a revelation as i'm typing this out :P

_cx is getting info for the X axis from _Explosion ?

I fail :P It's not enough that I can actually make it work. But I have to understand exactly why/how it works.


Edit: Elightenment.

select 0 is getting the first entry from the variable explosion which would be an X since getPos gets the XZY cords, correct?
« Last Edit: 11 Apr 2004, 02:46:04 by Isaioux2x »

Offline myke13021

  • Contributing Member
  • **
  • Myke
Re:We all start somewhere.
« Reply #3 on: 11 Apr 2004, 02:40:21 »
yep you get it.

_cx = _Explosion select 0 (getting the x axis, afaik North-South)
_cz = _Explosion select 1 (getting the y axis, East-West)
_cy = _Explosion select 2 (getting the z axis, heght above ground)

as i see the standard axis naming is a little....uhm, let's say "flipped over"  ;)

but what i'm relatively sure is:

select 0 = x axis = North-South
select 1 = y axis = East-West
select 2 = z axis = Height above ground (not sea level)

Isaioux2x

  • Guest
Re:We all start somewhere.
« Reply #4 on: 11 Apr 2004, 02:47:53 »
Hehe, thanks for all your help.

Offline myke13021

  • Contributing Member
  • **
  • Myke
Re:We all start somewhere.
« Reply #5 on: 11 Apr 2004, 02:53:54 »
np...always glad to help...don't forget to click the solved button on bottom left if your problem is solved  ;)