Home   Help Search Login Register  

Author Topic: [SOLVED]Hello and addWaypoint error  (Read 2486 times)

0 Members and 1 Guest are viewing this topic.

Offline becubed

  • Members
  • *
[SOLVED]Hello and addWaypoint error
« on: 06 Feb 2009, 03:08:08 »
Hello OFPECers,
    since I'm new here I though I'd introduce myself.
My name is Scott , I picked up ArmA about 2 months ago and it's one of the few computer games that I like.
I want to create my own missions for it but my ascension to scripting god has hit a snag on the first step!

I've searched through the forum here and can find many examples for what I am trying to do but can't seem to get them to work.
I have a feeling the answer will be embarrassingly obvious but I just can't see it.

I have two BLUFOR units on the map one is the player I'm using to spectate, the other is an AI unit called Man1.
I'm trying, via script, to create a waypoint for Man1 at a marker called Target1.

I have a script file called makemove.sqf that contains

Code: [Select]
    WPObj = group Man1 addWaypoint [Target1,0];
   
    group Man1 setCurrentWaypoint WPObj;
    WPObj setWayPointType "MOVE";
    WPObj setWayPointSpeed "FULL";
   
In the init field for Man1 I have

   
Code: [Select]
call {execVM "makemove.sqf"}   
When I preview the mission in the editor I get the error
Code: [Select]
    WPObj = group Man1 |#|addWaypoint [Target1,0];
   
    Error 0 Elements provided, 3 expected

I've tried as many things as I could think of, passing Man1 and Target1 in as parameters etc. but no luck.
What am I doing wrong?
Thanks
Scott
« Last Edit: 07 Feb 2009, 13:11:30 by becubed »

Offline hoz

  • OFPEC Site
  • Administrator
  • *****
Re: Hello and addWaypoint error
« Reply #1 on: 06 Feb 2009, 03:28:31 »
The syntax is

Code: [Select]
_wayP = groupname addWaypoint [fred, 10]

Your code should look like this..

In the unit init field add  MygroupName = group this

Code: [Select]
WPObj = MygroupName addWaypoint [Target1,0];
Xbox Rocks

Offline becubed

  • Members
  • *
Re: Hello and addWaypoint error
« Reply #2 on: 06 Feb 2009, 05:03:00 »
Hoz,
   thanks for the quick reply, unfortunately that was one of the ways that I tried and I get the same error. 0 elements provided 3 expected.
I'll rebuild the mission tonight and test it again just to make sure.

Scott

Offline hoz

  • OFPEC Site
  • Administrator
  • *****
Re: Hello and addWaypoint error
« Reply #3 on: 06 Feb 2009, 05:10:51 »
I just checked a script where I'm using this..

Code: [Select]
grpw1 addWaypoint [getmarkerpos "dest", 2];

Where you are specifying Target1 is this a named object or a trigger or gl?
« Last Edit: 06 Feb 2009, 05:57:07 by hoz »
Xbox Rocks

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re: Hello and addWaypoint error
« Reply #4 on: 06 Feb 2009, 06:21:52 »
You can use a named object as the first array element instead of a position.

The position of the named object is taken i imagine.

Name your group, it must have at least one waypoint before the one to be added.
Then using a radio trigger pop this in to the On activation field:

dud = grpname addwaypoint [fred, 10]

Place a lone soldier somewhere nearby and call him fred.
The waypoint will be within 10 meters of fred.


Planck
I know a little about a lot, and a lot about a little.

Offline becubed

  • Members
  • *
Re: Hello and addWaypoint error
« Reply #5 on: 06 Feb 2009, 07:17:33 »
Success, thank you all very much! :D
The issue was that Target1 was a marker, once I changed it to
Code: [Select]
WPObj = group Man1 addWaypoint [getMarkerPos "Target1",0];it worked without a problem.
I had previously tried this but didn't have quotes around the marker name. I then read that an object could be used instead and it's position would be used as default, so I got rid of the getMarkerPos. Obviously markers aren't objects.

Coming to ArmA scripting and game communities as a complete noob is it OK if I attach clarifications in the comments section of the OFPEC Command Reference? The entry there is concise, but the subtle gotcha's of any programming language can frustrate beginners and "Idiot's Guide" examples always help a lot.

Scott

Offline Worldeater

  • Former Staff
  • ****
  • Suum cuique
Re: Hello and addWaypoint error
« Reply #6 on: 06 Feb 2009, 20:05:48 »
Quote
Obviously markers aren't objects.

Right. See createMarker, it returns a string.

Note: The article for createMarker in the BIKI contains a bad example at the bottom. The variable used there is named _markerobj which is misleading. It's does not contain an object reference but a string!
« Last Edit: 07 Feb 2009, 05:03:43 by Worldeater »
try { return true; } finally { return false; }