Home   Help Search Login Register  

Author Topic: Scripted actions....  (Read 5954 times)

0 Members and 1 Guest are viewing this topic.

KyleSarnik

  • Guest
Re:Scripted actions....
« Reply #60 on: 11 Oct 2003, 23:22:09 »
Come on guys, im close to figuring this out, just give me a little more help... Thats all I ask for now....

Offline Chris Death

  • Former Staff
  • ****
  • Finally Death's gonna get ya
    • OFPEC
Re:Scripted actions....
« Reply #61 on: 12 Oct 2003, 10:34:42 »
Kyle, i'm sorry to say that, but i feel that i can't help you,
that's the reason why i'm not answering anymore.

I mean i have given you an explanation how to use arrays
and sub-arrays. I can't explain you that mucho better, because
english is not my primary language.

Best you could do is: read that post where i explained the
arrays and subarrays again, and tell me what you don't
understand, maybe i can try then to tell ya more bout it.

~S~ CD
Dont argue with idiots....they will bring you down to their level and beat you there with experience.

How to use Waypoint type Scripted

KyleSarnik

  • Guest
Re:Scripted actions....
« Reply #62 on: 12 Oct 2003, 18:05:55 »
But I can't figure out how to get the array for THAT plane! YOu didn't explain that part! Give me an example or something, than I could figure it out... plz just don't give up. on me...!

Offline Chris Death

  • Former Staff
  • ****
  • Finally Death's gonna get ya
    • OFPEC
Re:Scripted actions....
« Reply #63 on: 12 Oct 2003, 19:14:51 »
OK - first a little summary:

array1 = [planetype,seattype,canopytype]

This array contains 3 elements:

type of the plane (we need this only to compare it to the
plane, we get passed by the action) - a10

type of the seat (for that plane) - a10seat
type of canopy (for that plane) - a10canopy

OK, this array would only cover one plane.
What you need is something like a table (or database), where
more plane types are possible.
Therefore you need to work with subarrays.

main_array = [array1,array2,array3]

Now you have an array, which contains of 3 subarrays.

main_array looks then like:

planetype               seattype            canopytype

"a10"                      "a10seat"          "a10canopy"
"su25"                    "su25seat"         "su25canopy"
"F16"                      "F16seat"           "F16canopy"

Now if you execute the action, you need to compare the plane,
from where the action has been called (_this select 0)
against the first parameter of the subarrays from main_array.
Once you find the right plane, you can use this subarray to
get the seat and canopytypes.

To get the plane you can use (as already mentioned):

_plane = _this select 0

Now you need the type of the plane:

_planet = typeOf(_plane)

Now comes the "if" stuff.

{If (_planet == _x select 0) Then {_seatt = _x select 1; _canopyt = _x select 2}} ForEach my_array

This command does now compare _planet to each subarrays
first element, and if it does match, _seatt and _canopyt will be
assigned to the seattype and canopytype of the same subarray,
where the plane does match.

[_plane,_seatt,_canopyt] exec "ejection.sqs"

This line will then execute ejection.sqs and pass an array of
3 parameters to the script.

OK, let's have a look how it will work in real:

you fly in an a10
you press the custom action: eject-plane

_plane = _this select 0
;_plane will be the plane which owns the action

_planet = typeOf(_plane)

;will be a10

{If (_planet == _x select 0) Then {_seatt = _x select 1; _canopyt = _x select 2}} ForEach main_array

_x represents each subarray from main_array
_x select 0 represents each first element of each subarray
inside main_array => the plane type

Now _planet (in this case: a10) does match with one of the
first elements of the subarrays: a10 - su25 - F16 - doesn't it?
OK it matches with: a10
This means _seatt = "a10seat" and _canopyt = "a10canopyt"

Then the script says:

[_plane,_seatt,_canopyt] exec "ejection.sqs"

or:

[the plane,"a10seat","a10canopy"] exec "ejection.sqs"

:note - for the exec array i did not use _planet, as it's only
the type of the plane, but i used _plane, as it's the reference
to the plane itself.

hope the fire gets burning now

~S~ CD
Dont argue with idiots....they will bring you down to their level and beat you there with experience.

How to use Waypoint type Scripted

KyleSarnik

  • Guest
Re:Scripted actions....
« Reply #64 on: 12 Oct 2003, 20:31:04 »
Ah... yes I understand that part now, but now I don't understand defining subarrays... Can you have more than 3? Well I guess yoy could, so what could I put the main_array = [ks_parray1,ks_parray2,ks_parray3,...] (and so on up to say like 12) in the ejectactive script... Yes that should work, then to make a new costum array you could put: ks_parray4 = [planet,seatt,canopyt] right? But what would planet be... The planes classname?? Yes this seems very good I'll go work on it... But I need to know about planet... So you could make a costum array... Also when you use the typeof command, will I need to use a different array for the A10 and A10 LGB?? Oh and thanks alot...

