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

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.

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

Postby Nash » Thu Mar 23, 2017 4: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
User avatar
Nash
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Github ID: nashmuhandes

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

Postby Graf Zahl » Thu Mar 23, 2017 5: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.
User avatar
Graf Zahl
Lead GZDoom Developer
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

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

Postby Nash » Thu Mar 23, 2017 5: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.
User avatar
Nash
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Github ID: nashmuhandes

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

Postby Nash » Thu Mar 23, 2017 7: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.
User avatar
Nash
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Github ID: nashmuhandes

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

Postby Graf Zahl » Thu Mar 23, 2017 9:21 am

Actually, Menu.SetMenu should not be blocked for Play. I think ZZYZX was a bit overzealous by blocking this stuff.
User avatar
Graf Zahl
Lead GZDoom Developer
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

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

Postby ZZYZX » Thu Mar 23, 2017 9:50 am

I didn't do it
User avatar
ZZYZX
le chat du rabbin
 
 
 
Joined: 14 Oct 2012
Location: Ukraine

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

Postby Graf Zahl » Thu Mar 23, 2017 12:13 pm

It's generally blocked by the separation, but this function needs to be 'clearscope' so that the game can open menus.
User avatar
Graf Zahl
Lead GZDoom Developer
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

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

Postby Major Cooke » Thu Mar 23, 2017 2: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.
User avatar
Major Cooke
Do unto others as you would have unto you. Judge yourself first.
 
Joined: 28 Jan 2007

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

Postby Nash » Thu Mar 23, 2017 5:57 pm

Alright, noted. Made a new ticket. Thanks!

https://mantis.zdoom.org/view.php?id=471
User avatar
Nash
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Github ID: nashmuhandes

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

Postby Nash » Wed Jul 05, 2017 7: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).
User avatar
Nash
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Github ID: nashmuhandes

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

Postby ZZYZX » Fri Jul 07, 2017 3:14 pm

But you can do that directly?
User avatar
ZZYZX
le chat du rabbin
 
 
 
Joined: 14 Oct 2012
Location: Ukraine

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

Postby Nash » Mon Jul 10, 2017 10: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 allExpand view
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.
User avatar
Nash
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Github ID: nashmuhandes

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

Postby Gutawer » Mon Jul 10, 2017 11: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.
User avatar
Gutawer
User Accounts Assistant
 
Joined: 16 Apr 2016
Discord: Gutawer#3431

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

Postby Nero » Thu Oct 26, 2017 3:19 am

Just want to check, are event handlers global or does each player get their own unique copy?
User avatar
Nero
Royal Boredom....Why can't I do this in Windows?
 
Joined: 06 Sep 2006
Location: Middle of Nowheresville Il.

Previous

Return to Scripting

Who is online

Users browsing this forum: No registered users and 1 guest