"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!)
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: "How do I ZScript?"

Post by Graf Zahl »

A dummy object is just the same as your thinker in terms of cost. If you need it repeatedly, store it in a local variable. The expensive action is to retrieve the global storage thinker, not to use it.
User avatar
Major Cooke
Posts: 8196
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: "How do I ZScript?"

Post by Major Cooke »

What's with all the const function stuff and what is its purpose?
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

Re: "How do I ZScript?"

Post by Matt »

I'm sick of typing out this sort of thing constantly:

Code: Select all

		vel+=(
			cos(angle)*cos(pitch),
			sin(angle)*cos(pitch),
			-sin(pitch)
		)*10;
I'm seeing in the actor function list a bunch of things like "Vec3Angle". Can those be used instead?
Last edited by Matt on Sat Mar 04, 2017 2:08 pm, edited 1 time in total.
User avatar
ZZYZX
 
 
Posts: 1384
Joined: Sun Oct 14, 2012 1:43 am
Location: Ukraine

Re: "How do I ZScript?"

Post by ZZYZX »

I think there are static methods in vector3... Its just that these are not defined anywhere in the ZScript files and are instead directly set on the C++ side.
Anyway I'd write a function here and forget about the overhead. Like vector3 GetRotatedUnitVector(double angle, double pitch, double roll).

There are methods in actor that can give you only angle (Vec3Angle), but not angle+pitch and certainly not roll.
User avatar
Major Cooke
Posts: 8196
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: "How do I ZScript?"

Post by Major Cooke »

Use A_ChangeVelocity with the CVF_RELATIVE flag.
User avatar
Ed the Bat
Posts: 3060
Joined: Thu May 03, 2012 1:18 pm
Graphics Processor: nVidia with Vulkan support
Location: Maryland, US

Re: "How do I ZScript?"

Post by Ed the Bat »

Just a quick question this time:

Code: Select all

class Key : Inventory
{
	Default
	{
		+DONTGIB;		// Don't disappear due to a crusher
		Inventory.InterHubAmount 0;
		Inventory.PickupSound "misc/k_pkup";
	}
	
	override bool HandlePickup (Inventory item)
	{
		// In single player, you can pick up an infinite number of keys
		// even though you can only hold one of each.
		if (multiplayer)
		{
			return Super.HandlePickup (item);
		}
		if (GetClass() == item.GetClass())
		{
			item.bPickupGood = true;
			return true;
		}
		return false;
	}

	override bool ShouldStay ()
	{
		return !!multiplayer;
	}
}
I notice in gzdoom.pk3, the definition for Key features a flag with a semicolon after it. I know it's not required, but does this mean it's optional? Does it hold any significance?
User avatar
Major Cooke
Posts: 8196
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: "How do I ZScript?"

Post by Major Cooke »

It holds no significance with flags and are completely optional.
User avatar
Ed the Bat
Posts: 3060
Joined: Thu May 03, 2012 1:18 pm
Graphics Processor: nVidia with Vulkan support
Location: Maryland, US

Re: "How do I ZScript?"

Post by Ed the Bat »

Alright, just checking. Wanna make sure I keep all my syntax proper and correct.
User avatar
Nash
 
 
Posts: 17465
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia

Re: "How do I ZScript?"

Post by Nash »

Probably a typo since everything else doesn't.

I'd still be careful because knowing ZDoom's history of 'IT USED TO WORK WTF NOW ITDOESN'T"
User avatar
Major Cooke
Posts: 8196
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: "How do I ZScript?"

Post by Major Cooke »

No, that's a feature. People requested if it could be done for consistency and Graf obliged.
User avatar
Major Cooke
Posts: 8196
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: "How do I ZScript?"

Post by Major Cooke »

Graf: How does the versioning system work? What needs to be considered when using it? What will be enabled/disabled when (not) using it?
User avatar
ZZYZX
 
 
Posts: 1384
Joined: Sun Oct 14, 2012 1:43 am
Location: Ukraine

Re: "How do I ZScript?"

Post by ZZYZX »

1.

Code: Select all

version "<latest gzdoom version goes here>"
at the top of your zscript.txt
2. Nothing
3. Only GZDoom 2.3 ZScript features with unspecified version

P.S. It's NOT DONE. It's literally not done, the latest master branch in GZDoom's repo is in an intermediate state, half there. Don't try to use versions just yet.
User avatar
Major Cooke
Posts: 8196
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: "How do I ZScript?"

Post by Major Cooke »

I have no intention of doing it right now anyway. Considering how broken things are at the moment, I'm not updating my GZDoom to the latest git right now until after it's safer.

But the whole determination of the syntax for inserting play and ui keywords will definitely need clarification so I know what and when to use them with 2.4 features.
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: "How do I ZScript?"

Post by Graf Zahl »

Major Cooke wrote:Graf: How does the versioning system work? What needs to be considered when using it? What will be enabled/disabled when (not) using it?

I can't tell you how something works that isn't even done yet.
User avatar
kodi
 
 
Posts: 1355
Joined: Mon May 06, 2013 8:02 am

Re: "How do I ZScript?"

Post by kodi »

How do apply a player property to a pointer?

Return to “Scripting”