"How do I ZScript?"

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!)
Locked
User avatar
gwHero
Posts: 360
Joined: Mon May 08, 2017 3:23 am
Graphics Processor: Intel with Vulkan/Metal Support
Location: The Netherlands

Re: "How do I ZScript?"

Post by gwHero »

I was a bit experimenting with Nash's shadowsprites trying to implement his code also for decoration sprites like trees. Since it is written in ZScript, I have converted some of them from Decorate to Zscript. I got it working, except the sprite & classnames are not recognized in GZDoomBuilder Bugfix. Am I doing something wrong or is the editor not prepared yet for custom ZScript sprites? (I am using the most recent version R2986)

This is the code for one of the sprites in a file named zscript/ZVegetation.txt:

Code: Select all


class HrFir1 : Actor
{
	//$Category HeroVegetation
	//$Title "Fir tree 1"
	//$Sprite "HFI1A0"
	Default
	{
		Radius 16;
		Height 70;
		+SOLID
	}
	States
	{
	Spawn:	
		HFI1 A -1;
		Stop;
	}
}
referenced from zscript.txt in the root of the pk3:

Code: Select all

version "2.5"

#include "zscript/SpriteShadow.txt"
#include "zscript/ZVegetation.txt"
Actually quite straightforwarded. Btw. the editor number is defined in DoomEdNums from Mapinfo, and that's the only property the editor recognizes. So it's not a big deal, but it would be nice to get rid of the questionmark icons in the editor.
User avatar
Gutawer
Posts: 469
Joined: Sat Apr 16, 2016 6:01 am
Preferred Pronouns: She/Her

Re: "How do I ZScript?"

Post by Gutawer »

You have to put the GZDB-BF properties in the Default block, like the rest of the properties.
User avatar
gwHero
Posts: 360
Joined: Mon May 08, 2017 3:23 am
Graphics Processor: Intel with Vulkan/Metal Support
Location: The Netherlands

Re: "How do I ZScript?"

Post by gwHero »

You have to put the GZDB-BF properties in the Default block, like the rest of the properties.
Sounds logical! Thanks for the suggestion. But it didn't help, even put quotes around the category, but still no result.


UPDATE:
Since ZSCRIPT is all brand new I wouldn't dare this to call a bug, but assuming my ZScript code is correct, it seems that ZScript actors are not completely processed properly yet. A quick fix from the code I downloaded from Github did solve the problem, so I will report this in the proper place.

UPDATE2:
Issue solved. In my testwad I had only included the doom2.wad. Did not realize that when I moved the actor to Zscript code, I had to include the GZDoom.pk3 too. So just a user blunder.
User avatar
Rip and Tear
Posts: 185
Joined: Tue May 02, 2017 3:54 pm

Re: "How do I ZScript?"

Post by Rip and Tear »

Seeing the somewhat convoluted map detection system in the next Brutal Doom update got me thinking... ZDoom has a built in map identification system for automatic compatibility using MD5 checksums (see mapchecksum CCMD). Is there a way to utilize that to detect maps in ZScript?
User avatar
Zhs2
Posts: 1271
Joined: Fri Nov 07, 2008 3:29 pm
Graphics Processor: ATI/AMD with Vulkan/Metal Support
Location: Maryland, USA, but probably also in someone's mod somewhere
Contact:

Re: "How do I ZScript?"

Post by Zhs2 »

Asked this one on Discord and found that no one really knew if it was possible or not. Can a class' default properties be referenced elsewhere in the code? For example, I have a class AmmoType that inherits from Ammo, and I've defined it with a MaxAmount property. Can I reference this number somewhere else, as in AmmoType.MaxAmount? Or is this impossible since arbitrarily initializing a variable with an Actor-derived class is disallowed?
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: "How do I ZScript?"

Post by Matt »

