XenoBot Forums - Powered by vBulletin

User Tag List

Results 1 to 10 of 10

Thread: Bind script to hotkey or keyword?

  1. #1

    Join Date
    Jun 2014
    Posts
    33
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Question Bind script to hotkey or keyword?

    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 (creatureistanceFromSelf() <= 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
    Last edited by tjucken; 02-12-2016 at 04:59 PM.

  2. #2

    Join Date
    Jan 2014
    Posts
    183
    Mentioned
    9 Post(s)
    Tagged
    0 Thread(s)
    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

  3. #3

    Join Date
    Jun 2014
    Posts
    33
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by kamilqq View Post
    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.

  4. #4

    Join Date
    Jan 2014
    Posts
    183
    Mentioned
    9 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by tjucken View Post
    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.

  5. #5

    Join Date
    Jun 2014
    Posts
    33
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by kamilqq View Post
    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!

  6. #6

    Join Date
    Jan 2014
    Posts
    183
    Mentioned
    9 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by tjucken View Post
    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

    Code:
    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)

  7. #7

    Join Date
    Jun 2014
    Posts
    33
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by kamilqq View Post
    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

    Code:
    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?

  8. #8

    Join Date
    Jan 2014
    Posts
    183
    Mentioned
    9 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by tjucken View Post
    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.

  9. #9

    Join Date
    Jun 2014
    Posts
    33
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by kamilqq View Post
    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?

  10. #10

    Join Date
    Jan 2014
    Posts
    183
    Mentioned
    9 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by tjucken View Post
    Strange, do I have to have anything else running?
    no, just that script. Ask @DarkstaR or @shadowart, @Syntax why you getting this error.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •