[Not a bug] [4.5] GetPlayerInput in ACS is not registering

Bugs that have been investigated and resolved somehow.

Moderator: GZDoom Developers

[4.5] GetPlayerInput in ACS is not registering

Postby Zanieon » Fri Feb 19, 2021 6:02 am

So... i've made a script that needs to register that the player is pressing only the forward key to make it sprint faster after a while, but looks like GetPlayerInput stopped working in 4.5, i tried a couple things before rolling back to 4.4.2 just to make sure and it is indeed something related to the version of the source port.

Literally the examples found in the Wiki can be used to debug this as i used them as well to check if GetPlayerInput is registering any actual key, i used this script to check it out:

Code: Select allExpand view
script "ForwardkeyRegister" ENTER
{
    int Buttons;

    While (TRUE)
    {
        Buttons = GetPlayerInput(-1, INPUT_OLDBUTTONS);

        if (Buttons == BT_FORWARD)
        {
            print(s:"You are only pressing the forward key, and no others.");
        }
        Delay(1);
    }
}
User avatar
Zanieon
A Tamer of The Dark
 
Joined: 13 Jan 2009
Location: Somewhere in the future
Discord: Zanieon#3177
Twitch ID: Zanieon
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: ATI/AMD with Vulkan Support

Re: [4.5] GetPlayerInput in ACS is not registering

Postby Graf Zahl » Fri Feb 19, 2021 7:11 am

You cannot run the test like that. The input value contains some bits that may always be set, most importantly one related to the "Run" key. You have to mask out everything unrelated to your test, or you'll get incorrect behavior. This was something that just worked by happenstance in older versions under normal conditions (but more importantly, not *ALL* conditions!) but to allow proper testing of the Run state a new bit was added recently.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: [4.5] GetPlayerInput in ACS is not registering

Postby Zanieon » Fri Feb 19, 2021 7:26 am

Yeah, i just talked with MarisaKirisame through the Discord server, if this was a longstay bug then alright.

Besides i already found a way to check if the player is only pressing the forward key by comparing only MODINPUT_FORWARDMOVE and MODINPUT_SIDEMOVE values.

In any case, this script is based on an example straight from the Wiki, if this method is now wrong, someone will have to fix that in there too to avoid teaching others the wrong thing.
User avatar
Zanieon
A Tamer of The Dark
 
Joined: 13 Jan 2009
Location: Somewhere in the future
Discord: Zanieon#3177
Twitch ID: Zanieon
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: ATI/AMD with Vulkan Support

Re: [4.5] GetPlayerInput in ACS is not registering

Postby Graf Zahl » Fri Feb 19, 2021 7:43 am

This method has always been wrong. You cannot check a single bit in a bit mask like this because the other bits' values may have no relation to what you want to check.
Just because someone put incorrect code on the Wikio does not give the method any official sanctioning.

Where can I find it?
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: [4.5] GetPlayerInput in ACS is not registering

Postby Zanieon » Fri Feb 19, 2021 7:49 am

Here: https://zdoom.org/wiki/GetPlayerInput

It's in the "Reading Buttons" section.

And yeah as i said, if it's a longstay problem i won't shout and complain, i took this as legit method before, but i already managed to find another way so it's all good.

Btw, i think the page is needing an update anyways, because the addition of BT_RUN, which is not there yet.
User avatar
Zanieon
A Tamer of The Dark
 
Joined: 13 Jan 2009
Location: Somewhere in the future
Discord: Zanieon#3177
Twitch ID: Zanieon
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: ATI/AMD with Vulkan Support

Re: [4.5] GetPlayerInput in ACS is not registering

Postby Graf Zahl » Fri Feb 19, 2021 8:07 am

Ok, I removed all bad info from that page. I have to admit I was a bit shocked when I saw that it linked to a decade-old forum thread where Randi, of all people, gave that advice which resulted in the bad examples. :?

Again: No, bit fields do not work like that!
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: [4.5] GetPlayerInput in ACS is not registering

Postby Nash » Fri Feb 19, 2021 9:52 am

There's a lot of legacy bad advice. For example, I remember waaaay back in the day, being taught that to add flag constants together, to do:

Code: Select allExpand view

int flags 
= FLAG1 + FLAG2;


instead of the proper

Code: Select allExpand view

int flags 
= FLAG1 | FLAG2;
User avatar
Nash
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Github ID: nashmuhandes

Re: [4.5] GetPlayerInput in ACS is not registering

Postby Graf Zahl » Fri Feb 19, 2021 10:02 am

That one's at least harmless as long as each value is a single flag bit.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany


Return to Closed Bugs

Who is online

Users browsing this forum: No registered users and 0 guests