Skip to content

Instantly share code, notes, and snippets.

@Machine-Jonte
Last active April 6, 2022 19:10
Show Gist options
  • Save Machine-Jonte/25c6647e8ce54604a740e079509946eb to your computer and use it in GitHub Desktop.
Save Machine-Jonte/25c6647e8ce54604a740e079509946eb to your computer and use it in GitHub Desktop.
Bot script for game
function use_all()
bot.Use(0)
bot.Use(1)
bot.Use(2)
bot.Use(3)
end
function use(i) bot.Use(i) end
function move_up(speed) bot.Move(0,1,speed) end
function move_down(speed) bot.Move(0,-1,speed) end
function move_left(speed) bot.Move(-1,0,speed) end
function move_right(speed) bot.Move(1,0,speed) end
function rotate(angle, direction) bot.Rotate(angle,direction) end
function wait(time) bot.WaitTime(time) end
function wait_one() bot.WaitOne() end
function uprint(msg) bot.Print(msg) end
function current_rot() return bot.CurrentRot() end
function read_comp(i)
local msg = bot.ReadComp(i)
if msg ~= nil then
bot.Print(msg.hit)
end
return msg
end
function wait_shoot(time)
waited_time = 0
while waited_time < time do
read_comp(0)
use_all()
wait(100)
local text = string.format("Current Rot: %f", current_rot())
uprint(text)
waited_time = waited_time + 100
end
end
function search(start_angle)
-- Init
local angle = start_angle
-- rotate(angle, 1)
-- wait(1000)
-- Search Loop
while true do
use(0)
wait(800)
local msg = read_comp(0)
if msg == nil then
-- uprint("Failed to get message")
goto skip_to_next
end
if "component" == msg.hit or "shield" == msg.hit then
-- uprint(string.format("Detected: %s", msg.hit))
return current_rot()
end
angle = angle + 10
rotate(angle, 1)
wait(500)
if angle > 360 then
return 0
end
::skip_to_next::
end
end
-- uprint(string.format("Cooldown: %f", bot.ReadCompState(0).cooldown))
while true do
move_up(1)
wait(2000)
end
-- uprint(string.format("Msg: %s", read_comp))
local angle = 0
while true do
angle = search(angle-10)
-- uprint(string.format("Hit angle: %f", angle))
rotate(angle - 90, -1)
wait(1000)
use(1)
rotate(angle, 1)
wait(1000)
end
-- My evil killer script
-- muhahaha
-- bot.Print(bot.Timestamp())
-- bot.Print(bot.ReadCompState(0).health)
-- uprint(bot.ReadCompState(0).cooldown)
-- while true do
-- move_down(1)
-- wait_shoot(4000)
-- move_right(1)
-- rotate(-90, -0.5)
-- wait_shoot(6000)
-- -- wait(6000)
-- while true do
-- -- bot.Print(bot.ReadCompState(0).health)
-- -- bot.Print(bot.ReadCompState(0).timestamp)
-- -- bot.Print(bot.ReadComp(0).hit)
-- rotate(180, 1)
-- wait_shoot(2000)
-- rotate(90,-1)
-- wait_shoot(2000)
-- wait_shoot(2000)
-- end
-- end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment