Author Topic: GetObjectByTag : error?  (Read 326 times)

Legacy_Buddywarrior

  • Hero Member
  • *****
  • Posts: 512
  • Karma: +0/-0
GetObjectByTag : error?
« on: May 26, 2013, 12:13:11 am »


               I'm getting a ''Mitchmatch types''' error on the code below. But both GetObjectByTag() and EffectSummonCreature() have the variable as a string? I'm at a loss, any suggestions on what would cause this?

 

string Pet;
if (GetHitDice(oPC) ==  1) Pet = GetObjectByTag("gnomegardenwisp1");  //Getting error on this line

effect eEffect;eEffect = EffectSummonCreature(Pet);

               
               

               


                     Modifié par Buddywarrior, 26 mai 2013 - 12:16 .
                     
                  


            

Legacy_the.gray.fox

  • Full Member
  • ***
  • Posts: 214
  • Karma: +0/-0
GetObjectByTag : error?
« Reply #1 on: May 26, 2013, 01:17:04 am »


               GetObjectByTag() returns an _object_ datatype.
But you are assigning the return value to a _string_ datatype. That is the mismatch.
Change the datatype of Pet, from string to object, and it will work.


-fox
               
               

               
            

Legacy_Buddywarrior

  • Hero Member
  • *****
  • Posts: 512
  • Karma: +0/-0
GetObjectByTag : error?
« Reply #2 on: May 26, 2013, 01:21:13 am »


               That was the first thing I tried. And it didn't work sadly. ''Declaration does not match params" is the compile error.
               
               

               
            

Legacy_Buddywarrior

  • Hero Member
  • *****
  • Posts: 512
  • Karma: +0/-0
GetObjectByTag : error?
« Reply #3 on: May 26, 2013, 01:22:22 am »


               bah... ObjectToString(Pet); fixed I think. THanks for the extra pair of eyes.
               
               

               
            

Legacy__Guile

  • Hero Member
  • *****
  • Posts: 1308
  • Karma: +0/-0
GetObjectByTag : error?
« Reply #4 on: May 27, 2013, 03:52:40 am »


               keep in mind that, if 2 of these pets are in the module, then it will probably kick out an error as well....

Tags MUST be unique....

You could use GetNearestObjectByTag()..... ?
               
               

               
            

Legacy_Failed.Bard

  • Hero Member
  • *****
  • Posts: 1409
  • Karma: +0/-0
GetObjectByTag : error?
« Reply #5 on: May 27, 2013, 04:13:55 am »


               Are you trying to summon a creature that already exists somewhere within the mod?

 The GetObjectByTag() functions will only return an object if it already exists.  If the summon is something that's intended to be created right then, skip the get function entirely, and just feed in the ResRef directly into EffectSummonCreature(string sCreatureResref).