Results 1 to 4 of 4

Thread: Help with REFILL Action

  1. #1
    Normal User catok's Avatar
    Join Date
    Jan 2013
    Location
    Sweden
    Posts
    94
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quoted
    0 Post(s)
    Reputation
    14
    Rep Power
    4

    Question Help with REFILL Action

    Basically what I want to use for my Refill Check is:

    Code:
    1. Check if the script should buy potions (yes/no in Setup @Actions)
    2. If the script is told to buy potions only THEN will it check if you have lower amount of MP/HP to leave than you set it to.
    AFTER this it should do this:

    Code:
    3. It will check if you should leave the cave to deposit stuff (yes/no in Setup @Actions)
    4. If the script is told to leave the cave to deposit gold/loot only THEN will it check if you have lower amount of cap to leave than you set it to.
    If none of the above wishes to refill because you have enough cap/HP/MP to make it another "cycle" then it will start from the beginning.

    Here is my example (but don't know if it's good/secure enough):

    PHP Code:
    if buyPotions == "yes" then
        
    if itemcount(MPname) < MPToLeave or itemcount(HPname) < HPToLeave
    then
        gotolabel
    ("northRefill")
    else 
        
    gotolabel("startHuntNorth")
    end
    end

    if leaveCave == "yes" then
    if cap CapToLeave then
        gotolabel
    ("northRefill")
    else 
        
    gotolabel("startHuntNorth")
    end
    end

    gotolabel
    ("northStartHunt"
    I'm an improving scripter and once I get used to all commands and everything again i'll be able to handle stuff like this on my own, but for now i'd be glad to accept any help from any experienced scripter to carry my sorry ass. Thank you =)
    Last edited by catok; 02-09-2014 at 10:33 PM.
    Hard Working Scripter



    My Free Scripts:

    Knight
    EK - Mutated Mountains 50+ (option to hunt any tower)

  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
    In setup:
    Lua Code:
     
    buyPotions = true
    leaveCave = true


    In action:
    Lua Code:
     
    if buyManaPots then 
    	if itemcount(MPname) < MPToLeave or itemcount(HPname) < HPToLeave then
    		gotolabel("northRefill")
    	else 
    		gotolabel("startHuntNorth")
    	end
    end
     
    if leaveCave then 
    	if cap < CapToLeave then
    		gotolabel("northRefill")
    	else 
    		gotolabel("startHuntNorth")
    	end
    end
     
    gotolabel("northStartHunt")

  3. #3
    Normal User catok's Avatar
    Join Date
    Jan 2013
    Location
    Sweden
    Posts
    94
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quoted
    0 Post(s)
    Reputation
    14
    Rep Power
    4
    Well that is pretty much exactly what i've typed out in my example, except that you're using "true/false" and i'm using "yes/no".

    I know you are way better than me at these things, so I don't know why i'm argueing... Just when i'm looking at what you typed it's pretty much what I got with different commands. (I'm terrible at making the scripts sorted out and look good).
    Hard Working Scripter



    My Free Scripts:

    Knight
    EK - Mutated Mountains 50+ (option to hunt any tower)

  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 catok View Post
    Well that is pretty much exactly what i've typed out in my example, except that you're using "true/false" and i'm using "yes/no".

    I know you are way better than me at these things, so I don't know why i'm argueing... Just when i'm looking at what you typed it's pretty much what I got with different commands. (I'm terrible at making the scripts sorted out and look good).
    you put "usePots = true" in setup to define it is as boolean, so it can be true or false, not case sensitive. if you put "yes" or "no" its a string, so if some caps loving noob types NO then it will not work, because "NO" is not the same as "no". So thats why you use a boolean

    Also, in a condition check:
    Lua Code:
    if usePots then
    assumes true, which is the same as typing
    Lua Code:
    if usePots == true then
    just less typing.

    Opposite is
    Lua Code:
    if not usePots then
    or
    Lua Code:
    if usePots == false then
    Either way is fine, but I usually just do the first one.


    Thats why you use booleans.

    Alternative to that, which is bad and just takes more effort is saying...

    In seutp:
    usePots = "yes"


    In action:
    Lua Code:
    if usePots:lower() == "yes" then


    here ":lower()" converts a string to lowercase... but this is a stupid way to do something for a variable that can easily just be a Boolean.



    It's fine if you want to ask questions, it's good to know. You seem like you want to know the answer, instead of just wanting someone else to do the work for you, which I respect. So if you want to clarify anything else, just ask.
    Last edited by pink_panther; 02-10-2014 at 02:45 AM.

Posting Permissions

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