Aller au contenu

Photo

Need help with this script


  • Veuillez vous connecter pour répondre
5 réponses à ce sujet

#1
archer4217

archer4217
  • Members
  • 105 messages
Hi all,

I wrote this script with LilacSoul's generator, but when I save it, it says "Error: Variable Defined without type".

It's a trigger that's supposed to spawn a pick (not a placeable but an item to be picked up) at a waypoint called PickQuest. Any help is much appreciated. :) Thank you.

//Put this script OnEnter
void main()
{

object oPC = GetEnteringObject();

if (!GetIsPC(oPC)) return;

int DoOnce = GetLocalInt(oPC, GetTag(OBJECT_SELF));

if (DoOnce==TRUE) return;

SetLocalInt(oPC, GetTag(OBJECT_SELF), TRUE);

if (GetLocalInt(oPC, "Pick Quest")== 1)
   {
   oTarget = GetObjectByTag("PickQuest");

   CreateItemOnObject("pick", oTarget);

   }
}

#2
ffbj

ffbj
  • Members
  • 593 messages
oTarget is not defined. Should be:
object oTarget = GetObjectByTag("PickQuest");
Also I think it should be GetLocation (oTarget)
and then CreateItemAtLocation since a waypoint is not an object that an item can be created on, only as a location I think

#3
ffbj

ffbj
  • Members
  • 593 messages
Something like:

//Put this script OnEnter
void main()
{

object oPC = GetEnteringObject();
object oTarget = GetObjectByTag("PickQuest");
location lLocation = GetLocation(oTarget);
if (!GetIsPC(oPC)) return;

int DoOnce = GetLocalInt(oPC, GetTag(OBJECT_SELF));

if (DoOnce==TRUE) return;

SetLocalInt(oPC, GetTag(OBJECT_SELF), TRUE);

if (GetLocalInt(oPC, "Pick Quest")== 1)
   {

   CreateObject( OBJECT_TYPE_ITEM,"pick", lLocation);

   }
}

#4
archer4217

archer4217
  • Members
  • 105 messages
Thank you so much, sweetie. *hugs*

#5
ffbj

ffbj
  • Members
  • 593 messages
ffbj likes hugs, even ephemeral online ones. Hope it works.
I suppose the local is checking if the item tag is already set on the PC, then the script will return, since though the local is not set to TRUE the local being set makes the answer TRUE. I don't usually do it that way but it should work.

Modifié par ffbj, 03 septembre 2011 - 11:41 .


#6
ffbj

ffbj
  • Members
  • 593 messages
Ok it should actually be:


//Put this script OnEnter
void main()
{

object oPC = GetEnteringObject();
object oTarget = GetObjectByTag("PickQuest");
location lLocation = GetLocation(oTarget);
if (!GetIsPC(oPC)) return;

int DoOnce = GetLocalInt(oPC, GetTag(oTarget));

if (DoOnce==TRUE) return;

SetLocalInt(oPC, GetTag(oTarget), TRUE);

if (GetLocalInt(oPC, "PickQuest")== TRUE)
   {

   CreateObject( OBJECT_TYPE_ITEM,"pick", lLocation);

   }
}
The reason for this is that OBJECT_SELF as originally written refers to the trigger and we actually want to refer to the waypoint which is tagged PickQuest.  Should be good to go now.
By the way I usually stick to True or False if it's just a yes or no answer, while it is not wrong to use 1 it is sometimes confusing, though 1 is the same as saying True, it is, I think better to keep things as clear and as simple as possible.
Also to be as clear a possible you should  not say a waypoint called PickQuest.  You should use name, or tag, or resref when referring to items, creatures, etc... as they can all be different.  So a waypoint with the tag PickQuest. 

Modifié par ffbj, 04 septembre 2011 - 12:06 .