zscript vs decorate?

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!)
User avatar
Evatron
Posts: 23
Joined: Wed Mar 25, 2020 11:03 am

zscript vs decorate?

Post by Evatron »

sorry for the noob questions, im still getting the hang of wads beyond just maps.

i recently completed a custom monster based on an imp with a DECORATE script. everything worked except the textures had not changed and were the default imp sprites. i downloaded a custom monster from realm667 to learn from and see what i had done wrong. the first thing i noticed was that it uses ZSCRIPT instead of DECORATE. i then saw the ZSCRIPT had no references to existing monsters in it (mine used "DoomImp" and the ZSCRIPT had "Actor") and thought i should be using ZSCRIPT instead for my monster? but i dont really understand the difference.

so tldr - what is the difference between ZSCRIPT and DECORATE and which should i be using?

Thanks
User avatar
Enjay
 
 
Posts: 26517
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Re: zscript vs decorate?

Post by Enjay »

DECORATE still works, but ZScipt is far more powerful and flexible. As a result, there is more to learn with ZScript.

However, if you are just making relatively simple actors in ZScript, the process is very similar to that of DECORATE. The most obvious differences that you will notice immediately are that ZScript requires more {} and ; in its code and all entities are called Classes (which can inherit from Actor).

Internally, all the core actors have been converted to ZScript so if you need to inherit from an existing enemy, the system is basically the same as it would be with DECORATE. i.e. name your new enemy class and use : followed by the class that you want to inherit from.

e.g.

Code: Select all

class MyCoolEnemy : DoomImp
{ 
[do interesting stuff here]
]
User avatar
Redneckerz
Spotlight Team
Posts: 1050
Joined: Mon Nov 25, 2019 8:54 am
Graphics Processor: Intel (Modern GZDoom)

Re: zscript vs decorate?

Post by Redneckerz »

Evatron wrote:sorry for the noob questions, im still getting the hang of wads beyond just maps.

i recently completed a custom monster based on an imp with a DECORATE script. everything worked except the textures had not changed and were the default imp sprites. i downloaded a custom monster from realm667 to learn from and see what i had done wrong. the first thing i noticed was that it uses ZSCRIPT instead of DECORATE. i then saw the ZSCRIPT had no references to existing monsters in it (mine used "DoomImp" and the ZSCRIPT had "Actor") and thought i should be using ZSCRIPT instead for my monster? but i dont really understand the difference.

so tldr - what is the difference between ZSCRIPT and DECORATE and which should i be using?

Thanks
ZScript and DECORATE are very similar to one another, but ZScript gives far greater flexibility. You can actually combine ZScript and DECORATE. Please read the following pages:
ZScript
DECORATE

EDIT: Ah, a wild Enjay appeared and had the same thought again! :wink:

To combine ZScript and Decorate: Combining ZScript and DECORATE
Lastly, there is also Marrub's excellent ZScript documentation: ZScript Documentation.
Last edited by Redneckerz on Thu Mar 26, 2020 12:40 pm, edited 1 time in total.
Jarewill
 
 
Posts: 1759
Joined: Sun Jul 21, 2019 8:54 am

Re: zscript vs decorate?

Post by Jarewill »

For one ZScript provides far more possibilities when it comes to coding.
It allows making internal classes, allowing to completely rewrite the whole definition of Doom.

However, for start I would definitely recommend going for DECORATE. It is just far simpler to understand and is more documented on the wiki.
The reason your monster appeared as a normal imp is probably because it didn't have any states defined and used the imp's states instead.
You can look at the imp's DECORATE definition to see how to define proper states.

But there is no need to inherit from an already existing monster when making new ones.
Monsters are defined by having the "Monster" property.

As for the reason ZScript's monster inherits from "Actor" is because ZScript allows to write internal engine classes, so in order to make a normal actor, one needs to inherit from the "Actor" class.
DECORATE only allows to write actors, so instead of writing [Class x : Actor], DECORATE just uses [Actor x].

And also, last time I've looked at a monster from Realm667, they provide both ZScript and DECORATE code. The DECORATE version being names as "Old code" or something similar to that.

Edit: I took way too long writing all this....
User avatar
Evatron
Posts: 23
Joined: Wed Mar 25, 2020 11:03 am

Re: zscript vs decorate?

Post by Evatron »

Enjay wrote:DECORATE still works, but ZScipt is far more powerful and flexible. As a result, there is more to learn with ZScript.

However, if you are just making relatively simple actors in ZScript, the process is very similar to that of DECORATE. The most obvious differences that you will notice immediately are that ZScript requires more {} and ; in its code and all entities are called Classes (which can inherit from Actor).

Internally, all the core actors have been converted to ZScript so if you need to inherit from an existing enemy, the system is basically the same as it would be with DECORATE. i.e. name your new enemy class and use : followed by the class that you want to inherit from.

e.g.

Code: Select all

class MyCoolEnemy : DoomImp
{ 
[do interesting stuff here]
]
Ah okay thats interesting. But if i made a monster in ZScript where would i access it in doom builder? would it still be under decorates?
Jarewill
 
 
Posts: 1759
Joined: Sun Jul 21, 2019 8:54 am

Re: zscript vs decorate?

Post by Jarewill »

When it comes to putting custom monsters on the map, they need an editor number.

In DECORATE, they can be assigned at the end of the first line of the monster (after ACTOR x and inheritance).
ZScript doesn't allow to do it this way and instead needs to be done in MAPINFO's editor number definition
Gez
 
 
Posts: 17833
Joined: Fri Jul 06, 2007 3:22 pm

Re: zscript vs decorate?

Post by Gez »

DECORATE is simpler but more basic. If you're not going to do complex actors, you can keep with DECORATE. ZScript is a better choice when you want to do complex behaviors.

