"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!)
-
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?"
...yeah, the positioning and sizing of sbarinfos and stuff is completely fucked right now.
-
Ed the Bat
- Posts: 3060
- Joined: Thu May 03, 2012 1:18 pm
- Location: Maryland, US
Re: "How do I ZScript?"
How can I ensure a PlayerEntered event only happens when coming in to the map, and not when loading a saved game?
-
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?"
You can use a transient flagged variable. Those aren't saved.
-
Minigunner
- Posts: 754
- Joined: Mon Dec 28, 2009 5:13 pm
Re: "How do I ZScript?"
I've been attempting to get the Actor of a friendly monster's FriendPlayer (the number of the player it follows), and using "players[friendplayer - 1].mo" (I used an int variable to replace friendplayer - 1) always returns NULL. Am I getting something wrong here?
-
Ed the Bat
- Posts: 3060
- Joined: Thu May 03, 2012 1:18 pm
- Location: Maryland, US
Re: "How do I ZScript?"
I'm... a bit lost, there. Could you show me an example, please?Major Cooke wrote:You can use a transient flagged variable. Those aren't saved.
-
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?"
Code: Select all
transient int something;-
ZZYZX
-

- Posts: 1384
- Joined: Sun Oct 14, 2012 1:43 am
- Location: Ukraine
Re: "How do I ZScript?"
It should not fire when loading a saved game, if it does, then it's a bug.Ed the Bat wrote:How can I ensure a PlayerEntered event only happens when coming in to the map, and not when loading a saved game?
-
Ed the Bat
- Posts: 3060
- Joined: Thu May 03, 2012 1:18 pm
- Location: Maryland, US
Re: "How do I ZScript?"
I'll make a bug report for it on the tracker, then.
-
Nash
-

- Posts: 17512
- Joined: Mon Oct 27, 2003 12:07 am
- Location: Kuala Lumpur, Malaysia
Re: "How do I ZScript?"
If that bug is fixed, is there another way to detect a save game is loaded? I remember you actually advertising that as a feature.ZZYZX wrote: It should not fire when loading a saved game, if it does, then it's a bug.
-
ZZYZX
-

- Posts: 1384
- Joined: Sun Oct 14, 2012 1:43 am
- Location: Ukraine
Re: "How do I ZScript?"
Transients or (in a StaticEventHandler) you can check it in WorldLoaded.
-
Nash
-

- Posts: 17512
- Joined: Mon Oct 27, 2003 12:07 am
- Location: Kuala Lumpur, Malaysia
Re: "How do I ZScript?"
Nash wrote:Screen.DrawText/Texture question:
Is it possible to position something in the same resolution as whatever the current user's resolution is, BUT have the graphic always RENDER at a fixed resolution, say 320x200? So for example, if the user is using 1920x1080, the draw canvas would have more precision for you to position the object, but the graphic that's blitted to the screen should always look blocky like as if the screen was 320x200.
Which Draw Tag should I use to achieve this?
This is not working. I set DTA_VirtualWidth/Height to Screen.GetWidth()/GetHeight() and now the graphic is ultra tiny because I'm using 1920x1200.ZZYZX wrote:Use VirtualWidth and VirtualHeight, and just calculate fractional offsets based on the real resolution. (x,y are doubles, as well as VirtualWidthF/VirtualHeightF)
Note: don't forget to DTA_KeepRatio.
I need the SCALE to look big, but with the pixel positioning of the user's display resolution.
(Should I feature request explicit scale DTA tags?)
-
Graf Zahl
- Lead GZDoom+Raze Developer

- Posts: 49252
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: "How do I ZScript?"
Of course there's a global thinker list. That is needed to actually process any thinkers.ZZYZX wrote: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()?
Any thinker, including any actor will only be destroyed if Destroy is actually being called on it - as long as the thinker chain holds a reference to it it will remain active.
-
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?"
And that's why I said to call Destroy before deleting the array index, because they can be found by iterators.
-
Graf Zahl
- Lead GZDoom+Raze Developer

- Posts: 49252
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: "How do I ZScript?"
Nash wrote: (Should I feature request explicit scale DTA tags?)
No: Use DTA_DestWidth/DTA_DestHeight.
-
ZZYZX
-

- Posts: 1384
- Joined: Sun Oct 14, 2012 1:43 am
- Location: Ukraine
Re: "How do I ZScript?"
You aren't doing it right then.Nash wrote:This is not working. I set DTA_VirtualWidth/Height to Screen.GetWidth()/GetHeight() and now the graphic is ultra tiny because I'm using 1920x1200.ZZYZX wrote:Use VirtualWidth and VirtualHeight, and just calculate fractional offsets based on the real resolution. (x,y are doubles, as well as VirtualWidthF/VirtualHeightF)
Note: don't forget to DTA_KeepRatio.
I need the SCALE to look big, but with the pixel positioning of the user's display resolution.
(Should I feature request explicit scale DTA tags?)
How to do it right:
Code: Select all
void RenderScaled(TextureID tex, double x, double y, double scaleX, double scaleY)
{
double vw = double(Screen.GetWidth())/scaleX; // let's assume scaleX is 2.0, this means virtualwidth will be divided by 2
double vh = double(Screen.GetHeight())/scaleY;
x /= scaleX; // same for x coordinate, so the coordinate is scaled as well (from pixel to virtual)
y /= scaleY;
// here use x,y for coordinates and vw/vh for virtualwidthf/virtualheightf
// coordinates are fractional so there won't be precision loss with low virtualwidth/virtualheight.
}