Bioware Archive

Bioware Archive V2 => Builders - Scripting => Topic started by: Legacy_archer4217 on September 03, 2011, 11:34:03 pm

Title: Need help with this script
Post by: Legacy_archer4217 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. :) 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);

   }
}
               
               

               
            
Title: Need help with this script
Post by: Legacy_ffbj 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
               
               

               
            
Title: Need help with this script
Post by: Legacy_ffbj 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);

   }
}
               
               

               
            
Title: Need help with this script
Post by: Legacy_archer4217 on September 04, 2011, 12:25:04 am


               Thank you so much, sweetie. *hugs*
               
               

               
            
Title: Need help with this script
Post by: Legacy_ffbj 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 .
                     
                  


            
Title: Need help with this script
Post by: Legacy_ffbj 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 .