Inheritance of objects

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Inheritance of objects

Postby Apeirogon » Mon Jan 07, 2019 4:45 pm

So, looks like "is" keyword applied to object type class dont return true when it should.
For example
Code: Select allExpand view
   size = allactorclasses.size();

   for(int i = 0; i < size; i++)
   {
      if(allactorclasses[i] is "object_name")
      {
         console.printf("is works");            
      }
   }

somewhere else

class object_name
{}

dont print in console anything.
So is there are any other way to check inheritance of object like classes? Or I do something wrong?

What I need in this case, return all objects inherited from another base class object for some function, which contains some pointers to cvars which can not be returned to that functions in other ways.
Apeirogon
I have a strange sense of humour
 
Joined: 12 Jun 2017

Re: Inheritance of objects

Postby Player701 » Tue Jan 08, 2019 5:39 am

The AllActorClasses array seems to contain only classes inherited from Actor. Which, if you think about it, is kind of logical. Your class "object_name", however, is not inherited from Actor, so it's not included in the array. That's why your code doesn't print anything.
User avatar
Player701
You are now breathing manually.
 
Joined: 13 May 2009
Location: Russian Federation
Discord: Player701#8214

Re: Inheritance of objects

Postby Graf Zahl » Tue Jan 08, 2019 5:47 am

The name AllActorClasses already tells by its name what it contains. Its a partial sublist of the full class list for looking up actors. The full list can be found in AllClasses.
User avatar
Graf Zahl
Lead GZDoom Developer
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: Inheritance of objects

Postby Apeirogon » Tue Jan 08, 2019 2:59 pm

All actor classes array contains only actors and descendants.

That not that obvious. I mean, this is zscript, which already have much non obvious (undocumented, more precisely) things.
Apeirogon
I have a strange sense of humour
 
Joined: 12 Jun 2017

Re: Inheritance of objects

Postby Graf Zahl » Wed Jan 09, 2019 5:27 am

If an array is called All*ACTOR*Classes, why do you expect non-actors to be in there?
User avatar
Graf Zahl
Lead GZDoom Developer
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: Inheritance of objects

Postby Apeirogon » Wed Jan 09, 2019 11:24 am

I just misunderstood what it contain, when first time seen it in use in some mod.
Apeirogon
I have a strange sense of humour
 
Joined: 12 Jun 2017


Return to Scripting

Who is online

Users browsing this forum: kb1 and 2 guests