How do you get a team name? According to this it should be "teams.getname()" but that just exits with "Unknown function GetName"
User avatar
phantombeta
Posts: 2089
Joined: Thu May 02, 2013 1:27 am
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: Brazil

Re: "How do I ZScript?"

Post by phantombeta »

Does ZScript have NaN and/or Infinity for floating-point types?
If so, how do I check if one is NaN? "floatVal == NaN"? "floatVal == float.NaN"?
EDIT:
Nevermind, apparently it does support NaN and Infinity
User avatar
Agentbromsnor
Posts: 265
Joined: Wed Mar 28, 2012 2:27 am

Re: "How do I ZScript?"

Post by Agentbromsnor »

This has probably been asked before, but I've been looking for a way to print things using ZScript so I can test out my functions. I can't seem to find anything in this regard on the ZDoom wiki. I know that some programs use different printing functions for debugging though. Can anyone help me with this?
User avatar
Rip and Tear
Posts: 185
Joined: Tue May 02, 2017 3:54 pm

Re: "How do I ZScript?"

Post by Rip and Tear »

Agentbromsnor wrote:This has probably been asked before, but I've been looking for a way to print things using ZScript so I can test out my functions. I can't seem to find anything in this regard on the ZDoom wiki. I know that some programs use different printing functions for debugging though. Can anyone help me with this?
https://zdoom.org/wiki/A_Log
https://zdoom.org/wiki/A_LogFloat
https://zdoom.org/wiki/A_LogInt
User avatar
Agentbromsnor
Posts: 265
Joined: Wed Mar 28, 2012 2:27 am

Re: "How do I ZScript?"

Post by Agentbromsnor »

Okay, but can you also use it in a void function like that? Thanks!
User avatar
ZZYZX
 
 
Posts: 1384
Joined: Sun Oct 14, 2012 1:43 am
Location: Ukraine
Contact:

Re: "How do I ZScript?"

Post by ZZYZX »

Agentbromsnor wrote:This has probably been asked before, but I've been looking for a way to print things using ZScript so I can test out my functions. I can't seem to find anything in this regard on the ZDoom wiki. I know that some programs use different printing functions for debugging though. Can anyone help me with this?
Console.Printf. Same arguments as String.Format, but returns void and prints instead.
User avatar
Agentbromsnor
Posts: 265
Joined: Wed Mar 28, 2012 2:27 am

Re: "How do I ZScript?"

Post by Agentbromsnor »

ZZYZX wrote:
Agentbromsnor wrote:This has probably been asked before, but I've been looking for a way to print things using ZScript so I can test out my functions. I can't seem to find anything in this regard on the ZDoom wiki. I know that some programs use different printing functions for debugging though. Can anyone help me with this?
Console.Printf. Same arguments as String.Format, but returns void and prints instead.
At first, GZDoom threw up an error, but all I had to do is update to the latest version of GZDoom to solve it. Thanks!
User avatar
Gutawer
Posts: 469
Joined: Sat Apr 16, 2016 6:01 am
Preferred Pronouns: She/Her

Re: "How do I ZScript?"

Post by Gutawer »

Is there an equivalent to Thing_SetGoal() that uses pointers instead of TIDs?
User avatar
AFADoomer
Posts: 1326
Joined: Tue Jul 15, 2003 4:18 pm
Contact:

Re: "How do I ZScript?"

Post by AFADoomer »

Gutawer wrote:Is there an equivalent to Thing_SetGoal() that uses pointers instead of TIDs?
(Assuming this is in an actor, and that you want to set that actor's goal)

Code: Select all

            goal = goalobjectpointer;
            bChaseGoal = True; // equivalent to the "don't chase target" flag - or just leave it off for normal behavior.
 
User avatar
Nash
 
 
Posts: 17439
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: "How do I ZScript?"

Post by Nash »

What's stopping you from just overwriting/assigning to "target" directly?

///////////////

Question: what is for (;;) and why is it used that way?
Locked

Return to “Scripting”