KyleSarnik

  • Guest
Re:Scripted actions....
« Reply #65 on: 12 Oct 2003, 20:59:53 »
Grr this is the 3rd time I tried to post this...!

Ok the problem is that the guy is ejected but there is no seat, no canopy, and no parachute... So I figured its the seatt and canopyt (they names were probably wrong and they didn't get createvehicled). What did I do wrong?

ejectactive.sqs (only the top part w/ all the arrays)
Code: [Select]
_obj = _this select 0

ks_parray1 = ["a10","RAD_Ejectionseat","RAD_Ejectionseat"]
ks_parray2 = ["su25","RAD_Ejectionseat","RAD_Ejectionseat"]
ks_pmain_array = [ks_parray1,ks_parray2,ks_parray3,ks_parray4,ks_parray5,ks_parray6]
*I'm using RAD_Ejectionseat because I dont have the addons yet... (*goes and yells at addon maker*)

ejectarrays.sqs (the script called by the addaction)
Code: [Select]
_obj = _this select 0

_objt = typeof(_obj)

{If (_objt == _x select 0) Then {_seatt = _x select 1; _canopyt = _x select 2}} ForEach ks_pmain_array

[_obj,_seatt,_canopyt] exec "ejection.sqs"

So what's wrong?? If I can find what's wrong I might be able to fix it... so thanks for the help so far and thanks alot Chris Death...

Offline Chris Death

  • Former Staff
  • ****
  • Finally Death's gonna get ya
    • OFPEC
Re:Scripted actions....
« Reply #66 on: 12 Oct 2003, 21:03:04 »
Quote
But I need to know about planet

Quote
_plane = _this select 0

Now you need the type of the plane:

_planet = typeOf(_plane)

_planet is what typeOf(_plane) returns

This means: "A10"

-

Quote
will I need to use a different array for the A10 and A10 LGB

I'm not sure, if the a10_lgb returns a different classname
than the no_lgb one, but you should be able to find that out.

-

Quote
Can you have more than 3?

you can off course have as many subarrays as you want here.

-

Also i would recommend that you have one standard/default
subarray, which you can use when the type of the plane
doesn't exist in your array (think about new planes, updates
on classnames, etc.)

-

Quote
then to make a new costum array you could put: ks_parray4 = [planet,seatt,canopyt] right

I still think that you will need _plane - the object,
and not _planet - the type of the object, for your ejection.

:edit - just saw your last reply - soz i'm short on time
right now - will have a look and reply later, 2 or 3 hours,
depends on how long it takes me to hypnotize me mrs
(maybe with a good movie and a footy massage  ;D)

~S~ CD
« Last Edit: 12 Oct 2003, 21:06:17 by Chris Death »
Dont argue with idiots....they will bring you down to their level and beat you there with experience.

How to use Waypoint type Scripted

KyleSarnik

  • Guest
Re:Scripted actions....
« Reply #67 on: 14 Oct 2003, 22:47:57 »
more like 2-3 days...  ::) still waiting...

Offline Chris Death

  • Former Staff
  • ****
  • Finally Death's gonna get ya
    • OFPEC
Re:Scripted actions....
« Reply #68 on: 14 Oct 2003, 23:00:30 »
Quote
more like 2-3 days...   still waiting...

 :o huh - just awaken - seems she hypnotized me then  :-[

 ;D

Well, i couldn't find any mistake yet, maybe it's the createvehicle, what's goin wrong.

Try debugging each step of your scripts.

Use: hint format or sidechat format to let you display
your variables, etc to see if all's fine on them.

~S~ CD
Dont argue with idiots....they will bring you down to their level and beat you there with experience.

How to use Waypoint type Scripted

BadAssSuntchezz

  • Guest
Re:Scripted actions....
« Reply #69 on: 04 Jan 2004, 15:26:54 »
That's a real prob that cracked me, too.

standard version goes like this:
actionID = player addAction ["player Action","script.sqs"]

What i tried was to take different parenthesis or brackets like:
actionID = player addAction "playerAction",{variable1,variable2} exec "script.sqs"]

Unfortunatly it didn't work though! To get around this i had to type tons of code and quite a dozen of scripts instead of one simple one.

« Last Edit: 04 Jan 2004, 15:28:42 by BadAssSuntchezz »