Pass class limiter as parameter to a function

Discussions about Coding and Scripting

Pass class limiter as parameter to a function

Postby PrinceOfFunky » Fri Oct 12, 2018 4:44 pm

Spoiler: show
This code is compiled fine:
Code: Select all
//Return:
//-1 - if firstClass is not relationed to secondClass.
//0 - if firstClass is the same class of secondClass.
//1 - if firstClass is child of secondClass;
//2 - if firstClass is parent of secondClass;
static final function int classIsRelatedWith(class firstClass, class secondClass, optional bool bNoSubClass) {
   if (firstClass == secondClass)
      return 0;
   
   if (!bNoSubClass) {
      if (classIsChildOf(firstClass, secondClass))
         return 1;
      else if (classIsChildOf(secondClass, firstClass))
         return 2;
   }
   
   return -1;
}

But this one:
Code: Select all
if (classIsRelatedWith(newInvClass, aClass) >= 0)

where aClass is surely a class, and newInvClass is defined as:
Code: Select all
local class<Inventory> newInvClass;
newInvClass = class<Inventory>(DynamicLoadObject(invClass, class'Inventory'));

(edit: invClass is a String)
makes the compiler throw this error:
Code: Select all
Error, Bad or missing expression in 'If'

or this error if I add a check in the parenthesis:
Code: Select all
Error, Bad or missing expression in parenthesis
Failed due to errors.

What's the problem with it? I don't often use class limiters.


EDIT: Ok I got it, it was a problem with "static", I was calling "classIsRelatedWith()" which is a static function using ClassName.static.function(), instead of reference.static.function().
I guess this topic can be closed then .o.
Image
User avatar
PrinceOfFunky
Inhuman
 
Posts: 971
Joined: Mon Aug 31, 2015 10:31 pm

Return to Coding, Scripting

Who is online

Users browsing this forum: No registered users and 1 guest