Script Compiler Problem

Okay, so today I was scripting this:
//::///////////////////////////////////////////////
//:: TM_DARTPLAY_UD
/*
Script to be placed in the OnUserDefined handle.
NPC will play darts. NPC MUST start with 3 darts in inventory.
Target tag must be o_dartbrd. NPC tag must be c_dartplay.
Waypoint tag must be w_dartbrd001.
*/
//::///////////////////////////////////////////////
//:: Created By: manvar07299
//:: Created On: 26/7/2021
//::///////////////////////////////////////////////
object oTarget=GetNearestObjectByTag(o_dartbrd, OBJECT_SELF, 1);
int nCalledBy=GetUserDefinedEventNumber();
int nDartsReady=GetLocalInt(OBJECT_SELF, “dartstate”);
void main()
{
//
switch (nCalledBy)
{
case 1001://Called by On Heartbeat
//
if (GetIsObjectValid(GetItemInSlot(4)) && (nDartsReady == 1))
{
//if we have the darts in the right hand slot, attack target.
ClearAllActions();
ActionAttack(oTarget, TRUE);
}
else
{
//Otherwise, there are two cases. We’ve either just run out or are in the process
//of getting the darts back. We don’t want to interrupt the cycle if we’re already working on it.
if (nDartsReady == 1)
{
SetLocalInt(OBJECT_SELF, “dartstate”, 2);
ActionMoveToObject(oTarget);
//Pickup darts animation
ActionWait(0.5);
ActionPlayAnimation(13, 1.0, 1.0);
ActionWait(0.5);
ActionPlayAnimation(13, 1.0, 1.0);
ActionWait(0.5);
ActionPlayAnimation(13, 1.0, 1.0);
//
object oDestination = GetNearestObjectByTag(w_dartbrd001);
//Move to waypoint w_drtbrd001 & grant 3 darts and repeat
ActionMoveToObject(oDestination);
CreateItemOnObject(“NW_WTHDT001”, OBJECT_SELF, 3);
ActionEquipMostDamagingRanged();
ActionDoCommand(SetLocalInt(OBJECT_SELF, “dartstate”, 1));
}
}
break;
}
}
It is an easy/ simple script BUT. object oTarget=GetNearestObjectByTag(o_dartbrd, OBJECT_SELF, 1); This line in particular is quite problematic. I can’t figure out what’s wrong. Everything seems okay but when I try to compile I get: ERROR: VARIABLE DEFINED WITHOUT TYPE. What’s wrong? I got the definition from Lexicon (I think it was Lexicon, not sure though.). Reply if you can.
-Manvar-

Change this:

object oTarget=GetNearestObjectByTag(o_dartbrd, OBJECT_SELF, 1);

…to this:

object oTarget=GetNearestObjectByTag("o_dartbrd", OBJECT_SELF, 1);

And change this:

object oDestination = GetNearestObjectByTag(w_dartbrd001);

…to this:

object oDestination = GetNearestObjectByTag("w_dartbrd001");
2 Likes

@travus I honestly don’t know how I didn’t notice this before. Also one more question, how did you make this

look like nw script. I am pretty new to this forum thing.
-Manvar-

This explains how to format stuff here:

A Short Tour of These Forums - #9 by Tarot_Redhand

3 Likes

@manvar07299

there are several ways, i think this is best

```nwscript

// code here

```
3 Likes