Signup Now
Page 1 of 2 12 LastLast
Results 1 to 10 of 17

Thread: Simple Refiller

  1. #1
    Free User Riku's Avatar
    Join Date
    Nov 2014
    Posts
    365
    Reputation
    49
    Rep Power
    19

    Simple Refiller

    Simple Refiller

    Description
    A persistent action that will go to X waypoint in X section, if you are in X section with supplies low. *
    Optional to Force Refill.

    * I am fully aware that the mathematical statements in this description are horribly wrong and i'm sorry, just very noob friendly.


    Configuration
    Set FORCE_REFILL to true or false to leave the spawn/place immediatly or "hunt" your way back.

    Code
    init start
    local Settings = {
    FORCE_REFILL = true, -- True/false to leave immediatly or "hunt" your way back.

    HP = "great health potion", -- Name of Health Potions
    MP = "mana potion", -- Name of Mana Potions
    MIN_HP = 10, -- Minimum amount of HEALTH POTIONS to leave.
    MIN_MP = 10, -- Minimum amount of MANA POTIONS to leave.
    MIN_CAP = 30, -- Minimum amount of CAP to leave.

    HUNT_SECTION = "Spawn", -- Hunting Section...
    LEAVE_WAYPOINT = "Back", -- Waypoint to go to when supplies are low...
    LEAVE_SECTION = "Refill", -- In section...
    TURNBACK_SECTION = "Town", -- Section to turn back all targeting settings (The one in depot is recommended).
    }

    Settings.HP_C = function() return itemcount(Settings.HP, "all") end -- Don't touch
    Settings.MP_C = function() return itemcount(Settings.MP, "all") end -- Don't touch
    init end

    -->> Do not edit anything below!
    --// Riku Scripts ~

    auto(2000)

    if (Settings.HP_C() < Settings.MIN_HP) or (Settings.MP_C() < Settings.MIN_MP) or ($cap < Settings.MIN_CAP) then
    if (not Settings.FORCE_REFILL) and ($wptsection == Settings.HUNT_SECTION) then
    gotolabel(Settings.LEAVE_WAYPOINT, Settings.LEAVE_SECTION)
    elseif (Settings.FORCE_REFILL) and ($wptsection == Settings.HUNT_SECTION) then
    foreach settingsentry e 'Targeting/Creatures' do
    local Monster = getsetting(e, 'Name')
    setsetting('Targeting/Creatures/'..Monster..'/Setting1/OnlyIfTrapped', 'yes')
    end
    gotolabel(Settings.LEAVE_WAYPOINT, Settings.LEAVE_SECTION)
    end
    end

    if ($wptsection == Settings.TURNBACK_SECTION) then
    foreach settingsentry b 'Targeting/Creatures' do
    local Monsters = getsetting(b, 'Name')
    setsetting('Targeting/Creatures/'..Monsters..'/Setting1/OnlyIfTrapped', 'no')
    end
    end

    setsetting('Targeting/Creatures/All/Setting1/OnlyIfTrapped', 'yes')
    Last edited by Riku; 03-23-2015 at 11:14 PM.

  2. #2
    Free User
    Join Date
    Mar 2015
    Posts
    10
    Reputation
    10
    Rep Power
    0
    Not working for me. It goes to refill even there are supplies left =/

  3. #3
    Helper StaR's Avatar
    Join Date
    Dec 2013
    Location
    Manchester
    Posts
    713
    Reputation
    50
    Rep Power
    22
    Maybe you should add a stamina option @Riku



  4. #4
    Moderator Leonardo's Avatar
    Join Date
    Dec 2013
    Location
    Brazil
    Posts
    758
    Reputation
    77
    Rep Power
    22
    I've fixed your code a bit. Variables that need to be constantly updated shouldn't be put at init block, to fix that I've changed HP_C and MP_C vars to functions, outside the Settings table (fixes the nil error problem), and everytime it invokes those functions it'll return the current itemcount value (fixes the problem of going everytime to refill).

  5. #5
    Free User Riku's Avatar
    Join Date
    Nov 2014
    Posts
    365
    Reputation
    49
    Rep Power
    19
    Quote Originally Posted by reddah View Post
    Not working for me. It goes to refill even there are supplies left =/
    Copy the script again and try it. After what Leonardo changed it should work with no problems.

    Quote Originally Posted by StaR View Post
    Maybe you should add a stamina option @Riku
    Maybe. Atm i'm working on my paid scripts thread (newly opened) so i'm prioritizing that and even if that wasn't the case, I can not do it at the moment and when I could, I would've probably already forgotten about adding it.

    Quote Originally Posted by Leonardo View Post
    I've fixed your code a bit. Variables that need to be constantly updated shouldn't be put at init block, to fix that I've changed HP_C and MP_C vars to functions, outside the Settings table (fixes the nil error problem), and everytime it invokes those functions it'll return the current itemcount value (fixes the problem of going everytime to refill).
    Leonardo! Can you not read??
    -->> Do not edit anything below!

    You stepped over the line!!
    On a serious note though, thank you for noticing that and I do understand that you shouldn't have something that needs to be constantly updated in the init block, I don't check here often, it was very rushed and the error went unnoticed.
    Last edited by Riku; 03-19-2015 at 09:03 PM.

  6. #6
    Free User breuz's Avatar
    Join Date
    May 2014
    Posts
    60
    Reputation
    25
    Rep Power
    20
    auto(1000)

    if ($wptsection == 'HuntingWptSection' and needresupply()) then
    gotolabel('Label','DepositWptSection')
    end


    I use this one lol so simple
    just add ur supplies in the list
    then there's an action in the deposit wpts that sets onlyiftrapped

  7. #7
    Free User Riku's Avatar
    Join Date
    Nov 2014
    Posts
    365
    Reputation
    49
    Rep Power
    19
    @breuz

    If you want to post your script for other people, don't do it on my thread please, unless it's an edited version of my code as a "pull request".
    Your version has a huge amount of disadvantages compared to mine.

    Often enough, simple doesn't mean good. Unless there is a humongous good code behind the function.

  8. #8
    Free User
    Join Date
    Mar 2015
    Posts
    10
    Reputation
    10
    Rep Power
    0
    Still getting an error:


    23:58:47 error in Cavebot script SuppliesCheck:
    ["Settings.MP_C = function() return ite..."]:SuppliesCheck:18: unexpected symbol near '='

  9. #9
    Free User Riku's Avatar
    Join Date
    Nov 2014
    Posts
    365
    Reputation
    49
    Rep Power
    19
    Quote Originally Posted by reddah View Post
    Still getting an error:


    23:58:47 error in Cavebot script SuppliesCheck:
    ["Settings.MP_C = function() return ite..."]:SuppliesCheck:18: unexpected symbol near '='
    Try recopying now. I think I fixed something Leonardo made by mistake.

  10. #10
    Free User
    Join Date
    Mar 2015
    Posts
    10
    Reputation
    10
    Rep Power
    0
    @Riku Works like charm now. Thank You very much

 

 

Posting Permissions

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