"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!)
ZzZombo
Posts: 315
Joined: Mon Jul 16, 2012 2:02 am

Re: "How do I ZScript?"

Post by ZzZombo »

Namespacing, look it up.
User avatar
Nash
 
 
Posts: 17450
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia

Re: "How do I ZScript?"

Post by Nash »

A more helpful answer:

For resources more than 8 characters long, you must specify the full path with extension. This behaviour is consistent across (almost) everything in GZDoom. If the resouce is 8 characters or less, then GZDoom will attempt to automatically determine the namespace of the resource based on what context the resource is being called.
User avatar
Xaser
 
 
Posts: 10772
Joined: Sun Jul 20, 2003 12:15 pm

Re: "How do I ZScript?"

Post by Xaser »

^ All good info. One additional bit:
Nash wrote:This behaviour is consistent across (almost) everything in GZDoom.
The most notable exception is that sprites don't support long file names since their naming scheme is pretty critical to the way they work in the engine.

Relatedly, @vidumec: I notice your example is calling DrawImage on a resource from the "sprites" directory: is it an actual sprite? If not (e.g. it's a general HUD element or somesuch), you'll want to put those images in "graphics" instead, otherwise it may cause some troubles down the line.
User avatar
PaganRaven
Posts: 439
Joined: Fri Oct 14, 2005 2:21 pm

Re: "How do I ZScript?"

Post by PaganRaven »

I'm trying to get the player to have a constant Y offset of 1 by using floorclip, but it's kinda... not working, or only halfway working (the view has a tendency to bob up when the player stops moving).

Here's the best I could do:

override void Tick()
{
super.Tick();
floorclip = 1;
}

Having it reset on every tick is the only way I could get it to almost-work, even though any other actor would only need floorclip set one time to be constant. There has to be a better way to do this.
User avatar
JPL
 
 
Posts: 523
Joined: Mon Apr 09, 2012 12:27 pm

Re: "How do I ZScript?"

Post by JPL »

What's the correct usage of BlockLinesIterator? I can't find any examples. My code that does this:

Code: Select all

PlayerPawn p = players[consoleplayer].mo;
BlockLinesIterator bli = BlockLinesIterator.Create(p, 64);
while ( bli.Next() )
{
	Console.Printf(String.Format(CurLine.v1.p.x));
}
gives this error on startup:

Code: Select all

Script error, ":zscript.txt" line 13:
Cannot convert Pointer<Class<BlockThingsIterator>> to Pointer<Class<BlockLinesIterator>>
Script error, ":zscript.txt" line 14:
Unknown identifier 'bli'

I notice that the zscript-side declaration for BlockLinesIterator in wadsrc/static/zscript/base.txt names BlockThingsIterator, is that intentional or a typo?

Code: Select all

class BlockLinesIterator : Object native
{
	native Line CurLine;
	native Vector3 position;
	native int portalflags;
	
	native static BlockThingsIterator Create(Actor origin, double checkradius = -1);
	native static BlockThingsIterator CreateFromPos(Vector3 pos, double checkh, double checkradius, Sector sec = null);
	native bool Next();
}
User avatar
DoukDouk
Posts: 39
Joined: Sat Jan 31, 2015 1:53 pm

Re: "How do I ZScript?"

Post by DoukDouk »

Using ZScript, would it be possible to apply the "BRIGHT" keyword state to an actor, similar to how you would call a function?

Edit: Doy, there's a BRIGHT flag available.
SuaveSteve
Posts: 76
Joined: Sat Jul 05, 2014 7:38 am

Re: "How do I ZScript?"

Post by SuaveSteve »

Can ZScript currently be used to replace all your ACS scripts or is it just a supped up DECORATE?

Could I execute ZScript from a linedef trigger?
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 can, through the ScriptCall ACS function, however for map scripting ACS is still the way to go. ZScript is more for gameplay mod scripting.
User avatar
A_D_M_E_R_A_L
Posts: 287
Joined: Sun Apr 16, 2017 2:55 am
Preferred Pronouns: He/Him

Re: "How do I ZScript?"

Post by A_D_M_E_R_A_L »

How do you make a writing "PERFECT!" to appear in GZDoom intermission screen when you get all kills, items and secrets, line in Zandronum?
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49096
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: "How do I ZScript?"

Post by Graf Zahl »

JPL wrote: I notice that the zscript-side declaration for BlockLinesIterator in wadsrc/static/zscript/base.txt names BlockThingsIterator, is that intentional or a typo?

Code: Select all

class BlockLinesIterator : Object native
{
	native Line CurLine;
	native Vector3 position;
	native int portalflags;
	
	native static BlockThingsIterator Create(Actor origin, double checkradius = -1);
	native static BlockThingsIterator CreateFromPos(Vector3 pos, double checkh, double checkradius, Sector sec = null);
	native bool Next();
}

Urgh! Of course that is a bug.
User avatar
JPL
 
 
Posts: 523
Joined: Mon Apr 09, 2012 12:27 pm

Re: "How do I ZScript?"

Post by JPL »

Graf Zahl wrote:
JPL wrote: I notice that the zscript-side declaration for BlockLinesIterator in wadsrc/static/zscript/base.txt names BlockThingsIterator, is that intentional or a typo?

Code: Select all

class BlockLinesIterator : Object native
{
	native Line CurLine;
	native Vector3 position;
	native int portalflags;
	
	native static BlockThingsIterator Create(Actor origin, double checkradius = -1);
	native static BlockThingsIterator CreateFromPos(Vector3 pos, double checkh, double checkradius, Sector sec = null);
	native bool Next();
}

Urgh! Of course that is a bug.
Changing those two references to BlockLinesIterator (and recompiling gzdoom.pk3 of course) gets me further, to this error which I'm not as sure how to fix:

Code: Select all

Script error, ":zscript.txt" line 18:
Unknown identifier 'CurLine'
User avatar
Nash
 
 
Posts: 17450
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia

Re: "How do I ZScript?"

Post by Nash »

JPL wrote:
Graf Zahl wrote:
JPL wrote: I notice that the zscript-side declaration for BlockLinesIterator in wadsrc/static/zscript/base.txt names BlockThingsIterator, is that intentional or a typo?

Code: Select all

class BlockLinesIterator : Object native
{
	native Line CurLine;
	native Vector3 position;
	native int portalflags;
	
	native static BlockThingsIterator Create(Actor origin, double checkradius = -1);
	native static BlockThingsIterator CreateFromPos(Vector3 pos, double checkh, double checkradius, Sector sec = null);
	native bool Next();
}

Urgh! Of course that is a bug.
Changing those two references to BlockLinesIterator (and recompiling gzdoom.pk3 of course) gets me further, to this error which I'm not as sure how to fix:

Code: Select all

Script error, ":zscript.txt" line 18:
Unknown identifier 'CurLine'
I think it's best you open a bug report so that it can be fixed upstream...
User avatar
JPL
 
 
Posts: 523
Joined: Mon Apr 09, 2012 12:27 pm

Re: "How do I ZScript?"

Post by JPL »

Nash wrote: I think it's best you open a bug report so that it can be fixed upstream...
Done.
User avatar
ramon.dexter
Posts: 1543
Joined: Tue Oct 20, 2015 12:50 pm
Graphics Processor: nVidia with Vulkan support
Location: Kozolupy, Bohemia

Re: "How do I ZScript?"

Post by ramon.dexter »

Gutawer wrote:You can, through the ScriptCall ACS function, however for map scripting ACS is still the way to go. ZScript is more for gameplay mod scripting.
Yes. thank you! That should be in the first place on the wiki.
User avatar
Major Cooke
Posts: 8182
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 »

Huh. Interesting... I didn't know you could access the default properties...

Code: Select all

Speed = Default.Speed;
That's a neat trick!

Return to “Scripting”