Bully-Board
Bully Modding Section => Modding Questions/Help => Topic started by: mhdt 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.
-
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.
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.
-
it worked for any button,thank you.
-
The Jump Button will be "√" that i can't jump,i don't know why
-
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.
-
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
for ID = 0, 6 do
and the second way just need to change the code IsButtonBeingPressed(ID, 0) to
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
-
Other methods
IsButtonHeld(ButtonID,ControllerlD)--Only in AE
GetStickValue(ButtonID,ControllerID) > 0
-
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.
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