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.

zscript vs decorate?

Postby Evatron » Thu Mar 26, 2020 11:36 am

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
Evatron
 
Joined: 25 Mar 2020
Operating System: Windows XP/2003

Re: zscript vs decorate?

Postby Enjay » Thu Mar 26, 2020 12:35 pm

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 allExpand view
class MyCoolEnemy : DoomImp
{
[do interesting stuff here]
]
User avatar
Enjay
Everyone is a moon, and has a dark side which he never shows to anybody. Twain
 
 
 
Joined: 15 Jul 2003
Location: Scotland

Re: zscript vs decorate?

Postby Redneckerz » Thu Mar 26, 2020 12:38 pm

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.
User avatar
Redneckerz
To it's ports i may have seen
Spotlight Team
 
Joined: 25 Nov 2019
Discord: Redneckerz#8399
Operating System: Windows Vista/7/2008 64-bit
Graphics Processor: nVidia (Legacy GZDoom)

Re: zscript vs decorate?

Postby Jarewill » Thu Mar 26, 2020 12:39 pm

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....
Jarewill
 
 
 
Joined: 21 Jul 2019

Re: zscript vs decorate?

Postby Evatron » Thu Mar 26, 2020 12:48 pm

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 allExpand view
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?
User avatar
Evatron
 
Joined: 25 Mar 2020
Operating System: Windows XP/2003

Re: zscript vs decorate?

Postby Jarewill » Thu Mar 26, 2020 12:51 pm

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
Jarewill
 
 
 
Joined: 21 Jul 2019

Re: zscript vs decorate?

Postby Gez » Thu Mar 26, 2020 1:41 pm

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.
Gez
 
 
 
Joined: 06 Jul 2007

Re: zscript vs decorate?

Postby Enjay » Thu Mar 26, 2020 2:48 pm

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 allExpand view
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 allExpand view
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. :)
User avatar
Enjay
Everyone is a moon, and has a dark side which he never shows to anybody. Twain
 
 
 
Joined: 15 Jul 2003
Location: Scotland

Re: zscript vs decorate?

Postby Jarewill » Thu Mar 26, 2020 2:49 pm

Actually DECORATE supports multiple actions on one frame too.
Jarewill
 
 
 
Joined: 21 Jul 2019

Re: zscript vs decorate?

Postby Agentbromsnor » Thu Mar 26, 2020 3:07 pm

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
Agentbromsnor
 
Joined: 28 Mar 2012

Re: zscript vs decorate?

Postby Enjay » Thu Mar 26, 2020 3:09 pm

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
Enjay
Everyone is a moon, and has a dark side which he never shows to anybody. Twain
 
 
 
Joined: 15 Jul 2003
Location: Scotland

Re: zscript vs decorate?

Postby 3saster » Thu Mar 26, 2020 4:59 pm

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.
User avatar
3saster
 
Joined: 11 May 2018
Location: Canada

Re: zscript vs decorate?

Postby Gez » Thu Mar 26, 2020 5:16 pm

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.
Gez
 
 
 
Joined: 06 Jul 2007

Re: zscript vs decorate?

Postby Matt » Thu Mar 26, 2020 5:35 pm

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
Matt
Putting the XD into *xdeath since 2007
 
Joined: 04 Jan 2004
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia

Re: zscript vs decorate?

Postby Kizoky » Thu Mar 26, 2020 5:45 pm

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
User avatar
Kizoky
I smell like gravity
 
Joined: 14 Nov 2011
Location: Around weirdos, I'm the biggest weirdo among them
Discord: Kizoky#0375
Operating System: Windows 10/8.1/8/201x 64-bit
Graphics Processor: nVidia with Vulkan support

Next

Return to Scripting

Who is online

Users browsing this forum: No registered users and 2 guests