Home   Help Search Login Register  

Author Topic: Selecting Unit Problem?  (Read 1307 times)

0 Members and 1 Guest are viewing this topic.

SilentHunter_764

  • Guest
Selecting Unit Problem?
« on: 05 Dec 2005, 09:26:58 »
Hello all,

Firstly i appoligse if this is in the wrong thread. I havent been on OFPEC in a while, so.. ;D
I've been working on a script lately:

Code: [Select]
_unit = _this select 0

#loop
_unit addaction ["Engage at will!","engage.sqs"]
_unit addaction ["Forward!","forward.sqs"]
_unit addaction ["Halt!","halt.sqs"]

goto "loop"

Now, the problem lys within the unit selection. Ive made the corresponding scripts for this script (Engage.sqs etc) like this:

Code: [Select]
_unit = _this select 0

_unit switchmove "CommandEngageAtWill"
~1
_Unit GroupChat "Engage at will"

exit

However when i get in, i get the error: _unit = _this select 0 | type array expected object | or something like that.

Can anyone help me?

Cheers,
Kannon ;D
« Last Edit: 05 Dec 2005, 09:31:54 by LooseKannon »

LoTekK

  • Guest
Re:Selecting Unit Problem?
« Reply #1 on: 05 Dec 2005, 09:48:27 »
I don't quite get the first script snippet. Why are you sticking the addactions in an endless loop? Within about 2 seconds you'll likely have about a million of each action added to the action list.

As for the rest of it, it works without a hitch.

Or rather, I don't get any error messages. You might want to look into the switchmoves, though, since there'll be no tweening between the unit's current stance/animation and the hand signal animation. Also, as it currently stands, the unit will get stuck in the handsignal animation, unable to move.
« Last Edit: 05 Dec 2005, 09:50:16 by LoTekK »

Offline Trapper

  • Honoured Contributor
  • ***
  • I'm a llama!
Re:Selecting Unit Problem?
« Reply #2 on: 05 Dec 2005, 14:23:12 »
The errormessage will be caused by the script call.

Correct are:

soldier1 exec "script.sqs"
Code: [Select]
_unit = _this
[soldier1] exec "script.sqs"
Code: [Select]
_unit = _this select 0

Offline Baddo

  • Former Staff
  • ****
  • Reservist Jaeger
Re:Selecting Unit Problem?
« Reply #3 on: 05 Dec 2005, 18:06:39 »
The errormessage will be caused by the script call.

Correct are:

soldier1 exec "script.sqs"
Code: [Select]
_unit = _this

Use this form if you only have one argument to pass, which looks like the case here. Don't make an array out of one argument. Even better would be to just use _this in your script instead of _unit, because creating another variable in addition to _this is unnecessary. This of course changes when you have multiple arguments.
« Last Edit: 05 Dec 2005, 18:10:17 by Baddo »

SilentHunter_764

  • Guest
Re:Selecting Unit Problem?
« Reply #4 on: 06 Dec 2005, 04:36:05 »
Cheers for the help, gents.

Looks like ive solved the problem, but now ive got the problem of the actions on the menu. I dont want to have half a million actions, so am i going to need to put

Code: [Select]
_unit addaction <whatever action was just used> on the end of each script? So, after youve chosen an action it will pop back up?

Thanks in advance,
Kannon

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Re:Selecting Unit Problem?
« Reply #5 on: 06 Dec 2005, 22:17:33 »
no, just give them the action once, at the beginning
as long as you don't remove the action, it will stay there forever, and is reuseable

Offline Sui

  • Former Staff
  • ****
    • OFPEC
Re:Selecting Unit Problem?
« Reply #6 on: 07 Dec 2005, 01:31:39 »
You can also name the action, thereby making it removeable via script.

eg.
Quote
action1 = _unit addaction ["Engage at will!","engage.sqs"]

...

_unit removeacton action1

But as Triggerhappy pointed out, the action will only be removed if you physically remove it via removeaction. The player clicking on it won't remove it.

SilentHunter_764

  • Guest
Re:Selecting Unit Problem?
« Reply #7 on: 07 Dec 2005, 04:08:36 »
Yep, Ive got it down-pat now.

The scripts now read:

Code: [Select]
_unit = _this select 0

_unit switchmove "fxangel"
~2
exit

etc.

Ive also got the animation for returning to regular stance;

Code: [Select]
_unit = _this select 0

_unit switchmove " "

But now ive got the problem that when you return to the standard animation - your stuck (cant move).

Thankyou SO MUCH for the help so far!

Cheers,
Kannon

EDIT: Ah, yes. I tested not having the addaction after the script and it does remain on the menu. Cheers Triggerhappy.
« Last Edit: 07 Dec 2005, 04:09:29 by LooseKannon »