[ZScript] How Do EventHandlers ¯\(°_o)/¯ ?

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!)

Post a reply

Smilies
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :geek: :ugeek: :!: :?: :idea: :arrow: :| :mrgreen: :3: :wub: >:( :blergh:
View more smilies

BBCode is OFF
Smilies are ON

Topic review
   

Expand view Topic review: [ZScript] How Do EventHandlers ¯\(°_o)/¯ ?

Re: [ZScript] How Do EventHandlers ¯\(°_o)/¯ ?

by Sarah » Thu Oct 26, 2017 2:19 am

Just want to check, are event handlers global or does each player get their own unique copy?

Re: [ZScript] How Do EventHandlers ¯\(°_o)/¯ ?

by Gutawer » Mon Jul 10, 2017 10:49 am

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.

Re: [ZScript] How Do EventHandlers ¯\(°_o)/¯ ?

by Nash » Mon Jul 10, 2017 9:40 am

ZZYZX wrote:But you can do that directly?
Indeed... I can't remember why I couldn't get it to work before.

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);
    }
}
 
How is OnInputEvent supposed to even be used? It's supposed to show what key is being pressed, but it only prints ONCE when the menu is opened for the first time. Additionally, it doesn't seem like OnInputEvent is able to be fired repeatedly - it only fires once when the menu is spawned, then you can never poll any input anymore, it just does not respond.

I want this to fire repeatedly.

Re: [ZScript] How Do EventHandlers ¯\(°_o)/¯ ?

by ZZYZX » Fri Jul 07, 2017 2:14 pm

But you can do that directly?

Re: [ZScript] How Do EventHandlers ¯\(°_o)/¯ ?

by Nash » Wed Jul 05, 2017 6:49 pm

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).

Re: [ZScript] How Do EventHandlers ¯\(°_o)/¯ ?

by Nash » Thu Mar 23, 2017 4:57 pm

Alright, noted. Made a new ticket. Thanks!

https://mantis.zdoom.org/view.php?id=471

Re: [ZScript] How Do EventHandlers ¯\(°_o)/¯ ?

by Major Cooke » Thu Mar 23, 2017 1:18 pm

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.
Not intentionally, but to me, the menu screams player purchasing shops like none other. Besides, someone would've attempted it sooner or later.
And, I agree. Menu.SetMenu being allowed usage would be very ideal.

Re: [ZScript] How Do EventHandlers ¯\(°_o)/¯ ?

by Graf Zahl » Thu Mar 23, 2017 11:13 am

It's generally blocked by the separation, but this function needs to be 'clearscope' so that the game can open menus.

Re: [ZScript] How Do EventHandlers ¯\(°_o)/¯ ?

by ZZYZX » Thu Mar 23, 2017 8:50 am

I didn't do it

Re: [ZScript] How Do EventHandlers ¯\(°_o)/¯ ?

by Graf Zahl » Thu Mar 23, 2017 8:21 am

Actually, Menu.SetMenu should not be blocked for Play. I think ZZYZX was a bit overzealous by blocking this stuff.

Re: [ZScript] How Do EventHandlers ¯\(°_o)/¯ ?

by Nash » Thu Mar 23, 2017 6:34 am

Okay, now I remember the other thing I wanted to try related to that menu issue.
Graf Zahl wrote:Any reason you are seinding that through the network?

In your own words, Graf:
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.
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.

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.

Re: [ZScript] How Do EventHandlers ¯\(°_o)/¯ ?

by Nash » Thu Mar 23, 2017 4:40 am

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.

Re: [ZScript] How Do EventHandlers ¯\(°_o)/¯ ?

by Graf Zahl » Thu Mar 23, 2017 4:18 am

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.

Re: [ZScript] How Do EventHandlers ¯\(°_o)/¯ ?

by Nash » Thu Mar 23, 2017 3:47 am

[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

Re: [ZScript] How Do EventHandlers ¯\(°_o)/¯ ?

by Major Cooke » Wed Mar 22, 2017 6:19 pm

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.)

Top