Home   Help Search Login Register  

Author Topic: SetPos problem...  (Read 835 times)

0 Members and 1 Guest are viewing this topic.

Offline Kurayami

  • Members
  • *
SetPos problem...
« on: 16 Dec 2002, 07:33:46 »
I decided to get back into messing around with OFP scripting again after about a year off today, so I've been fooling around and making useless scripts in an attempt to get back up to speed. I'm having a problem that's stumping me, though...

Here's the script:

Code: [Select]
_Ammo = _this select 0
_Target = _this select 1

_oldX = GetPos _Ammo select 0
_oldY = GetPos _Ammo select 1
_oldZ = GetPOs _Ammo select 2

#Update

_newX = GetPos _Target select 0
_newY = GetPos _Target select 1
_newZ = GetPos _Target select 2

_Ammo SetPos [_newX,_newY,newZ]
_Ammo SetDammage 1
~0.01
_Ammo SetPos [_oldX,_oldY,_oldZ]
_Ammo SetDammage 0
~1
goto "Update"

It's basically an ultra-simple barage script that I'm going to incorporate with several more... but it doesn't work.

_Ammo SetPos [_newX,_newY,newZ] returns "type any, expected number."

I don't see why it doesn't work. I checked up on a few other similar scripts and I don't see anything out of order. Any insight would be appriciated.

Oh, and on a side note...
Is there any way to add multiple magazines in an array? I've always had to add each mag individually and that's kind of a pain.

Thanks.

Offline toadlife

  • OFPEC Old Skool
  • Former Staff
  • ****
  • Official OFP Editing Center Toad
    • toadlife.net
Re:SetPos problem...
« Reply #1 on: 16 Dec 2002, 10:16:45 »
Nothing looks wrong...

What is "_ammo"?

and

What is "_target"?
"Whenever you want information on the 'net, don't ask a question; just post a wrong answer." -- Cancer Omega.

Bremmer

  • Guest
Re:SetPos problem...
« Reply #2 on: 16 Dec 2002, 11:02:29 »
Actually something does look wrong, but its just a typo - nothing to worry about:

newZ should be _newZ

Cheers  :)

Offline Kurayami

  • Members
  • *
Re:SetPos problem...
« Reply #3 on: 16 Dec 2002, 16:26:11 »
Nothing looks wrong...

What is "_ammo"?

and

What is "_target"?
Well, for this little experiment _ammo is an M2(East) and _target is a soldier in a house.


Actually something does look wrong, but its just a typo - nothing to worry about:

newZ should be _newZ

Cheers  :)

Oh. Duh. I guess that's why it's bad to script after midnight. I went through the script about 10 times before posting and never noticed that.

It works now. Thanks.


What about my second question? To clarify it more, I mean is there a way to do something similar to "x AddMagazineCargo ["M16", 5]" with a single AddMagazine command as opposed to having to do it five times? It'd be helpful because I have several old scripts that are very messy because of a million AddMagazine lines.

Offline toadlife

  • OFPEC Old Skool
  • Former Staff
  • ****
  • Official OFP Editing Center Toad
    • toadlife.net
Re:SetPos problem...
« Reply #4 on: 16 Dec 2002, 20:22:01 »
What about my second question? To clarify it more, I mean is there a way to do something similar to "x AddMagazineCargo ["M16", 5]" with a single AddMagazine command as opposed to having to do it five times? It'd be helpful because I have several old scripts that are very messy because of a million AddMagazine lines.

If you have resistance you can use the while > do function to accomplish this...

_c = 0
while "_c < 5" do {soldier addmagazine {m16};_c = _c + 1}

This would give em 5 16 mags.

If you only have 1.46, then you could do it this way...

_c = 0
#add
soldier addmagazine "m16";_c = _c + 1
?_c < 5:goto "add"
« Last Edit: 16 Dec 2002, 21:56:43 by toadlife »
"Whenever you want information on the 'net, don't ask a question; just post a wrong answer." -- Cancer Omega.

Offline Kurayami

  • Members
  • *
Re:SetPos problem...
« Reply #5 on: 16 Dec 2002, 21:59:42 »
Heh. I rigged up something like the second one earlier this morning. It was considerably messier and defeated the purpose of not just doing the same line several times  ;D

I wasn't aware of "while." I do have Resistance, but I haven't really followed any scripting stuff since before 1.46. I'm gonna give that a shot. Thanks.

Offline toadlife

  • OFPEC Old Skool
  • Former Staff
  • ****
  • Official OFP Editing Center Toad
    • toadlife.net
Re:SetPos problem...
« Reply #6 on: 16 Dec 2002, 23:04:36 »
The "while > do" and "if >then >else" functions were added in the 1.85 patch, so make sure you get the latest patch for resistance.

BTW, I think those examples above will give the soldier 6 mags not 5 :P

Oh yeah...and welcome back to the world of OFP scripting! The new functions make alot of things easier. :)
"Whenever you want information on the 'net, don't ask a question; just post a wrong answer." -- Cancer Omega.