For Realm667 actors that use ZScript, you can usually find an "OLDCODE" lump that contains DECORATE code.
User avatar
Enjay
 
 
Posts: 26517
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Re: zscript vs decorate?

Post by Enjay »

One of the nice things that I like about ZScript over DECORATE is that you can give a single frame several action whereas in DECORATE you might have something like:

Code: Select all

TROO A 0 A_CoolThing1
TROO A 0 A_CoolThing2
TROO A 0 A_CoolThing3
TROO A 6 A_CoolThing4
In Zscript you can have something like

Code: Select all

TROO A 6
    {
        A_CoolThing1;
        A_CoolThing2;
        A_CoolThing3;
        A_CoolThing4;
    }
Personally I still use a mixture of both. If I'm working with older stuff that already has DECORATE, unless I have a reason to convert it I don't bother. If, however, I need something that DECORATE can't do, or I'm doing something absolutely from scratch, I'll use ZScript.

Like I said earlier, at a basic level, ZScript and DECORATE are very similar with relatively minor syntax differences. You've got plenty of links to information now so pick what works for you and have fun with it. :)
Jarewill
 
 
Posts: 1759
Joined: Sun Jul 21, 2019 8:54 am

Re: zscript vs decorate?

Post by Jarewill »

Actually DECORATE supports multiple actions on one frame too.
User avatar
Agentbromsnor
Posts: 265
Joined: Wed Mar 28, 2012 2:27 am

Re: zscript vs decorate?

Post by Agentbromsnor »

ZScript is for programmers who don't need any hand holding what so ever. Being familiar with C++ helps.

DECORATE is generally preferred within the community because it is much better documented and you don't need to be a seasoned programmer to understand it.
User avatar
Enjay
 
 
Posts: 26517
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Re: zscript vs decorate?

Post by Enjay »

Jarewill wrote:Actually DECORATE supports multiple actions on one frame too.
I stand corrected. I thought it was just a ZScript thing. Either way, it's useful versus the old multiple 0 length frames. But that does mean one less advantage for ZScript I guess. ;)
User avatar
3saster
Posts: 199
Joined: Fri May 11, 2018 2:39 pm
Location: Canada

Re: zscript vs decorate?

Post by 3saster »

Agentbromsnor wrote:ZScript is for programmers who don't need any hand holding what so ever. Being familiar with C++ helps.

DECORATE is generally preferred within the community because it is much better documented and you don't need to be a seasoned programmer to understand it.
This is a common misconception that isn't true at all. DECORATE and basic ZScript only differ by mostly by some semicolons and extra brackets; see the zombieman page. The main difference is that ZScript has lots of handy stuff that can be taken advantage of even in basic mods. Sure, the complicated stuff will look like you need programming experience, but basic stuff will look nearly identical to DECORATE (see this page for the syntax differences). On top of that, every single function in DECORATE is also in ZScript (this is an automatic engine side thing), and since the syntax is similar, every single DECORATE tutorial, etc, also holds for ZScript. So it is my recommendation that you start with ZScript, since you have access to all the potentially useful additions, and you do not have to go through the tedious conversion process when/if you realize you want some of ZScript's functionality. Furthermore, DECORATE is deprecated; ZScript is actively being developed. To quote this document:
Jekyll Grim Payne wrote:Now, there are a lot of misconceptions related to this point, so it’s important to expand on it.
The first common misconception is that ZScript is supposedly harder to use than DECORATE. This is, in fact, not true: ZScript just has a much higher ceiling in terms of the available features and possibilities. However, the base is the same in both languages. In fact, simple base actors, such as vanilla Doom enemies and props, look almost identical in ZScript and DECORATE, except for a few headers and semicolons. This is demonstrated on the Zombieman page on ZDoom wiki. The learning curve is longer but it’s not necessarily steeper.
In other words, if you know DECORATE, you’re already ready to code ZScript. Yes, your ZScript code will be simple at first, but that’s OK. Nobody starts advanced. And no, just like DECORATE, ZScript does not necessarily require any previous programming experience.
That being said, there is ONE reason to use DECORATE over ZScript. Zandronum only supports DECORATE (and an old version at that), not ZScript (and never will), so if multiplayer is an absolutely integral part of your mod, then consider using DECORATE (even then, it won't support everything that GZDoom DECORATE does). Other than this one reason, there is no reason to use DECORATE over ZScript in a new project.
Gez
 
 
Posts: 17833
Joined: Fri Jul 06, 2007 3:22 pm

Re: zscript vs decorate?

Post by Gez »

The main advantage of DECORATE is greater compatibility with other ports -- Zandronum, K8Vavoom, and perhaps also even DelphiDoom. DECORATE also enjoys greater support in editors -- I doubt DBX will ever bother parsing ZScript, for instance.
User avatar
Matt
Posts: 9696
Joined: Sun Jan 04, 2004 5:37 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Debian Bullseye
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
Contact:

Re: zscript vs decorate?

Post by Matt »

One qualifier about DECORATE being more compatible: Zandronum's lag behind GZDoom is much larger than just ZScript, so it's possible to accidentally - and for all practical purposes irretrievably - code something for GZDoom that is impossible to convert to Zandro compat later.

I would strongly recommend starting in ZScript first, since you can just ignore all the stuff you don't understand and revisit it later without spending hours converting old code.
User avatar
Kizoky
Posts: 291
Joined: Mon Nov 14, 2011 9:59 am
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia with Vulkan support
Location: Around weirdos, I'm the biggest weirdo among them
Contact:

Re: zscript vs decorate?

Post by Kizoky »

ZScript is harder than DECORATE yes, but once you learned how to use it you absolutely won't want to go back fiddling with DECORATE
I'm not really a programmer myself, still I learned how to use it
Post Reply

Return to “Scripting”