"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!)
Locked
User avatar
Nash
 
 
Posts: 17439
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: "How do I ZScript?"

Post by Nash »

Major Cooke: Okay thanks, I'll have a read and see what I can learn.
ZZYZX wrote:Ohhhhh right, I missed the error part. I guess it's a bug in GZDoom. Left should work on readonly strings, since IIRC it returns a new string.

https://github.com/coelckers/gzdoom/blo ... e.txt#L640
Same applies to CharAt, CharCodeAt...
This can be fixed by putting const at end of the declarations. Whoever is not lazy to make a PR :)

ZZYZX: I'll make a bug report, thanks.
User avatar
ZZYZX
 
 
Posts: 1384
Joined: Sun Oct 14, 2012 1:43 am
Location: Ukraine
Contact:

Re: "How do I ZScript?"

Post by ZZYZX »

MC made a PR already :)
User avatar
Major Cooke
Posts: 8176
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 merged it. Try that.
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
Contact:

Re: "How do I ZScript?"

Post by Matt »

What's the syntax for this GetReplacement thing?
User avatar
Major Cooke
Posts: 8176
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 »

Just the class name.
User avatar
Major Cooke
Posts: 8176
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 »

Is ThrowAbortException a runtime thing that aborts to console or does it prevent start-up? I just noticed it in Object. Could be useful to help guide mods for mods...
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
Contact:

Re: "How do I ZScript?"

Post by Matt »

Major Cooke wrote:Just the class name.
Like GetReplacement("Shotgun")?
User avatar
Major Cooke
Posts: 8176
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 »

Yes.
User avatar
Major Cooke
Posts: 8176
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 Zahl wrote:You'll have to do this with DTA_VitualWidth/DTA_VirtualHeight
Where at in particular should this be done? Because I found another way using SetSize directly, though I get the impression that's the very thing you want us to avoid...
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49071
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: "How do I ZScript?"

Post by Graf Zahl »

Post code, then I can tell you.
User avatar
Major Cooke
Posts: 8176
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 »

Code: Select all

SetSize(0, 1024 / 2, 768 / 2);
DrawString(mQ4SmallHudFont, FormatNumber(GetAmountOnly("D4DCash"), 1), (1024 / 2, 24 / 2), DI_TEXT_ALIGN_RIGHT, Font.CR_WHITE);
SetSize(0, 1024, 768);
Doubles the size of the string I want drawn. That gets me the result I want but now I'll have to take into account the new size if I wish to move it. Not good, and clearly a hack IMO.

In particular there may be a time where I'd want it to scale out a little more whenever it updates and shrink back into place (I have a system for detecting those updates ready, it's just the scaling part which will be painful).
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
Contact:

Re: "How do I ZScript?"

Post by Matt »

Is there a way to:

1. get the line that's right in front of an actor;
2. determine whether it's 2-sided; and
3. determine whether its front side is the one facing the actor?
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49071
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: "How do I ZScript?"

Post by Graf Zahl »

Not at the moment. The PathTraverse iterator which would allow you to get such stuff hasn't been exported yet.

2. and 3. are simple flag and position checks on the line, once you have the line you can get the data from it.
User avatar
Major Cooke
Posts: 8176
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: What do you think of my example above?
User avatar
ZZYZX
 
 
Posts: 1384
Joined: Sun Oct 14, 2012 1:43 am
Location: Ukraine
Contact:

Re: "How do I ZScript?"

Post by ZZYZX »

Vaecrius wrote:Is there a way to:

1. get the line that's right in front of an actor;
Manually using BlockLinesIterator :)
Locked

Return to “Scripting”