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.

ZScript extend clarification

Postby SuaveSteve » Sat Jan 06, 2018 5:24 am

ZScript supports inheritance just like DECORATE does, but what exactly is the difference with the extend keyword?
SuaveSteve
 
Joined: 05 Jul 2014

Re: ZScript extend clarification

Postby _mental_ » Sat Jan 06, 2018 5:57 am

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.
_mental_
 
 
 
Joined: 07 Aug 2011

Re: ZScript extend clarification

Postby SuaveSteve » Sat Jan 06, 2018 6:01 am

And what's the difference between that and inheriting and replacing a class?
SuaveSteve
 
Joined: 05 Jul 2014

Re: ZScript extend clarification

Postby _mental_ » Sat Jan 06, 2018 6:13 am

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


Return to Scripting

Who is online

Users browsing this forum: No registered users and 2 guests