Posted: Sun Aug 14, 2016 2:31 pm Post subject: Part of Script does Nothing
When injecting the code, the set keys E, R, T, Y do nothing not sure if they arent even working, or if the p1animstate is changing too fast.
This is the code in it's "lua" entirety:
Code:
if(t ~= nil) then -- if script is already running then
timer_setEnabled(t, false) -- stop the script
object_destroy(t)
t = nil
end
tickrate = 1 -- 50ms is every 3 frames
function main ()
hitstun_countdown = readInteger(getAddress("[ballstate]+128"))/1092
if hitstun_countdown < 0 then hitstun_countdown = 0
bunted = readInteger(getAddress("[ballstate]+144"))
if bunted == 8 then hitstun_countdown = 0
if bunted == 3 then hitstun_countdown = 20
bally = readInteger("[ballcoords]+1c")
ballx = readInteger("[ballcoords]+18")
p1animstate = readInteger("[p1state]+138")
p2animstate = readInteger("[p2state]+138")
p3animstate = readInteger("[p3state]+138")
p4animstate = readInteger("[p4state]+138")
p4y = readInteger("[p4coords]+1c")
p4x = readInteger("[p4coords]+18")
p3y = readInteger("[p3coords]+1c")
p3x = readInteger("[p3coords]+18")
p2y = readInteger("[p2coords]+1c")
p2x = readInteger("[p2coords]+18")
p1y = readInteger("[p1coords]+1c")
p1x = readInteger("[p1coords]+18")
distance = math.sqrt((ballx-p1x)*(ballx-p1x)+(bally-p1y)*(bally-p1y))
end
end
end
if hitstun_countdown > 120 then hitstun_countdown = 0
end
if isKeyPressed(VK_E) and p1animstate == 16 then
doKeyPress(VK_X)
end
if isKeyPressed(VK_R) and p2animstate == 16 then
doKeyPress(VK_X)
end
if isKeyPressed(VK_T) and p3animstate == 16 then
doKeyPress(VK_X)
end
if isKeyPressed(VK_Y) and p4animstate == 16 then
doKeyPress(VK_X)
end
end
createHotkey(function(hk)
local dx = readInteger("[ballcoords]+18")-readInteger("[p1coords]+18")
local dy = readInteger("[ballcoords]+1c")-readInteger("[p1coords]+1c")
if math.sqrt(dx*dx+dy*dy) <= 9000000 and hitstun_countdown >= 0 and hitstun_countdown <= 1 then
doKeyPress(VK_Z)
end
end, VK_D)
createHotkey(function(hk)
local dx = readInteger("[ballcoords]+18")-readInteger("[p2coords]+18")
local dy = readInteger("[ballcoords]+1c")-readInteger("[p2coords]+1c")
if math.sqrt(dx*dx+dy*dy) <= 9000000 and hitstun_countdown >= 0 and hitstun_countdown <= 1 then
doKeyPress(VK_Z)
end
end, VK_F)
createHotkey(function(hk)
local dx = readInteger("[ballcoords]+18")-readInteger("[p3coords]+18")
local dy = readInteger("[ballcoords]+1c")-readInteger("[p3coords]+1c")
if math.sqrt(dx*dx+dy*dy) <= 9000000 and hitstun_countdown >= 0 and hitstun_countdown <= 1 then
doKeyPress(VK_Z)
end
end, VK_G)
createHotkey(function(hk)
local dx = readInteger("[ballcoords]+18")-readInteger("[p4coords]+18")
local dy = readInteger("[ballcoords]+1c")-readInteger("[p4coords]+1c")
if math.sqrt(dx*dx+dy*dy) <= 9000000 and hitstun_countdown >= 0 and hitstun_countdown <= 1 then
doKeyPress(VK_Z)
end
end, VK_H)
t = createTimer(nil, false) -- create a Timer object and assign it to variable t
timer_onTimer(t, main) -- When the timer ticks, call the function main
timer_setInterval(t, tickrate) -- Sets the tickrate of the timer in milliseconds
timer_setEnabled(t, true) -- Turns the timer on -- Lua code here
Here's what your code looks like when it's properly indented.
Hopefully this makes it obvious to you where you screwed up.
Hint: You probably didn't want nested if statements.
Code:
function main ()
hitstun_countdown = readInteger(getAddress("[ballstate]+128"))/1092
if hitstun_countdown < 0 then
hitstun_countdown = 0
bunted = readInteger(getAddress("[ballstate]+144"))
if bunted == 8 then
hitstun_countdown = 0
if bunted == 3 then
hitstun_countdown = 20
bally = readInteger("[ballcoords]+1c")
ballx = readInteger("[ballcoords]+18")
p1animstate = readInteger("[p1state]+138")
p2animstate = readInteger("[p2state]+138")
p3animstate = readInteger("[p3state]+138")
p4animstate = readInteger("[p4state]+138")
p4y = readInteger("[p4coords]+1c")
p4x = readInteger("[p4coords]+18")
p3y = readInteger("[p3coords]+1c")
p3x = readInteger("[p3coords]+18")
p2y = readInteger("[p2coords]+1c")
p2x = readInteger("[p2coords]+18")
p1y = readInteger("[p1coords]+1c")
p1x = readInteger("[p1coords]+18")
distance = math.sqrt((ballx-p1x)*(ballx-p1x)+(bally-p1y)*(bally-p1y))
end
end
end
if hitstun_countdown > 120 then
hitstun_countdown = 0
end
if isKeyPressed(VK_E) and p1animstate == 16 then
doKeyPress(VK_X)
end
if isKeyPressed(VK_R) and p2animstate == 16 then
doKeyPress(VK_X)
end
if isKeyPressed(VK_T) and p3animstate == 16 then
doKeyPress(VK_X)
end
if isKeyPressed(VK_Y) and p4animstate == 16 then
doKeyPress(VK_X)
end
end
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum