Results 1 to 4 of 4

Thread: Variable/Action Problem

  1. #1
    Normal User
    Join Date
    Jan 2014
    Posts
    21
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quoted
    0 Post(s)
    Reputation
    12
    Rep Power
    3

    Variable/Action Problem

    I cant figure out what the problem here is, it concerns ONLY the ammunition part.


    Lua Code:
     
    Ammunition_Usage = true
    Ammunition_Name = "Spear"
    Ammunition_Amount = 20
    Ammunition_Check = 5
    Ammunition_Price = 10


    Lua Code:
     
    local Spear_Money = positive(Ammunition_Amount - itemcount(Ammunition_Name)) * Ammunition_Price
    local Mana_Money = positive(Mana_Potion_Amount - itemcount(Mana_Potion_Name)) * Mana_Potion_Price
    local Health_Money = positive(Health_Potion_Amount - itemcount(Health_Potion_Name)) * Health_Potion_Price
    local Total_Money = Spear_Money + Mana_Money + Health_Money
     
    if ischannel("NPCs") == false then
        say('hi') wait(1200,2000)
    else
        npcsay('hi') wait(800,1200)
    end
     
    npcsay('deposit all') wait(800,1200)
    npcsay('yes') wait(800,1200)
    npcsay('balance') wait(800,1200)
     
    setsettings("Settings/Cavebot/Settings/OpenNextBP", "no")
     
    if Total_Money > 0 then
        npcsay("withdraw "..Total_Money) wait(800,1200)
        npcsay("yes") wait(800,1200)
    end
     
     
    if gold() < Total_Money then
        gotolabel('Randomizing1')
    end
     
    if ((Mana_Potion_Usage == true) and (itemcount(Mana_Potion_Name) < Mana_Potion_Amount)) or ((Health_Potion_Usage == true) and (itemcount(Health_Potion_Name) < Health_Potion_Amount)) then
        gotolabel('Randomizing2')
    else
        gotolabel('CheckPoint6')
    end


    This part fails, even if i got too many spears, it still withdraws money for it.

    Lua Code:
     
    if ((Ammunition_Usage == true) and (itemcount(Ammunition_Name) < Ammunition_Amount)) then
        gotolabel('Ammunition1')
    else
        gotolabel('CheckPoint7')
    end


    This fails too, got enough spears or more, still goes to buy

    Lua Code:
     
    if ischannel("NPCs") == false then
        say('hi') wait(1200,2000)
    else
        npcsay('hi') wait(800,1200)
    end
     
    npcsay('trade') wait(1200,2000)
    buyitemsupto(Ammunition_Name, Ammunition_Amount, itemcount(Ammunition_Name)) wait(1500,2000)
    moveitems(Ammunition_Name, "all", weapon, 100) wait(800,1200)
     
    if itemcount(Ammunition_Name) < Ammunition_Amount then
        gotolabel('Randomizing5')
    end


    And here it buys out as much spears as it possibly can...



    Any suggestions how to improve?



    @Edit

    This also fails at the spear part

    Lua Code:
     
    if ((Mana_Potion_Usage == true) and (itemcount(Mana_Potion_Name) < Mana_Potion_Check)) or ((Health_Potion_Usage == true) and (itemcount(Health_Potion_Name) < Health_Potion_Check)) or ((Ammunition_Usage == true) and (itemcount(Ammunition_Name) < Ammunition_Check)) or (cap < Capacity_Check) then
        gotolabel('WayBack1')
    else
        gotolabel('StartHunt1_1')
    end
    Last edited by Axetion; 02-04-2014 at 07:20 PM.

  2. #2
    iBot User pink_panther's Avatar
    Join Date
    May 2012
    Location
    Australia
    Posts
    4,075
    Mentioned
    49 Post(s)
    Tagged
    1 Thread(s)
    Quoted
    178 Post(s)
    Reputation
    309
    Rep Power
    10
    Lua Code:
     
    Ammunition_Usage = true
    Ammunition_Name = "Spear"
    Ammunition_Amount = 20
    Ammunition_Check = 5
    Ammunition_Price = 10


    This is just defining variables, no problem here.

    Will only do the ammunition part if you don't have variables for Mana and Health Pots.


    This is stupid:
    Lua Code:
     
    if ischannel("NPCs") == false then
        say('hi') wait(1200,2000)
    else
        npcsay('hi') wait(800,1200)
    end


    the bot will only say hi in default if the npc chat is closed anyway, this is redundant.


    This:
    Lua Code:
     
    if ((Ammunition_Usage == true) and (itemcount(Ammunition_Name) < Ammunition_Amount)) then
        gotolabel('Ammunition1')
    else
        gotolabel('CheckPoint7')
    end



    should be this:
    Lua Code:
     
    if ((Ammunition_Usage == true) and (itemcount(Ammunition_Name) < weaponamount)) then
        gotolabel('Ammunition1')
    else
        gotolabel('CheckPoint7')
    end


    Itemcount() doesnt count items in your hand, just in containers.



    Lua Code:
     
    if ischannel("NPCs") == false then
        say('hi') wait(1200,2000)
    else
        npcsay('hi') wait(800,1200)
    end
     
    npcsay('trade') wait(1200,2000)
    buyitemsupto(Ammunition_Name, Ammunition_Amount, itemcount(Ammunition_Name)) wait(1500,2000)
    moveitems(Ammunition_Name, "all", weapon, 100) wait(800,1200)
     
    if itemcount(Ammunition_Name) < Ammunition_Amount then
        gotolabel('Randomizing5')
    end


    This "works" because you dont actually have a condition check anywhere for it to be skipped. If the condition is the check above, than that's the issue. you need to use weaponamount to return your current spear ammo


    Here:
    Lua Code:
     
    if ((Mana_Potion_Usage == true) and (itemcount(Mana_Potion_Name) < Mana_Potion_Check)) or ((Health_Potion_Usage == true) and (itemcount(Health_Potion_Name) < Health_Potion_Check)) or ((Ammunition_Usage == true) and (itemcount(Ammunition_Name) < Ammunition_Check)) or (cap < Capacity_Check) then
        gotolabel('WayBack1')
    else
        gotolabel('StartHunt1_1')
    end


    again you're not using weaponamount. seems like thats you're main issue.

    Also check your debug log for errors.





    Fix that up and let me know how you go.

  3. #3
    Normal User
    Join Date
    Jan 2014
    Posts
    21
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quoted
    0 Post(s)
    Reputation
    12
    Rep Power
    3
    Thanks for the answer, the part with checking if NPC channel is open works. If its not open it says hi, otherwise npcsay hi, tested it and it worked. I'll check the rest

  4. #4
    iBot User pink_panther's Avatar
    Join Date
    May 2012
    Location
    Australia
    Posts
    4,075
    Mentioned
    49 Post(s)
    Tagged
    1 Thread(s)
    Quoted
    178 Post(s)
    Reputation
    309
    Rep Power
    10
    Quote Originally Posted by Axetion View Post
    Thanks for the answer, the part with checking if NPC channel is open works. If its not open it says hi, otherwise npcsay hi, tested it and it worked. I'll check the rest
    I know it "works", but ibot has a build in feature where it will only say "hi" in the default chat IF npc is not already open, if it is open, it just says npcsay("hi"). In other words, ibot already does what you're doing, for you.


    you dont need to do what you're doing.

    just put a location check near the npc before you speak so it doesnt spam hi to no one in the middle on nowhere, as long as you do that, you're safe.

Posting Permissions

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