Inheritance of objects

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

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.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Post Reply
User avatar
Apeirogon
Posts: 1605
Joined: Mon Jun 12, 2017 12:57 am

Inheritance of objects

Post by Apeirogon »

So, looks like "is" keyword applied to object type class dont return true when it should.
For example

Code: Select all

	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.
User avatar
Player701
 
 
Posts: 1640
Joined: Wed May 13, 2009 3:15 am
Graphics Processor: nVidia with Vulkan support
Contact:

Re: Inheritance of objects

Post by Player701 »

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
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49072
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Inheritance of objects

Post by Graf Zahl »

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
Apeirogon
Posts: 1605
Joined: Mon Jun 12, 2017 12:57 am

Re: Inheritance of objects

Post by Apeirogon »

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.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49072
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Inheritance of objects

Post by Graf Zahl »

If an array is called All*ACTOR*Classes, why do you expect non-actors to be in there?
User avatar
Apeirogon
Posts: 1605
Joined: Mon Jun 12, 2017 12:57 am

Re: Inheritance of objects

Post by Apeirogon »

I just misunderstood what it contain, when first time seen it in use in some mod.
Post Reply

Return to “Scripting”