[4.5] GetPlayerInput in ACS is not registering

Forum rules
Please don't bump threads here if you have a problem - it will often be forgotten about if you do. Instead, make a new thread here.

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: [4.5] GetPlayerInput in ACS is not registering

Re: [4.5] GetPlayerInput in ACS is not registering

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

Re: [4.5] GetPlayerInput in ACS is not registering

by 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 all

int flags = FLAG1 + FLAG2;
instead of the proper

Code: Select all

int flags = FLAG1 | FLAG2;

Re: [4.5] GetPlayerInput in ACS is not registering

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

Re: [4.5] GetPlayerInput in ACS is not registering

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

Re: [4.5] GetPlayerInput in ACS is not registering

by 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?

Re: [4.5] GetPlayerInput in ACS is not registering

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

Re: [4.5] GetPlayerInput in ACS is not registering

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

[4.5] GetPlayerInput in ACS is not registering

by 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 all

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);
    }
}

Top