"How do I ZScript?"
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!)
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!)
-
- Posts: 317
- Joined: Mon Jul 16, 2012 2:02 am
Re: "How do I ZScript?"
Namespacing, look it up.
-
-
- Posts: 17456
- Joined: Mon Oct 27, 2003 12:07 am
- Location: Kuala Lumpur, Malaysia
Re: "How do I ZScript?"
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.
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.
-
-
- Posts: 10773
- Joined: Sun Jul 20, 2003 12:15 pm
Re: "How do I ZScript?"
^ All good info. One additional bit:
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.
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.Nash wrote:This behaviour is consistent across (almost) everything in GZDoom.
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.
-
- Posts: 439
- Joined: Fri Oct 14, 2005 2:21 pm
Re: "How do I ZScript?"
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.
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.
-
-
- Posts: 523
- Joined: Mon Apr 09, 2012 12:27 pm
Re: "How do I ZScript?"
What's the correct usage of BlockLinesIterator? I can't find any examples. My code that does this:
gives this error on startup:
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
PlayerPawn p = players[consoleplayer].mo;
BlockLinesIterator bli = BlockLinesIterator.Create(p, 64);
while ( bli.Next() )
{
Console.Printf(String.Format(CurLine.v1.p.x));
}
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();
}
-
- Posts: 39
- Joined: Sat Jan 31, 2015 1:53 pm
Re: "How do I ZScript?"
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.
Edit: Doy, there's a BRIGHT flag available.
-
- Posts: 79
- Joined: Sat Jul 05, 2014 7:38 am
Re: "How do I ZScript?"
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?
Could I execute ZScript from a linedef trigger?
-
- Posts: 469
- Joined: Sat Apr 16, 2016 6:01 am
- Preferred Pronouns: She/Her
Re: "How do I ZScript?"
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.
-
- Posts: 294
- Joined: Sun Apr 16, 2017 2:55 am
- Preferred Pronouns: He/Him
Re: "How do I ZScript?"
How do you make a writing "PERFECT!" to appear in GZDoom intermission screen when you get all kills, items and secrets, line in Zandronum?
-
- Lead GZDoom+Raze Developer
- Posts: 49143
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: "How do I ZScript?"
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.
-
-
- Posts: 523
- Joined: Mon Apr 09, 2012 12:27 pm
Re: "How do I ZScript?"
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: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.
Code: Select all
Script error, ":zscript.txt" line 18:
Unknown identifier 'CurLine'
-
-
- Posts: 17456
- Joined: Mon Oct 27, 2003 12:07 am
- Location: Kuala Lumpur, Malaysia
Re: "How do I ZScript?"
I think it's best you open a bug report so that it can be fixed upstream...JPL wrote: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: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.Code: Select all
Script error, ":zscript.txt" line 18: Unknown identifier 'CurLine'
-
-
- Posts: 523
- Joined: Mon Apr 09, 2012 12:27 pm
Re: "How do I ZScript?"
Done.Nash wrote: I think it's best you open a bug report so that it can be fixed upstream...
-
- Posts: 1558
- Joined: Tue Oct 20, 2015 12:50 pm
- Graphics Processor: nVidia with Vulkan support
- Location: Kozolupy, Bohemia
Re: "How do I ZScript?"
Yes. thank you! That should be in the first place on the wiki.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.
-
- Posts: 8193
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Location: QZDoom Maintenance Team
Re: "How do I ZScript?"
Huh. Interesting... I didn't know you could access the default properties...
That's a neat trick!
Code: Select all
Speed = Default.Speed;