View Full Version : Bind script to hotkey or keyword?
tjucken
02-12-2016, 01:58 PM
Hey! I've got this script and I would like to preferably bind it to a hotkey but could settle for a keyword if its not possible.
DarkstaR kamilqq
What should I add to this script in order to bind it?
For example if i use F1 this script will run once.
local spells = {"Utori Bomb Vis", "Utori Bomb Flam", "Exevo Vort Lux", "Exori Pyro"}
local runeid = 3154
local dist = 7
while (true) do
local creature = Creature.GetByID(Self.TargetID())
local i = 1
while (creature:isValid() and creature:isAlive() and (creature:DistanceFromSelf() <= dist) and creature:isTarget()) do
Self.Cast(spells[i])
Self.UseItemWithTarget(runeid)
i = i + 1
wait(2010)
if (i > 4) then i = 1 end
end
end
kamilqq
02-12-2016, 05:09 PM
You should make just a function you want to execute and add hotkey when its pressed it will execute your function.
Im at phone so cant help you wih code.
Its like
If hotkey == f1 then
ExecuteFunction()
End
tjucken
02-12-2016, 05:13 PM
You should make just a function you want to execute and add hotkey when its pressed it will execute your function.
Im at phone so cant help you wih code.
Its like
If hotkey == f1 then
ExecuteFunction()
End
Would you mind adding whats needed to my code? im a total beginner at coding and dont really understand what im suppose to do.
If its not too time-consuming.
Best regards.
kamilqq
02-12-2016, 05:16 PM
Would you mind adding whats needed to my code? im a total beginner at coding and dont really understand what im suppose to do.
If its not too time-consuming.
Best regards.
Ill be on my computer in 2 hours. When im at computer ill write a code for you if noone will be faster. And its not even 5 minutes to do.
tjucken
02-12-2016, 06:05 PM
Ill be on my computer in 2 hours. When im at computer ill write a code for you if noone will be faster. And its not even 5 minutes to do.
Thanks alot mate, i hope i can redo some favour for you sometime!
kamilqq
02-12-2016, 06:45 PM
Thanks alot mate, i hope i can redo some favour for you sometime!
Never made hotkeys script before, so i was looking at the example at Update thread.
The main thing we care is that it works well.
That hotkeys thing looks well for manualy playin.
Enjoy your code. :P
local spells = {"Utori Bomb Vis", "Utori Bomb Flam", "Exevo Vort Lux", "Exori Pyro"}
local runeid = 3154
local dist = 7
for name, value in pairs(Hotkeys) do
if (type(value) == "number") then
if (not Hotkeys.Register(value)) then
print("Failed to register hotkey %d", value)
end
end
end
local spellsOnUse = function()
local creature = Creature.GetByID(Self.TargetID())
local i = 1
while (creature:isValid() and creature:isAlive() and (creature:DistanceFromSelf() <= dist) and creature:isTarget()) do
Self.Cast(spells[i])
Self.UseItemWithTarget(runeid)
i = i + 1
wait(2010)
if (i > 4) then i = 1 end
end
end
function pressHandler(key, control, shift)
if key == Hotkeys.F1 then
spellsOnUse()
end
end
function releaseHandler(key, control, shift)
-- not needed i think
end
Hotkeys.AddPressHandler(pressHandler)
Hotkeys.AddPressHandler(releaseHandler)
Hotkeys.AddPressHandler(function(key)
if (key == Hotkeys.DELETE) then
for i = 1, 255 do
UnRegisterHotkey(i)
end
end
end)
tjucken
02-12-2016, 08:18 PM
Never made hotkeys script before, so i was looking at the example at Update thread.
The main thing we care is that it works well.
That hotkeys thing looks well for manualy playin.
Enjoy your code. :P
local spells = {"Utori Bomb Vis", "Utori Bomb Flam", "Exevo Vort Lux", "Exori Pyro"}
local runeid = 3154
local dist = 7
for name, value in pairs(Hotkeys) do
if (type(value) == "number") then
if (not Hotkeys.Register(value)) then
print("Failed to register hotkey %d", value)
end
end
end
local spellsOnUse = function()
local creature = Creature.GetByID(Self.TargetID())
local i = 1
while (creature:isValid() and creature:isAlive() and (creature:DistanceFromSelf() <= dist) and creature:isTarget()) do
Self.Cast(spells[i])
Self.UseItemWithTarget(runeid)
i = i + 1
wait(2010)
if (i > 4) then i = 1 end
end
end
function pressHandler(key, control, shift)
if key == Hotkeys.F1 then
spellsOnUse()
end
end
function releaseHandler(key, control, shift)
-- not needed i think
end
Hotkeys.AddPressHandler(pressHandler)
Hotkeys.AddPressHandler(releaseHandler)
Hotkeys.AddPressHandler(function(key)
if (key == Hotkeys.DELETE) then
for i = 1, 255 do
UnRegisterHotkey(i)
end
end
end)
Thanks for helping me out, but i get this error:
Error: bad argument #1 to 'pairs' (table expected, got nil)
Also which hotkey is it set to and where do I change it?
kamilqq
02-12-2016, 08:21 PM
Thanks for helping me out, but i get this error:
Error: bad argument #1 to 'pairs' (table expected, got nil)
Also which hotkey is it set to and where do I change it?
I run it without any errors, maybe your xenobot/data/xxxx.lua is broken the only way ( theres placed "Hotkeys" table ).
Your hotkey is F1 its here :
if key == Hotkeys.F1 then
Really dunno about your error, im running without any problem.
tjucken
02-12-2016, 08:23 PM
I run it without any errors, maybe your xenobot/data/xxxx.lua is broken the only way ( theres placed "Hotkeys" table ).
Your hotkey is F1 its here :
if key == Hotkeys.F1 then
Really dunno about your error, im running without any problem.
Strange, do I have to have anything else running?
kamilqq
02-12-2016, 09:40 PM
Strange, do I have to have anything else running?
no, just that script. Ask DarkstaR or shadowart, Syntax why you getting this error.
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.