ZScript Discussion
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!)
-
- Lead GZDoom+Raze Developer
- Posts: 49146
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: ZScript Discussion
The compiler is well capable of resolving an anonymous function with just a single function in it to call the inner function directly.
-
- Posts: 8193
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Location: QZDoom Maintenance Team
Re: ZScript Discussion
What about multiple functions inside of the anonymous function?
-
- Lead GZDoom+Raze Developer
- Posts: 49146
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: ZScript Discussion
In that case a VM script function needs to be created because a state can only hold one function pointer.
-
- Posts: 469
- Joined: Sat Apr 16, 2016 6:01 am
- Preferred Pronouns: She/Her
Re: ZScript Discussion
https://streamable.com/w9dcc
Should this be doable? Seems like it should be unintended, but I don't want to make a report on mantis since I'm not sure this is actually a bug. Done with this code, for testing:
Should this be doable? Seems like it should be unintended, but I don't want to make a report on mantis since I'm not sure this is actually a bug. Done with this code, for testing:
Code: Select all
Class BreakEverythingMaybe : EventHandler {
override void UiTick() {
EventHandler.SendNetworkEvent("BreakEverything?");
}
override void NetworkProcess(ConsoleEvent e) {
if (e.Name == "BreakEverything?") {
ThinkerIterator spinnyIterator = ThinkerIterator.Create("Zombieman");
Actor(spinnyIterator.Next()).angle += 1;
}
}
}
-
-
- Posts: 1384
- Joined: Sun Oct 14, 2012 1:43 am
- Location: Ukraine
Re: ZScript Discussion
That's exactly what SendNetworkEvent is for.
-
-
- Posts: 10773
- Joined: Sun Jul 20, 2003 12:15 pm
Re: ZScript Discussion
Quick question: can we define const arrays in the namespace yet? The wiki claims so, but the example provided (and a few other permutations I tried) causes a syntax error when used outside of a function.
-
- Posts: 8193
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Location: QZDoom Maintenance Team
Re: ZScript Discussion
Meant anonymous functions, not namespace. Fixed.
Anyway, no, it's not possible right now outside of functions. That or my memory is fried.
Anyway, no, it's not possible right now outside of functions. That or my memory is fried.
-
- Lead GZDoom+Raze Developer
- Posts: 49146
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: ZScript Discussion
I have added static const arrays inside classes. Unless something broke they should work. The initial problem here was the memory organization as implemented by Randi. I had to refactor a lot of the data into static memory before I could make these arrays work without becoming a drag, that's wgy it took longer.
-
- Posts: 545
- Joined: Sat Aug 30, 2014 8:21 am
Re: ZScript Discussion
Would it be possible to extend the usable range of the AimTarget() function, or preferably, add a range option as a parameter? I'm using this function in my sniper rifle code, but its current maximum range is insufficient with distant targets.
-
- Posts: 30
- Joined: Thu May 21, 2015 5:33 am
Re: ZScript Discussion
How do you convert a String to a StateLabel? I need an array of state labels, and ZScript doesn't support arrays of StateLabels.
-
- Posts: 469
- Joined: Sat Apr 16, 2016 6:01 am
- Preferred Pronouns: She/Her
Re: ZScript Discussion
This is better suited for the "How do I ZScript?" (viewtopic.php?f=3&t=55073) thread, but to answer the question - you can use the ResolveState function, for example:
Code: Select all
ResolveState(<state string>)
-
- Posts: 30
- Joined: Thu May 21, 2015 5:33 am
Re: ZScript Discussion
Whoops, got this thread confused for that one. ResolveState doesn't work, BTW. It only accepts strings at compile time, not runtime.
-
- Posts: 8193
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Location: QZDoom Maintenance Team
Re: ZScript Discussion
Use a StateLabel instead of a String as the variable type.
Code: Select all
StateLabel next = "yourstatehere";
return ResolveState(next);
-
- Posts: 219
- Joined: Sat Dec 05, 2015 2:18 pm
Re: ZScript Discussion
I've been out of the loop for over a year and now I'm trying to read up on what this is. But I'm no programmer so I can't really understand what I can do with this. So my question is, what can I do with ZS that wasn't possible before? And with that I mean stuff that affects gameplay/visuals/engine and that is not possible with ACS or decorate.
-
-
- Posts: 26540
- Joined: Tue Jul 15, 2003 4:58 pm
- Location: Scotland
Re: ZScript Discussion
Sorry if this has been discussed already but there are 118 pages here.
I understand that on startup, ZScript is processed first, then DECORATE. What would happen if a ZScript actor made reference to a DECORATE actor in its definition (e.g. the ZScript actor spawned a DECORATE actor (say as a projectile), or had an inventory check for a DECORATE actor etc etc.)
I understand that on startup, ZScript is processed first, then DECORATE. What would happen if a ZScript actor made reference to a DECORATE actor in its definition (e.g. the ZScript actor spawned a DECORATE actor (say as a projectile), or had an inventory check for a DECORATE actor etc etc.)