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!)
-
- Posts: 1268
- Joined: Wed Jul 20, 2011 4:24 pm
Re: ZScript Discussion
Hmm I see...
for now, is there some ide for developing zscript or are you guys for now developing zscript in a notepad (not the ++) like app? (At least I didn't found in slade3 neither gzdoom builder a text editor bundled with a zscript parser)
for now, is there some ide for developing zscript or are you guys for now developing zscript in a notepad (not the ++) like app? (At least I didn't found in slade3 neither gzdoom builder a text editor bundled with a zscript parser)
-
- Posts: 7402
- Joined: Fri Oct 22, 2004 9:22 am
- Graphics Processor: nVidia with Vulkan support
- Location: MAP33
Re: ZScript Discussion
I just use the SLADE3 text editor. There's no highlighting yet, but it works for me.ibm5155 wrote:Hmm I see...
for now, is there some ide for developing zscript or are you guys for now developing zscript in a notepad (not the ++) like app? (At least I didn't found in slade3 neither gzdoom builder a text editor bundled with a zscript parser)
-
- Posts: 8193
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Location: QZDoom Maintenance Team
Re: ZScript Discussion
Indeed. Set it to ZDoom Decorate and it can have at least some. That's all I need.
-
-
- Posts: 17455
- Joined: Mon Oct 27, 2003 12:07 am
- Location: Kuala Lumpur, Malaysia
Re: ZScript Discussion
Almost yes. For example, I just did a special effects system (for things like blood, rain FX, smoke - things that require a lot of things to be spawned at once and have a lot of transparency overdraw) that each player in multiplayer can separately configure the density of, and it doesn't desync In multiplayer.ibm5155 wrote: Also, can zscript do something that you really cannot do in decorate/acs?
(The trick is to always spawn the objects, then Destroy() / bInvisible them in BeginPlay)
-
-
- Posts: 1384
- Joined: Sun Oct 14, 2012 1:43 am
- Location: Ukraine
Re: ZScript Discussion
So I made a PR for the first part of the events, so that Graf can review it before too much is done, and also so that some unrelated enhancements finally get into the master (printf-related).
Brief description in the PR: https://github.com/coelckers/gzdoom/pull/236
Next planned stage is PlayerEventHandler.
Not sure if these are ever used in ZDoom with it's multiplayer model, but for the future:
- PlayerConnected
- PlayerDisconnected
- PlayerJoined - this actually exists in ZDoom and is called ENTER script
- PlayerSpectated
Also:
- PlayerRespawned (including resurrect command!)
- PlayerDied (not sure if we need this, since again we can check if player died using a script that loops and checks health<=0)
Brief description in the PR: https://github.com/coelckers/gzdoom/pull/236
Next planned stage is PlayerEventHandler.
Not sure if these are ever used in ZDoom with it's multiplayer model, but for the future:
- PlayerConnected
- PlayerDisconnected
- PlayerJoined - this actually exists in ZDoom and is called ENTER script
- PlayerSpectated
Also:
- PlayerRespawned (including resurrect command!)
- PlayerDied (not sure if we need this, since again we can check if player died using a script that loops and checks health<=0)
-
- Lead GZDoom+Raze Developer
- Posts: 49141
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: ZScript Discussion
ZZYZX wrote: - PlayerDied (not sure if we need this, since again we can check if player died using a script that loops and checks health<=0)
Note: For such things an event will always be cheaper than polling it.
-
-
- Posts: 1384
- Joined: Sun Oct 14, 2012 1:43 am
- Location: Ukraine
Re: ZScript Discussion
In that case I probably need to add WorldThingDied/WorldThingResurrected/WorldThingDestroyed too.
-
- Posts: 317
- Joined: Mon Jul 16, 2012 2:02 am
Re: ZScript Discussion
Why the interface is made of special classes instead of like it's done nearly everywhere where you have events? You subscribe to an event, and when it fires, your callback function is called with relevant parameters. This way you preserve the context that the code handling an event runs in, while in this system you would also have to establish inter-class communication to send info from event handlers to the real recipient.
-
-
- Posts: 1384
- Joined: Sun Oct 14, 2012 1:43 am
- Location: Ukraine
Re: ZScript Discussion
This is a valid programming pattern.
Also, mixing, say, user input with actor classes is a bad coding practice as it produces highly unreadable and unmaintainable code.
Specialized object should read the user input and decide what to do. Same thing with other events that occur.
If you still think it's needed, give specific examples please.
Also:
https://www.libsdl.org/release/SDL-1.2. ... mples.html (here you pop events from the queue)
https://www.sfml-dev.org/tutorials/2.0/ ... events.php (here you pop events from the queue)
The three examples above are not suitable for ZScript because they assume you have single event processor in the whole application.
http://www.winprog.org/tutorial/window_click.html (well ok, a bit similar to "subscribing", but you can have one wndproc per window)
http://doc.qt.io/qt-4.8/eventsandfilters.html (here the global event loop calls your CLASSES with the specified VIRTUAL METHODS in them)
Where is this "everywhere" that you are talking of? C# or JS?
In Java you'd also have classes because Java got no concept of anonymous function (I think there's something similar in Java8, but it's not a real anonymous function or delegate anyway — it's an interface, CLASS, with only one method in it).
ZScript doesn't have function pointers either, so here it is — classes. It's way more natural with the existing codebase than trying to put a completely alien approach on top of it.
Also, mixing, say, user input with actor classes is a bad coding practice as it produces highly unreadable and unmaintainable code.
Specialized object should read the user input and decide what to do. Same thing with other events that occur.
If you still think it's needed, give specific examples please.
Also:
https://en.wikibooks.org/wiki/X_Window_ ... ib#Example (here you pop events from the queue)ZzZombo wrote:Why the interface is made of special classes instead of like it's done nearly everywhere where you have events?
https://www.libsdl.org/release/SDL-1.2. ... mples.html (here you pop events from the queue)
https://www.sfml-dev.org/tutorials/2.0/ ... events.php (here you pop events from the queue)
The three examples above are not suitable for ZScript because they assume you have single event processor in the whole application.
http://www.winprog.org/tutorial/window_click.html (well ok, a bit similar to "subscribing", but you can have one wndproc per window)
http://doc.qt.io/qt-4.8/eventsandfilters.html (here the global event loop calls your CLASSES with the specified VIRTUAL METHODS in them)
Where is this "everywhere" that you are talking of? C# or JS?
In Java you'd also have classes because Java got no concept of anonymous function (I think there's something similar in Java8, but it's not a real anonymous function or delegate anyway — it's an interface, CLASS, with only one method in it).
ZScript doesn't have function pointers either, so here it is — classes. It's way more natural with the existing codebase than trying to put a completely alien approach on top of it.
-
- Posts: 317
- Joined: Mon Jul 16, 2012 2:02 am
Re: ZScript Discussion
Delphi, Lua, Javascript, Perl; DotA 2, WinAPI. I could continue listing if I had more time.
-
- Lead GZDoom+Raze Developer
- Posts: 49141
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: ZScript Discussion
So what? ZScript doesn't have function pointers or multiple inheritance so the entire discussion is moot.
-
-
- Posts: 1384
- Joined: Sun Oct 14, 2012 1:43 am
- Location: Ukraine
Re: ZScript Discussion
Also, you (ZzZombo) successfully missed the last point in the PR description.
Right now, in WorldLoaded/WorldUnloaded, we only pass IsSaveGame variable.
In the future I'm going to also add kind of previous level info and IsHubTravel, so that we can tell if we travelled from another level (or it's a new game) and if we can return back to that level.
Now, if this is done via delegates/event handlers or virtual method arguments, we'll have to have virtual void WorldLoaded(bool IsSaveGame) and virtual void WorldLoaded3(bool IsSaveGame, LevelInfo prevLevelInfo, bool IsHubTravel), because if you edit the original WorldLoaded to have three arguments, all mods that were using it will break.
The same way variable types could be tweaked, and the only requirement there would be that it has to cast into the same type that older mods assume it to be (i.e. if IsSaveGame becomes an int or an enum, it's perfectly okay in this case, because if (IsSaveGame) checks will still work).
That was one of the main reasons to put it exactly this way and not something else.
Right now, in WorldLoaded/WorldUnloaded, we only pass IsSaveGame variable.
In the future I'm going to also add kind of previous level info and IsHubTravel, so that we can tell if we travelled from another level (or it's a new game) and if we can return back to that level.
Now, if this is done via delegates/event handlers or virtual method arguments, we'll have to have virtual void WorldLoaded(bool IsSaveGame) and virtual void WorldLoaded3(bool IsSaveGame, LevelInfo prevLevelInfo, bool IsHubTravel), because if you edit the original WorldLoaded to have three arguments, all mods that were using it will break.
The same way variable types could be tweaked, and the only requirement there would be that it has to cast into the same type that older mods assume it to be (i.e. if IsSaveGame becomes an int or an enum, it's perfectly okay in this case, because if (IsSaveGame) checks will still work).
That was one of the main reasons to put it exactly this way and not something else.
-
- Posts: 1268
- Joined: Wed Jul 20, 2011 4:24 pm
Re: ZScript Discussion
Wait so you made something like the zandronum's clientside acs code? where you can just Spawn rain around your câmera and not around each player (so in this case it'll avoud a huge lag D:)Nash wrote:Almost yes. For example, I just did a special effects system (for things like blood, rain FX, smoke - things that require a lot of things to be spawned at once and have a lot of transparency overdraw) that each player in multiplayer can separately configure the density of, and it doesn't desync In multiplayer.ibm5155 wrote: Also, can zscript do something that you really cannot do in decorate/acs?
(The trick is to always spawn the objects, then Destroy() / bInvisible them in BeginPlay)
And does it work if you coop spy?
-
- Posts: 8193
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Location: QZDoom Maintenance Team
Re: ZScript Discussion
I too would love to hear more about this. This is one of the biggest reasons why D4D right now is single player only, because of the customizations being tailored to pretty much just one player.Nash wrote:
Almost yes. For example, I just did a special effects system (for things like blood, rain FX, smoke - things that require a lot of things to be spawned at once and have a lot of transparency overdraw) that each player in multiplayer can separately configure the density of, and it doesn't desync In multiplayer.
(The trick is to always spawn the objects, then Destroy() / bInvisible them in BeginPlay)
-
-
- Posts: 1384
- Joined: Sun Oct 14, 2012 1:43 am
- Location: Ukraine
Re: ZScript Discussion
There! There, Eruanna, are modders that do care about demo and networking compatibility!
Are you still so sure that you need to force them into not being able to affect playsim at the cost of not adding useful features?
(still on the feature query thing)
On topic: changed multiple handler types into single handler type + multiple data types, to avoid confusion and too strict specialization of handlers.
i.e. instead of WorldEventHandler you now have a regular EventHandler, but WorldLoaded takes an object called WorldEvent with all the relevant data in it.
Are you still so sure that you need to force them into not being able to affect playsim at the cost of not adding useful features?
(still on the feature query thing)
On topic: changed multiple handler types into single handler type + multiple data types, to avoid confusion and too strict specialization of handlers.
i.e. instead of WorldEventHandler you now have a regular EventHandler, but WorldLoaded takes an object called WorldEvent with all the relevant data in it.