[ZScript] How Do EventHandlers ¯\(°_o)/¯ ?
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: 17455
- Joined: Mon Oct 27, 2003 12:07 am
- Location: Kuala Lumpur, Malaysia
Re: [ZScript] How Do EventHandlers ¯\(°_o)/¯ ?
[I will return to my previous issue later, it's not urgent and something else came up]
@ZZYZX: I made an Event suggestion: https://mantis.zdoom.org/view.php?id=466
@ZZYZX: I made an Event suggestion: https://mantis.zdoom.org/view.php?id=466
-
- Lead GZDoom+Raze Developer
- Posts: 49141
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: [ZScript] How Do EventHandlers ¯\(°_o)/¯ ?
Major Cooke wrote:I think he was trying to make a system where he could open and close the menu with the same keybind? (Correct me if I'm wrong.)
Whatever. What I find ironic is that the engine finally gets opened up, and yet the first thing Nash and you are trying to do is still working mostly against the new features and try pushing the boundaries. But as things are, right now that's really not on my agenda.
I still want to export two more subsystems (working on the statusbar/HUD right now, the last one being the map thinkers) before thinking about making it better.
-
-
- Posts: 17455
- Joined: Mon Oct 27, 2003 12:07 am
- Location: Kuala Lumpur, Malaysia
Re: [ZScript] How Do EventHandlers ¯\(°_o)/¯ ?
With all due respect, I didn't even explain what I was trying to do yet and you assumed I was purposely trying to break the engine.
If you must know, actually I wasn't even sure what I was trying to do when I made the post. I THOUGHT I had to send the open menu command through the NetworkProcess but it turns out I don't need to. What I should have done is just bind a button to "netevent OpenMenu <WhateverMenu>".
So okay fine, it was a lack of technical understanding. But the motivation was definitely NOT to break the engine and try to do things the engine was not meant to do. -_-
Hence why I said "it's not urgent". It wasn't even a big deal and I learned I wasn't even doing the correct thing in the first place.
If you must know, actually I wasn't even sure what I was trying to do when I made the post. I THOUGHT I had to send the open menu command through the NetworkProcess but it turns out I don't need to. What I should have done is just bind a button to "netevent OpenMenu <WhateverMenu>".
So okay fine, it was a lack of technical understanding. But the motivation was definitely NOT to break the engine and try to do things the engine was not meant to do. -_-
Hence why I said "it's not urgent". It wasn't even a big deal and I learned I wasn't even doing the correct thing in the first place.
-
-
- Posts: 17455
- Joined: Mon Oct 27, 2003 12:07 am
- Location: Kuala Lumpur, Malaysia
Re: [ZScript] How Do EventHandlers ¯\(°_o)/¯ ?
Okay, now I remember the other thing I wanted to try related to that menu issue.
In your own words, Graf:
Now the restriction is in place, and according to you, it has to be done through network calls.
Yet with 2.4, this does not work anymore.
So my question is relevant after all: how do I call an open menu from play classes, then? The motivation is the same as the original ticket: I need a scripted way to open a menu.
Graf Zahl wrote:Any reason you are seinding that through the network?
In your own words, Graf:
The issue was closed back then (at my request too, even) because back then before the Play/UI restrictions, it was possible to directly call Menu.SetMenu.The main problem here is that all the requested use cases require custom network protocol handling and that's unfortunately not that easy to do. Having a menu open is a one-liner function but it's an open invitation to use it wrong.
Now the restriction is in place, and according to you, it has to be done through network calls.
Yet with 2.4, this does not work anymore.
So my question is relevant after all: how do I call an open menu from play classes, then? The motivation is the same as the original ticket: I need a scripted way to open a menu.
-
- Lead GZDoom+Raze Developer
- Posts: 49141
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: [ZScript] How Do EventHandlers ¯\(°_o)/¯ ?
Actually, Menu.SetMenu should not be blocked for Play. I think ZZYZX was a bit overzealous by blocking this stuff.
-
-
- Posts: 1384
- Joined: Sun Oct 14, 2012 1:43 am
- Location: Ukraine
Re: [ZScript] How Do EventHandlers ¯\(°_o)/¯ ?
I didn't do it
-
- Lead GZDoom+Raze Developer
- Posts: 49141
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: [ZScript] How Do EventHandlers ¯\(°_o)/¯ ?
It's generally blocked by the separation, but this function needs to be 'clearscope' so that the game can open menus.
-
- Posts: 8193
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Location: QZDoom Maintenance Team
Re: [ZScript] How Do EventHandlers ¯\(°_o)/¯ ?
Not intentionally, but to me, the menu screams player purchasing shops like none other. Besides, someone would've attempted it sooner or later.Graf Zahl wrote:Whatever. What I find ironic is that the engine finally gets opened up, and yet the first thing Nash and you are trying to do is still working mostly against the new features and try pushing the boundaries.
And, I agree. Menu.SetMenu being allowed usage would be very ideal.
-
-
- Posts: 17455
- Joined: Mon Oct 27, 2003 12:07 am
- Location: Kuala Lumpur, Malaysia
-
-
- Posts: 17455
- Joined: Mon Oct 27, 2003 12:07 am
- Location: Kuala Lumpur, Malaysia
Re: [ZScript] How Do EventHandlers ¯\(°_o)/¯ ?
What is the best way to get a return value from Network events? I'm trying to do some play <-> UI stuff that requires passing information back and forth. Halp.
I need the UI class to query some world stuff and retrieve information about the world (coordinates and Actors if possible).
I need the UI class to query some world stuff and retrieve information about the world (coordinates and Actors if possible).
-
-
- Posts: 1384
- Joined: Sun Oct 14, 2012 1:43 am
- Location: Ukraine
Re: [ZScript] How Do EventHandlers ¯\(°_o)/¯ ?
But you can do that directly?
-
-
- Posts: 17455
- Joined: Mon Oct 27, 2003 12:07 am
- Location: Kuala Lumpur, Malaysia
Re: [ZScript] How Do EventHandlers ¯\(°_o)/¯ ?
Indeed... I can't remember why I couldn't get it to work before.ZZYZX wrote:But you can do that directly?
Next question, since you wrote the events stuff, I'm sure you know the answer to this.
Code: Select all
class LADCharacterMenu : GenericMenu
{
override bool OnInputEvent(InputEvent ev)
{
Console.Printf("%d", ev.KeyScan);
return Super.OnInputEvent(ev);
}
}
I want this to fire repeatedly.
-
- Posts: 469
- Joined: Sat Apr 16, 2016 6:01 am
- Preferred Pronouns: She/Her
Re: [ZScript] How Do EventHandlers ¯\(°_o)/¯ ?
OnInputEvent gets triggered for keys when they are either pressed down or released (you can use ev.type to determine which, e.g. ev.Type == InputEvent.Type_KeyDown), IIRC. If you want to track a key being currently pressed down, you can track it with a bool - set to true on key down, set to false on key up. If you want to track the entire keyboard, you may want to use something like an enum and an int, like with player.buttons (or GetPlayerInput()). You can then test for input using the & operator, just like with player.buttons.
-
- Posts: 551
- Joined: Wed Sep 06, 2006 12:36 pm
- Preferred Pronouns: She/Her
- Operating System Version (Optional): Debian 11 (bullseye), Windows 10
- Location: Middle of Nowheresville Il.
Re: [ZScript] How Do EventHandlers ¯\(°_o)/¯ ?
Just want to check, are event handlers global or does each player get their own unique copy?