ZScript Basics: a guide for non-programmers

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.

ZScript Basics: a guide for non-programmers

Postby Jekyll Grim Payne » Mon Apr 20, 2020 5:17 am

ZScript Basics: a guide for non-programmers from a non-programmer


I started on zscript in early 2019 and have been familiarizing myself with it as a person with zero coding and little math experience, having only worked with DECORATE/ACS in the past. I'm now writing and compliting this basics guide on github:

The Guide:
https://github.com/jekyllgrim/ZScript_Basics

You could argue that it's better to read an actual coding guide, like on C#, and you're probably right. But there are tons of people out there who have been doing DECORATE hacks for years and are now in a pickle, since all the cool kids are doing ZScript, and they don't know how to join the fun and aren't necessarily willing to learn actual coding for that. This guide is for them.

Please note the following:
  • This is a work in progress. Some chapters aren't finished yet but are planned or have a draft (i.e. they're mentioned in Contents but don't have active links). Some are only in my head.
  • This guide won't cover everything. The chapter names you can see under Contents are close to being a complete plan. The guide is intended for people who are willing to continue learning new stuff on their own, and it only really covers the basics of the main aspects of ZScript.
  • Some examples and explanations in the guide are purposefully simplified. I try to make sure they're never incorrect for the sake of simplicity, but they can be incomplete.
  • There are no collaborators right now, but once I'm done with the main bulk, I'll probably be accepting help.
User avatar
Jekyll Grim Payne
 
Joined: 21 Jul 2008
Discord: Agent_Ash#4401
Github ID: jekyllgrim
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia (Modern GZDoom)

Re: ZScript Basics: a guide for non-programmers

Postby Kzer-Za » Tue May 19, 2020 5:08 am

Hi!

I've been reading your guide again and found one thing in Virtual Functions section that I've looked over the first couple times:

Code: Select allExpand view
if (source && source is "Zombieman")


Can I ask what is "is"? What are the rules for using it? Until now I thought that the way to check the class of the source of the damage was
Code: Select allExpand view
if(source.GetClass() == "Zombieman")


PS. I must say that your guide is great!
Kzer-Za
 
Joined: 20 Aug 2017

Re: ZScript Basics: a guide for non-programmers

Postby 3saster » Tue May 19, 2020 9:36 am

"is" is a special keyword in ZScript. To use the "Zombieman" example you provided,
Code: Select allExpand view
source is "Zombieman"
will return true if source is a class of type "Zombieman" OR is a class derived from "Zombieman". By comparison, the example you posted using GetClass will only return true if the source is a class of type "Zombieman" (and will return false for classes derived from it). To use an actual example, suppose the source is a "HellKnight" (which is derived from "BaronOfHell"). Then
Code: Select allExpand view
source is "BaronOfHell"

will return true, while
Code: Select allExpand view
source.GetClass() == "BaronOfHell"

or (a more common and slightly more robust way a specific class can be checked against)
Code: Select allExpand view
source.GetClassName() == "BaronOfHell" //replace == with ~== for a case insensitive compare

will both return false.
User avatar
3saster
 
Joined: 11 May 2018
Location: Canada

Re: ZScript Basics: a guide for non-programmers

Postby Kzer-Za » Tue May 19, 2020 1:46 pm

Thanks!
Kzer-Za
 
Joined: 20 Aug 2017

Re: ZScript Basics: a guide for non-programmers

Postby Lagi » Tue May 19, 2020 2:15 pm

this is a great tutorial,

not that i want to understand what all that means, but it was nice to read. I very quickly get the concept of things, and your examples from doom help a lot to get the concept behind some "code structures"
User avatar
Lagi
 
Joined: 23 Jun 2018
Location: Thou shalt alter thy beliefs with new evidence

Re: ZScript Basics: a guide for non-programmers

Postby Gifty » Wed May 20, 2020 12:03 am

This is just what I was looking for, thanks for putting this together!
User avatar
Gifty
Recon'ize that smell?
 
Joined: 16 Jun 2013


Return to Tutorials

Who is online

Users browsing this forum: No registered users and 1 guest