Author Topic: Need help, Starting Conditionals Script(s) not working properly...  (Read 500 times)

Legacy__Guile

  • Hero Member
  • *****
  • Posts: 1308
  • Karma: +0/-0


               OK, I made a forge, but the starting conditionals are NOT working like they should

I'll show two scripts so you can follow what's going on

In Line 1 (PC Selects The Weapon in their Right and this script fires from the ActionTaken Event Tab)

// gf_ss_rh
// This script is part of my Genisys Forge System

void main()
{
  object oPC = GetPCSpeaker();
  int nSlot = INVENTORY_SLOT_RIGHTHAND;
  SetLocalInt(oPC, "ITEM_SLOT", nSlot);
}


in Line 2 (the Property they want to select is THIS starting conditional script in the TextAppearsWhen Event Tab)

int StartingConditional()
{
   int iShow = FALSE;
   object oPC = GetPCSpeaker();
   int nSlot = GetLocalInt(oPC, "ITEM_SLOT");
   object oItem = GetItemInSlot(nSlot, oPC);
   int nType = GetBaseItemType(oItem);
   //If it's an Item that can be worn! (No Weapons Allowed!)
   if(nType == BASE_ITEM_AMULET || nType == BASE_ITEM_BOOTS ||
   BASE_ITEM_BRACER || nType == BASE_ITEM_CLOAK ||
   BASE_ITEM_GLOVES || nType == BASE_ITEM_HELMET ||
   BASE_ITEM_ARMOR || nType == BASE_ITEM_RING ||
   BASE_ITEM_SMALLSHIELD || nType == BASE_ITEM_TOWERSHIELD ||
   BASE_ITEM_LARGESHIELD)
   {
    iShow = TRUE;
   }

 return iShow;

}

But the Line with the Starting Conditional is showing when it shouldn't.  This is happening for most of my lines (except 1) and the others are exactly like the one above, except different base item types.

Any help?  '^_^'
               
               

               


                     Modifié par _Guile, 31 août 2011 - 03:11 .
                     
                  


            

Legacy__Guile

  • Hero Member
  • *****
  • Posts: 1308
  • Karma: +0/-0
Need help, Starting Conditionals Script(s) not working properly...
« Reply #1 on: August 29, 2011, 08:33:13 pm »


               Nevermind, I fixed it by changing up the script some.  '<img'>

int StartingConditional()
{
  object oPC = GetPCSpeaker();
  int nSlot = GetLocalInt(oPC, "ITEM_SLOT");
  object oItem = GetItemInSlot(nSlot, oPC);
  int nType = GetBaseItemType(oItem);

  switch(nType)
  {
   case BASE_ITEM_AMULET: { return TRUE;} break;
   case BASE_ITEM_ARMOR: { return TRUE;} break;
   case BASE_ITEM_BELT: {  return TRUE;} break;
   case BASE_ITEM_BOOTS: { return TRUE;} break;
   case BASE_ITEM_BRACER: { return TRUE;} break;
   case BASE_ITEM_CLOAK: { return TRUE;} break;
   case BASE_ITEM_GLOVES: { return TRUE;} break;
   case BASE_ITEM_HELMET: { return TRUE;} break;
   case BASE_ITEM_LARGESHIELD: { return TRUE;} break;
   case BASE_ITEM_RING: { return TRUE;} break;
   case BASE_ITEM_SMALLSHIELD: { return TRUE;} break;
   case BASE_ITEM_TOWERSHIELD: { return TRUE;} break;
  }

  return FALSE;
}
               
               

               


                     Modifié par _Guile, 30 août 2011 - 12:01 .
                     
                  


            

Legacy__Guile

  • Hero Member
  • *****
  • Posts: 1308
  • Karma: +0/-0
Need help, Starting Conditionals Script(s) not working properly...
« Reply #2 on: August 30, 2011, 01:01:31 pm »


               Anyone understand why the first version didn't work but the 2nd one did?
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Need help, Starting Conditionals Script(s) not working properly...
« Reply #3 on: August 30, 2011, 02:05:49 pm »


               Perhaps because you where getting the item in the right hand.  then checking to see if it was anything but a weapon.
               
               

               
            

Legacy__Guile

  • Hero Member
  • *****
  • Posts: 1308
  • Karma: +0/-0
Need help, Starting Conditionals Script(s) not working properly...
« Reply #4 on: August 31, 2011, 04:10:27 pm »


               

Lightfoot8 wrote...

Perhaps because you where getting the item in the right hand.  then checking to see if it was anything but a weapon.


That was what I was wanting to do, to NOT show the line if it was anything BUT the base items types I listed.
Unfortunately it was showing the line regardless, weird.
               
               

               
            

Legacy_the.gray.fox

  • Full Member
  • ***
  • Posts: 214
  • Karma: +0/-0
Need help, Starting Conditionals Script(s) not working properly...
« Reply #5 on: September 01, 2011, 02:44:14 pm »


               

_Guile wrote...

   if(nType == BASE_ITEM_AMULET || nType == BASE_ITEM_BOOTS ||
   BASE_ITEM_BRACER || nType == BASE_ITEM_CLOAK ||
   BASE_ITEM_GLOVES || nType == BASE_ITEM_HELMET ||
   BASE_ITEM_ARMOR || nType == BASE_ITEM_RING ||
   BASE_ITEM_SMALLSHIELD || nType == BASE_ITEM_TOWERSHIELD ||
   BASE_ITEM_LARGESHIELD)

Any help?  '^_^'


Hello.
Look at how you chained the Boolean OR operators and the BASE_ITEM_* constants.
I will put highlights on the initial portion of the if() :

   if(nType == BASE_ITEM_AMULET || nType == BASE_ITEM_BOOTS ||
   BASE_ITEM_BRACER || nType == BASE_ITEM_CLOAK ||

The Red expression is giving the logical bug.

BASE_ITEM_BRACER is a constant with value nonZero. That alone makes your if() evaluate to TRUE, regardless of what the other (Green) expressions evaluate to.
Hence your conversation node is made visible _always_.


-fox
               
               

               
            

Legacy__six

  • Hero Member
  • *****
  • Posts: 1436
  • Karma: +0/-0
Need help, Starting Conditionals Script(s) not working properly...
« Reply #6 on: September 01, 2011, 07:43:25 pm »


               Side note, for the advantage of having less code your switch could be changed to...

  switch(nType)
  {
   case BASE_ITEM_AMULET:
   case BASE_ITEM_ARMOR:
   case BASE_ITEM_BELT:
   case BASE_ITEM_BOOTS:
   case BASE_ITEM_BRACER:
   case BASE_ITEM_CLOAK:
   case BASE_ITEM_GLOVES:
   case BASE_ITEM_HELMET:
   case BASE_ITEM_LARGESHIELD:
   case BASE_ITEM_RING:
   case BASE_ITEM_SMALLSHIELD:
   case BASE_ITEM_TOWERSHIELD:
return TRUE;
break;

default:
return FALSE;
  }
               
               

               


                     Modifié par _six, 01 septembre 2011 - 06:44 .
                     
                  


            

Legacy__Guile

  • Hero Member
  • *****
  • Posts: 1308
  • Karma: +0/-0
Need help, Starting Conditionals Script(s) not working properly...
« Reply #7 on: September 02, 2011, 04:35:03 am »


               Sweet, awesome response guys, thanks +Rep (if I could give you one I would)