ZScript extend clarification

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!)
SuaveSteve
Posts: 76
Joined: Sat Jul 05, 2014 7:38 am

ZScript extend clarification

Post by SuaveSteve »

ZScript supports inheritance just like DECORATE does, but what exactly is the difference with the extend keyword?
_mental_
 
 
Posts: 3814
Joined: Sun Aug 07, 2011 4:32 am

Re: ZScript extend clarification

Post by _mental_ »

Like the name implies extend allows to add functions to already existing class without altering its definition.
It’s possible to define a class in multiple files for example. This feature has nothing to do with inheritance.
SuaveSteve
Posts: 76
Joined: Sat Jul 05, 2014 7:38 am

Re: ZScript extend clarification

Post by SuaveSteve »

And what's the difference between that and inheriting and replacing a class?
_mental_
 
 
Posts: 3814
Joined: Sun Aug 07, 2011 4:32 am

Re: ZScript extend clarification

Post by _mental_ »

Check extension of StateProvider class for almost every weapon in GZDoom core ZScript lumps.
How do you suppose to achieve this with class replacement?

Return to “Scripting”