"How do I ZScript?"
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!)
-
hideousdestructor
- 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?"
Is there yet a way now to log something but only for the calling player (as opposed to broadcasting it to everyone)?
-
Major Cooke
- Posts: 8221
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Operating System Version (Optional): Windows 10
- Graphics Processor: nVidia with Vulkan support
- Location: GZBoomer Town
Re: "How do I ZScript?"
I must've had the most corrosive brainfart when I posted that solution. You could just as easily do this instead:Jaxxoon R wrote:Thanks, I think it works now.
Code: Select all
Angle = master.Angle;
A_FaceTarget(80);-
Nash
-

- Posts: 17513
- Joined: Mon Oct 27, 2003 12:07 am
- Location: Kuala Lumpur, Malaysia
Re: "How do I ZScript?"
I've read some generic programming advice that over-reliance of using "auto" isn't recommended and it's always better to specify the type you want, whenever possible.
Is the same advice relevant for ZScript and "let"? Should I be worried that I'm generally just let'ting stuff everywhere without much forethought?
Is the same advice relevant for ZScript and "let"? Should I be worried that I'm generally just let'ting stuff everywhere without much forethought?
-
Blue Shadow
- Posts: 5046
- Joined: Sun Nov 14, 2010 12:59 am
Re: "How do I ZScript?"
The downside I see is that when you're reading the code, you might not immediately deduce the data type of the variable you're declaring, and you might have to look in other places to figure that out, e.g calling a function and storing what it returns into the variable - in this case you need to check the function's return type.
-
Nash
-

- Posts: 17513
- Joined: Mon Oct 27, 2003 12:07 am
- Location: Kuala Lumpur, Malaysia
Re: "How do I ZScript?"
I can imagine that being annoying when you're trying to read something you didn't make yourself. And to make things worse, no Intellisense for ZScript...
-
Ed the Bat
- Posts: 3060
- Joined: Thu May 03, 2012 1:18 pm
- Location: Maryland, US
Re: "How do I ZScript?"
Following up on my question... I seem to have the impression that the player's StartItem list is stored as DropItem...? If that's the case, maybe a way to read DropItem will get me where I want to be. I'm at square one on that one too, though...
-
Graf Zahl
- Lead GZDoom+Raze Developer

- Posts: 49252
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: "How do I ZScript?"
What precisely do you want to do? If you just want to blank out or replace specific music pieces, using SNDINFO and $musicalias might be a better option.Ed the Bat wrote:What I really wanted was a more elegant and automated way to blank out songs that I hate, so I wouldn't have to rely so much on batch files. Hearing a note before I begin playing makes me feel sloppy.
It's stored in the drop item list which is accessible. Check the boss brain code, which also repurposes it.Ed the Bat wrote: Anyhow, new question... is there a way to read the contents of a player's StartItem list?
-
Nash
-

- Posts: 17513
- Joined: Mon Oct 27, 2003 12:07 am
- Location: Kuala Lumpur, Malaysia
Re: "How do I ZScript?"
How do I make a custom variable and property behave like DropItem / StartItem? It allows you to assign many classes additively to it.
-
Ed the Bat
- Posts: 3060
- Joined: Thu May 03, 2012 1:18 pm
- Location: Maryland, US
Re: "How do I ZScript?"
That's what I've been doing for a couple of years. I was just hoping I could stop using a batch file to track which SNDINFO lumps to load for which PWADs, and have the engine itself check some conditionals and do it on-the-fly.Graf Zahl wrote:What precisely do you want to do? If you just want to blank out or replace specific music pieces, using SNDINFO and $musicalias might be a better option.
Excellent, I'll look there. Thanks for the tip!Graf Zahl wrote:It's stored in the drop item list which is accessible. Check the boss brain code, which also repurposes it.
-
Graf Zahl
- Lead GZDoom+Raze Developer

- Posts: 49252
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: "How do I ZScript?"
Use SLADE to insert the lumps into the WADs. Problem solved forever. I have been doing that for years.Ed the Bat wrote:That's what I've been doing for a couple of years. I was just hoping I could stop using a batch file to track which SNDINFO lumps to load for which PWADs, and have the engine itself check some conditionals and do it on-the-fly.Graf Zahl wrote:What precisely do you want to do? If you just want to blank out or replace specific music pieces, using SNDINFO and $musicalias might be a better option.
-
Nash
-

- Posts: 17513
- Joined: Mon Oct 27, 2003 12:07 am
- Location: Kuala Lumpur, Malaysia
Re: "How do I ZScript?"
If a Thinker (non-Actor) is made using new(), added into an array, and then later is deleted from the array using Delete()... will it be truly removed? Actually what's the safest way to remove it? myArray.Delete(index, 1) or myArray[index].Destroy()?
-
AFADoomer
- Posts: 1346
- Joined: Tue Jul 15, 2003 4:18 pm
Re: "How do I ZScript?"
Or do we need to call .Destroy() to destroy the thinker object, then call .Delete() to clear the array index?Nash wrote:If a Thinker (non-Actor) is made using new(), added into an array, and then later is deleted from the array using Delete()... will it be truly removed? Actually what's the safest way to remove it? myArray.Delete(index, 1) or myArray[index].Destroy()?
-
kodi
-

- Posts: 1361
- Joined: Mon May 06, 2013 8:02 am
Re: "How do I ZScript?"
Is it possible to make a projectile not collide with one specific actor in one of its pointers?
-
Major Cooke
- Posts: 8221
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Operating System Version (Optional): Windows 10
- Graphics Processor: nVidia with Vulkan support
- Location: GZBoomer Town
Re: "How do I ZScript?"
@Nash: If you intend on destroying the thinker, you must call Destroy first, then shrink the array using ShrinkToFit... Or just delete for that index. The arrays are merely pointers to other actors, and all thinkers are stored in internal thinker arrays so removing it from your dynamic array will not actually destroy it.
So... Call myArray[index].Destroy() first and then the Delete/ShrinkToFit function.
@kodi: Override CanCollideWith. Do a check for non-passive on the actor with the pointer, see if it's that pointer and return false. True for all other cases.
So... Call myArray[index].Destroy() first and then the Delete/ShrinkToFit function.
@kodi: Override CanCollideWith. Do a check for non-passive on the actor with the pointer, see if it's that pointer and return false. True for all other cases.
Code: Select all
override bool CanCollideWith(Actor other, bool passive)
{
if (!passive)
{
if (other == tracer)
return false;
}
return true;
}-
ZZYZX
-

- Posts: 1384
- Joined: Sun Oct 14, 2012 1:43 am
- Location: Ukraine
Re: "How do I ZScript?"
When last reference to an object is lost, thinker should be deleted, but that's unless there's a global list of thinkers somewhere, like one for Actors. Graf, help.Nash wrote:If a Thinker (non-Actor) is made using new(), added into an array, and then later is deleted from the array using Delete()... will it be truly removed? Actually what's the safest way to remove it? myArray.Delete(index, 1) or myArray[index].Destroy()?
Anyway, you can try testing this by printing something in OnDestroy of your class and thus checking if OnDestroy gets called when you remove it from the array.
Note: can be called in few seconds or even minutes (remember how EventHandlers were garbage collected only after some time and certain circumstances made it faster?)
Edit: if it's STAT_STATIC, do destroy manually.