Author Topic: Need help with this script  (Read 431 times)

Legacy_archer4217

  • Full Member
  • ***
  • Posts: 206
  • Karma: +0/-0
Need help with this script
« on: September 03, 2011, 11:34:03 pm »


               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. '<img'> 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);

   }
}
               
               

               
            

Legacy_ffbj

  • Hero Member
  • *****
  • Posts: 1097
  • Karma: +0/-0
Need help with this script
« Reply #1 on: September 04, 2011, 12:00:00 am »


               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
               
               

               
            

Legacy_ffbj

  • Hero Member
  • *****
  • Posts: 1097
  • Karma: +0/-0
Need help with this script
« Reply #2 on: September 04, 2011, 12:06:17 am »


               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);

   }
}
               
               

               
            

Legacy_archer4217

  • Full Member
  • ***
  • Posts: 206
  • Karma: +0/-0
Need help with this script
« Reply #3 on: September 04, 2011, 12:25:04 am »


               Thank you so much, sweetie. *hugs*
               
               

               
            

Legacy_ffbj

  • Hero Member
  • *****
  • Posts: 1097
  • Karma: +0/-0
Need help with this script
« Reply #4 on: September 04, 2011, 12:38:21 am »


               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 .
                     
                  


            

Legacy_ffbj

  • Hero Member
  • *****
  • Posts: 1097
  • Karma: +0/-0
Need help with this script
« Reply #5 on: September 04, 2011, 12:59:02 am »


               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 .