ZScript Documentation

Handy guides on how to do things, written by users for users.

Moderators: GZDoom Developers, Raze Developers

Forum rules
Please don't start threads here asking for help. This forum is not for requesting guides, only for posting them. If you need help, the Editing forum is for you.
User avatar
Rachael
Posts: 13791
Joined: Tue Jan 13, 2004 1:31 pm
Preferred Pronouns: She/Her

Re: ZScript Documentation

Post by Rachael »

Gez wrote:A few things:
  1. DECORATE and ZScript have the same backend. Once it's compiled there is no difference for the engine whether something was coded in DECORATE or ZScript.
  2. There's no need to convert stuff just for the purpose of having converted it. Only convert what you need to convert.
  3. DECORATE will remain forever supported.
4. DECORATE will remain supported, however it will not itself be updated, only the action functions you can use. (And I believe, actually, those can be defined in ZScript anyhow, and used in DECORATE later, if I am not mistaken)
D2JK
Posts: 545
Joined: Sat Aug 30, 2014 8:21 am

Re: ZScript Documentation

Post by D2JK »

I just spent some time editing in the virtual functions for thinker and actor.
If I override the CanCollideWith function, and just want to add a single rule, is it possible to end it with Super.CanCollideWith(); like with some of the other overrides? Or does it mess things up if the only thing I include in the override is that single addition of my own, and nothing else?
User avatar
Major Cooke
Posts: 8196
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: ZScript Documentation

Post by Major Cooke »

You can do super. Any virtual function can do that but just note, if it inherits from Actor/internal class, it's pointless to do that because it's empty.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49182
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: ZScript Documentation

Post by Graf Zahl »

AActor.CanCollideWith does nothing, there's no need to call it. If you want to stack rules for subclasses it can surely be used that way.
User avatar
Major Cooke
Posts: 8196
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: ZScript Documentation

Post by Major Cooke »

Remind me again, when is the 'action' word necessary?
D2JK
Posts: 545
Joined: Sat Aug 30, 2014 8:21 am

Re: ZScript Documentation

Post by D2JK »

Code: Select all

Override bool CanCollideWith(actor other, bool passive)
 {
  if (other.health < 50)				return false;
  else							         return true;
 }
This is on a projectile. Is it intended that this projectile will now always collide with -SOLID monsters (regardless of their health), but otherwise, the health check is obeyed?
User avatar
Major Cooke
Posts: 8196
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: ZScript Documentation

Post by Major Cooke »

You forgot to add passive bool checks. Check the information carefully.
D2JK
Posts: 545
Joined: Sat Aug 30, 2014 8:21 am

Re: ZScript Documentation

Post by D2JK »

Ok, I think I get it. If the monster is not solid, this function will not be called in the first place, so it doesn't matter what conditions I've written in it.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49182
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: ZScript Documentation

Post by Graf Zahl »

Major Cooke wrote:Remind me again, when is the 'action' word necessary?

Only for weapons, overlays and custom inventory states.
User avatar
Enjay
 
 
Posts: 26571
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland

Re: ZScript Documentation

Post by Enjay »

Something that might be useful in the documentation as a bit of a primer for people, a sort of "What can ZScript do for me" section to let people know how ZScript fits in to and dovetails with the various scripting systems and text definition options available in ZDoom and some basic suggestions of the kind of thing a modder could use ZScipt for.

I know that the page currently says "ZScript (formerly known as DoomScript) is a text-format lump used to create classes or structs for use in ZDoom. It can include the names of other lumps for processing similar to DECORATE." and that's fine as a basic introduction but something to ease people in to zscript and show them what it's all about, thereby making it more accessible, would be good IMO. I would do it myself but I don't feel expert enough in ZScript. Having missed the whole thing kicking off properly, I'm a bit behind the curve and only slowly getting to grips with it myself.
D2JK
Posts: 545
Joined: Sat Aug 30, 2014 8:21 am

Re: ZScript Documentation

Post by D2JK »

I'm sure it's been explained somewhere, but how do I convert a pointed class name into a string, so that I can use this string in A_Log, for example?

Code: Select all

if (target)
 {
  String S = target. <What do I write here?>
  A_Log(S);
 }
Being able to do this should help me a lot when trying to fix certain problems.
User avatar
Major Cooke
Posts: 8196
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: ZScript Documentation

Post by Major Cooke »

Does GetClass() work in that regard?
User avatar
Major Cooke
Posts: 8196
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: ZScript Documentation

Post by Major Cooke »

Enjay wrote:Something that might be useful in the documentation as a bit of a primer for people, a sort of "What can ZScript do for me" section to let people know how ZScript fits in to and dovetails with the various scripting systems and text definition options available in ZDoom and some basic suggestions of the kind of thing a modder could use ZScipt for.

I know that the page currently says "ZScript (formerly known as DoomScript) is a text-format lump used to create classes or structs for use in ZDoom. It can include the names of other lumps for processing similar to DECORATE." and that's fine as a basic introduction but something to ease people in to zscript and show them what it's all about, thereby making it more accessible, would be good IMO. I would do it myself but I don't feel expert enough in ZScript. Having missed the whole thing kicking off properly, I'm a bit behind the curve and only slowly getting to grips with it myself.
Join the club. We gots cookies.

Seriously though, I cannot exactly do that when I am still coming to grips with it too. I still have a lot to learn about it, and thus I cannot recommend it until someone like Graf does some of the editing himself on the wiki page.
D2JK
Posts: 545
Joined: Sat Aug 30, 2014 8:21 am

Re: ZScript Documentation

Post by D2JK »

Does GetClass() work in that regard?
No. "Cannot convert to string".
User avatar
Major Cooke
Posts: 8196
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: ZScript Documentation

Post by Major Cooke »

Maybe this might help you.

Return to “Tutorials”