Jump to content

Home

Script Error


TimBob12

Recommended Posts

Hey,

I am working on a new function which you can probably guess. but I am getting errors at the '(' on line 10 and 12 and I can't work it out. Any help would be appreciated.

 

#include "trigger"

void main()
{
   float x = 0.0;
   float y = 0.0;
   float z = 0.0;
   float orient = 0.0;

   vector test ( x,y,z );

   location test2( test, orient );
   string script = "move_guard";

   new_trigger( test2, 10, script );
}

Link to comment
Share on other sites

Seems to me that your location call is missing an Object variable.

 

From the Lexicon:

Location(object, vector, float)

Set the value of a Location data structure

location Location(
   object oArea,
   vector vPosition,
   float fOrientation
);

Parameters

oArea

An Area within the game module

vPosition

An object specifying an xyz coordinate

fOrientation

An angular value between 0.0 and 360.0

Description

A constructor is a special type of function whose purpose is to create a new instance of its type. A constructor is also where any special construction actions or initialization takes place. Its return type is a new object of the specified type, so in this case what we get back is a new object of type location.
In order to construct a new location object the script needs three things:
The area the location is referenced in (This is the Area of the Module)
A new vector containing the x, y and z coordinates of this location
A float representing the facing of the object from 0.0 to 360.0 where 0.0 = East, 90.0 = North, 180.0 = West, and 270.0 = South.


Remarks

Object creation is often one of the most expensive operations, in terms of CPU usage, that can be performed. The rule of thumb is “Create as many objects as you need, but no more”.

Version

1.62
Example

//Locate the area we are in
object oArea = GetArea(OBJECT_SELF);
//Locate where in the are we are
vector vPosition = GetPosition(OBJECT_SELF);
//Identify the direction we are facing
float fOrientation = GetFacing(OBJECT_SELF);
//Create a new location with this information
location myLocation = Location( oArea, vPosition, fOrientation);

Link to comment
Share on other sites

Hmmm, I don't think I've ever used that parameter before when calling location variables. Also why would it then also pick up the same error on the vector variable. I think I forgot to say that it is a syntax error as well.

Link to comment
Share on other sites

Yeah, I just looked at your code for awhile and it seemed to be syntax-correct, but then I haven't written much code lately.

 

Just peeking again, perhaps it is your use of the spacebar around your variables that are inside the parens. Try it without any space, like vector test(x,y,z);

 

Yeah, I know that might be grasping a little ;)

Link to comment
Share on other sites

Did you fix it now? If not I may have a solution for you (can't check it though because of the missing include file):

 

#include "trigger"

void main()
{
   float x = 0.0;
   float y = 0.0;
   float z = 0.0;
   float orient = 0.0;

   vector test( x,y,z );

   location test2 = Location(test, orient);
   string script = "move_guard";

   new_trigger(test2, 10, script);
}

 

Hope that works for you... At least for me it worked when spawning npcs.

 

Fastmaniac

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...