News: Welcome back to Bullworth! If you haven't already, you will need to reset your password..


Author Topic: IsButtonPressed on Anniversary Edition???  (Read 2946 times)

0 Members and 2 Guests are viewing this topic.

Offline mhdt

  • Jr. Member
  • **
  • Posts: 94
    • View Profile
IsButtonPressed on Anniversary Edition???
« on: September 24, 2021, 08:22:51 AM »
IsButtonPressed on anniversary edition work like IsButtonBeingPressed,so what should i do to have the true IsButtonPressed like PC?I tried to use the brute force of "variables", but it takes 75 lines, which is a waste of time.
« Last Edit: September 24, 2021, 08:25:08 AM by mhdt »

Offline Altamurenza

  • Full Member
  • ***
  • Posts: 118
  • Gender: Male
  • I love cheat, unique, realistic, & expansion mod.
    • View Profile
Re: IsButtonPressed on Anniversary Edition???
« Reply #1 on: September 26, 2021, 03:24:13 AM »
You can use IsButtonBeingPressed and IsButtonBeingReleased to determine which button is still holding in by the user. I use those method sometimes on my script, but i am not really sure if it would work on Anniversary Edition.

Code: [Select]
local HOLD = {}

while true do
Wait(0)

-- detect button
for ID = 0, 15 do
if IsButtonBeingPressed(ID, 0) and not HOLD[ID] then
HOLD[ID] = true
end

if IsButtonBeingReleased(ID, 0) and HOLD[ID] then
HOLD[ID] = false
end
end

-- IsButtonPressed(6, 0) replacement test
if HOLD[6] then
SoundPlay2D("Erand") -- repeatedly play errand sound by holding punch button!
end
end

At least, give it a try.
« Last Edit: September 26, 2021, 03:26:44 AM by Altamurenza »

Offline mhdt

  • Jr. Member
  • **
  • Posts: 94
    • View Profile
Re: IsButtonPressed on Anniversary Edition???
« Reply #2 on: September 26, 2021, 09:36:36 AM »
it worked for any button,thank you.

Offline mhdt

  • Jr. Member
  • **
  • Posts: 94
    • View Profile
Re: IsButtonPressed on Anniversary Edition???
« Reply #3 on: September 27, 2021, 01:01:10 AM »
The Jump Button will be "√" that i can't jump,i don't know why
« Last Edit: September 27, 2021, 10:15:46 AM by mhdt »

Offline Altamurenza

  • Full Member
  • ***
  • Posts: 118
  • Gender: Male
  • I love cheat, unique, realistic, & expansion mod.
    • View Profile
Re: IsButtonPressed on Anniversary Edition???
« Reply #4 on: September 27, 2021, 09:32:19 PM »
It's a common problem, i heard it a lot. I believe there's something wrong with the virtual-button-managements on Anniversary Edition, they failed to predict object interactions and attempted to override other button instead. The reason is that symbol only shows up when it comes to picking up something or interacting with object.

However, it was only my speculation after all.

EDIT:

Can't it be fixed? I don't know, i haven't played AE for a long time.
« Last Edit: September 27, 2021, 09:35:09 PM by Altamurenza »

Offline Poters

  • Jr. Member
  • **
  • Posts: 32
  • Gender: Male
    • View Profile
Re: IsButtonPressed on Anniversary Edition???
« Reply #5 on: September 28, 2021, 03:14:32 AM »
The Jump Button will be "√" that i can't jump,i don't know why
Don't worry, there's still a way to fix it...

First of all, I would like to explain what is causing this "√" bug to occur,
so because Code "for ID = 0, 15 do"
which means capture all button ids from 0 to 15 and this is one of the cause,, from 0 to 15 this means also take button id 9. and this id 9 if paired with IsButtonBeingPressed there will be bug "√", and to solve this you can use 2 ways, namely

the first you can change the code "for ID = 0, 15 do" to

Code: [Select]
for ID = 0, 6 do
and the second way just need to change the code IsButtonBeingPressed(ID, 0) to

Code: [Select]
IsButtonPressed(ID, 0)
as I said earlier if IsButtonBeingPressed is paired with id 9, 0 then there will be Bug "√"

hope you understand and please try

Offline mhdt

  • Jr. Member
  • **
  • Posts: 94
    • View Profile
Re: IsButtonPressed on Anniversary Edition???
« Reply #6 on: May 17, 2022, 08:10:59 AM »
Other methods
IsButtonHeld(ButtonID,ControllerlD)--Only in AE
GetStickValue(ButtonID,ControllerID) > 0
« Last Edit: May 18, 2022, 09:23:36 AM by mhdt »

Offline RBS ID

  • Jr. Member
  • **
  • Posts: 67
  • Gender: Male
  • I don't know.
    • View Profile
    • This is website title.
Re: IsButtonPressed on Anniversary Edition???
« Reply #7 on: May 18, 2022, 05:49:38 AM »
Good find.

I use this to implement the button is being held down. But since you found this, maybe I'll use that function in my scripts instead of this below method.
Code: [Select]

T_BUTTON = function()
  repeat
    Wait(0)
  until SystemIsReady()
  _G.gButton = {}
  for i = 0, 15 do
    gButton[i] = {beingPressed = false, pressed = false, beingReleased = false}
  end
  while true do
    Wait(0)
    for i = 0, 15 do
      if GetStickValue(i, 0) == 1 then
        gButton[i].beingPressed = true
        Wait(1)
        gButton[i].beingPressed = false
        while GetStickValue(i, 0) == 1 do
          Wait(0)
          gButton[i].pressed = true
        end
        gButton[i].beingReleased, gButton[i].pressed = true, false
        Wait(1)
        gButton[i].beingReleased = false
    end
  end
end

gButton_Thread = CreateThread("T_BUTTON")


-- Usage & example:
if gButton[6].pressed then
  MinigameSetAnnouncement(tostring(GetTimer()) .. "\n", true)
end

« Last Edit: May 18, 2022, 06:16:24 AM by RanggaBS »