XenoBot Forums - Powered by vBulletin

User Tag List

Results 1 to 2 of 2

Thread: Library and settings

  1. #1

    Join Date
    Nov 2014
    Location
    Sundsvall, Sweden
    Posts
    174
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)

    Library and settings

    Hey, made this and thought i might share. the library isnt really big or anything special, just thought it might help someone.

    Here's the library(Name this Library.lua or the settings file wont be able to load it. Capital L!):

    Code:
    --////////////////////--
    --Library version 1.0---
    --////////////////////--
    
    -- tables and checks
    Supplies = {}
    MinSupplies = {}
    MaxSupplies = {}
    
    i = 0
    if ManaPots then 
    	Supplies[i] = Mpots
    	MinSupplies[i] = MinMpots
    	MaxSupplies[i] = MaxMpots
    	Manas = true
    	i = i + 1
    end
    if HealthPots then 
    	Supplies[i] = Hpots
    	MinSupplies[i] = MinHpots
    	MaxSupplies[i] = MaxHpots
    	Healths = true
    	i = i + 1
    end
    if TakeRunes then
    	Supplies[i] = Runes
    	MinSupplies[i] = MinRunes
    	MaxSupplies[i] = MaxRunes
    	Rune = true
    	i = i + 1
    end
    if TakeAmmo then 
    	Supplies[i] = Ammo
    	MinSupplies[i] = MinAmmo
    	MaxSupplies[i] = MaxAmmo
    	i = i + 1 
    end
    
    Backpacks = {}
    
    i = 1
    if SuppliesBP then
    	Backpacks[i] = {SuppliesBP, true}
    	i = i + 1
    end
    if AmmoBP then
    	Backpacks[i] = {AmmoBP, true}
    	i = i + 1
    end
    if StackableBP then
    	Backpacks[i] = {StackableBP, true}
    	i = i + 1
    end
    if NonStackableBP then
    	Backpacks[i] = {NonStackableBP, true}
    	i = i + 1
    end
    ------------------------
    ------//Supplies//------
    ------------------------
    
    --SupplyChecker
    function SupplyChecker()
    Refill = false
    	for i = 0, #Supplies do
    		if (Self.ItemCount(Supplies[i]) <= MinSupplies[i]) then
    			print("Running out of " .. Supplies[i] .. "s, going to refill.")
    			Refill = true
    			break
    		elseif i == #Supplies and not Refill then
    			print("Supplies looking good, continuing..")
    		end
    	end
    	if Refill then
    		return true
    	elseif not Refill then
    		return false
    	end
    end
    
    --SupplyCheckBeforeHunt
    function PreSupplyCheck()
    Refill = false
    	for i = 0, #Supplies do
    		if (Self.ItemCount(Supplies[i]) < MaxSupplies[i]-5) then
    			print("Not enough " .. Supplies[i] .. "s, going back to try refilling again")
    			Refill = true
    			break
    		elseif i == #Supplies and not Refill then
    			print("Supplies looking good, continuing..")
    		end
    	end
    	if Refill then
    		return true
    	elseif not Refill then
    		return false
    	end
    end
    
    --SupplyCosts
    function SupplyCost()
    Cost = 0
    	for i = 0, #Supplies do
    		if Self.ItemCount(Supplies[i]) < MaxSupplies[i] then
    			tmpCost = (MaxSupplies[i]-Self.ItemCount(Supplies[i]))*Item.GetCost(Item.GetID(Supplies[i]))
    			Cost = Cost + tmpCost
    		end
    	end
    	return Cost
    end
    
    --Getting Supplies
    
    --MagicShop
    function MagicShop()
    Self.SayToNpc({"hi", "trade"}, 60)
    wait(200)
    Self.ShopSellFlasks()
    wait(400, 800)
    	if Manas then
    		while Self.ItemCount(Mpots) < MaxMpots do
    			Self.ShopBuyItemsUpTo(Item.GetID(Mpots), MaxMpots)
    			wait(400, 800)
    		end
    	end
    	if Healths then
    		while Self.ItemCount(Hpots) < MaxHpots do
    			Self.ShopBuyItemsUpTo(Item.GetID(Hpots), MaxHpots)
    			wait(400, 800)
    		end
    	end
    	if Rune then
    		while Self.ItemCount(Runes) < MaxRunes do
    			Self.ShopBuyItemsUpTo(Item.GetID(Runes), MaxRunes)
    			wait(400, 800)
    		end
    	end
    end
    
    --AmmoShop
    function AmmoShop()
    Self.SayToNpc({"hi", "trade"}, 60)
    wait(200)
    	while Self.ItemCount(Ammo) < MaxAmmo do
    		Self.ShopBuyItemsUpTo(Item.GetID(Ammo), MaxAmmo)
    		wait(400, 800)
    	end
    end
    if not ExtraMoney then
    ExtraMoney = 0
    end
    function Bank()
    Self.SayToNpc({"hi", "deposit all", "yes", "withdraw " .. SupplyCost()+ExtraMoney .. "", "yes"}, 60)
    wait(600, 800)
    end
    
    --StaminaCheck
    function StaminaCheck()
    	if Self.Stamina() <= Stamina*60 then
    		return true
    	else
    		return false
    	end
    end
    
    function WithdrawItems()
    	Self.OpenDepot()
    	wait(500,800)
    	if DepositFlasks then
    		Self.DepositItems({283, FlaskDP}, {284, FlaskDP}, {285,FlaskDP})
    	end
    	if ManaPots then
    		Self.OpenDepot()
    		wait(500)
    		Self.WithdrawItems(SupplyDP, {Mpots, SuppliesBP, MaxMpots-Self.ItemCount(Mpots)})
    	end
    	if HealthPots then
    		Self.OpenDepot()
    		wait(500)
    		Self.WithdrawItems(SupplyDP, {Hpots, SuppliesBP, MaxHpots-Self.ItemCount(Hpots)})
    	end
    	if TakeRunes then
    		Self.OpenDepot()
    		wait(500)
    		Self.WithdrawItems(SupplyDP, {Runes, SuppliesBP, MaxRunes-Self.ItemCount(Runes)})
    	end
    end
    
    --Backpack Opener
    function BACKPACK_OPENER()
        if #Container.GetAll() < #Backpacks+1 then
            setWalkerEnabled(false)
            Self.CloseContainers()
            Self.OpenMainBackpack(true):OpenChildren(unpack(Backpacks))
            setWalkerEnabled(true)
        end
    end
    And here's the settings:

    Code:
    --SupplyChecker() Returns true if any of the supplies is equal or less than the minimum of any supply is reached, if not it returns false.
    --PreSupplyCheck() Same as above, meant to be used after being at the store to see if it actually did get the supplies neeeded.
    --SupplyCost() -- returns how much it would cost to resupply + extra money
    --MagicShop() -- buys manas and/or healths and/or runes. Depending if it's enabled or not in the setting.
    --AmmoShop() -- buys ammunition for paladins.
    --StaminaCheck() -- checks stamina in hours, returns true if stamina is equal or less than specified minimum stamina.
    --WithdrawItems() -- Withdraws items from chosen depot slot and chosens supplies.
    --BACKPACK_OPENER() -- closes all bps and opens all bps specified in the setting.
    
    -- The backpacks you're not using you can delete or comment out, just save this as a template?
    
    -- backpacks
    MainBP = "mushroom backpack"
    SuppliesBP = "grey backpack"
    --AmmoBP = "jewelled backpack"
    --StackableBP = "backpack"
    --NonStackableBP = "beach backpack"
    
    -- supplies
    ManaPots = true  			-- true/false
    HealthPots = true 			-- true/false
    TakeRunes = true 			-- true/false
    TakeAmmo = false 			-- true/false
    
    WithdrawManas = true 		-- true/false
    WithdrawHealths = true 		-- true/false
    WithdrawRunes = true 		-- true/false
    WithdrawAmmo = false 		-- true/false
    
    Mpots = "Mana Potion"		-- Name of the mana potions you want to use.
    MaxMpots = 200				-- How many manas to begin the hunt with.
    MinMpots = 50				-- How many manas to leave the hunt.
    
    Hpots = "Health Potion"		-- Name of the health potions you want to use.
    MaxHpots = 50				-- How many healths to begin the hunt with.
    MinHpots = 10				-- How many healths to leave the hunt.
    
    Runes = "avalanche rune"	-- Name of the runes you want to use.
    MaxRunes = 400				-- How many runes to begin the hunt with.
    MinRunes = 50				-- How many runes to leave the hunt.
    
    Ammo = "spear"				-- Name of the ammunition you want to use.
    MaxAmmo = 15				-- How much ammo to begin the hunt with.
    MinAmmo = 5					-- How much ammo to leave the hunt.
    
    -- Misc
    Stamina = 20				-- Stamina to logout. (hours)
    ExtraMoney = 1000			-- Extra money to bring incase of travel etc
    	
    DepositFlasks = true		-- Deposit flasks? true/false
    FlaskDP = 4					-- which depot slot to deposit flasks to.
    SupplyDP = 3 				-- which depot slot to withdraw supplies from. 0 = depot 1
    
    
    --------------------------------------------------------------------------------------
    --Down here you can add or remove labels, aswell as rename them.----------------------
    --------------------------------------------------------------------------------------
    dofile("Library.lua")
    registerEventListener(WALKER_SELECTLABEL, "onLabel")
    
    function onLabel(label)
        if(label == "MagicShop") then
    		MagicShop()
    	elseif(label == "AmmoShop") then
    		AmmoShop()
    	elseif(label == "Bank") then
    		Bank()
    	elseif(label == "Check") then
    		if SupplyChecker() then
    			Walker.Goto("Leave")
    		elseif StaminaCheck() then
    			print("Getting low on stamina, going back to town.")
    			Walker.Goto("Leave")
    		end
    	elseif(label == "preCheck") then
    		if PreSupplyCheck() then
    			Walker.Goto("Refill")
    		end
    	elseif(label == "Backpacks") then
    		BACKPACK_OPENER()
    	elseif(label == "Withdraw") then
    		WithdrawItems()
    	elseif(label == "Stamina") then
    		if StaminaCheck() then
    			print("Low on stamina, logging out.")
    			os.exit()
    		end
        end
    end
    If there's any bugs, tell me about it and i'll fix it.(probably)

    if there's any any feutures you might need, post it down below and i might just add it

  2. #2
    ShadowWolf's Avatar
    Join Date
    Dec 2015
    Location
    New Zealand
    Posts
    10
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    This is really helpful!
    Thanks @yompa93
    ~ Shadow Wolf
    ~ A friend will bail you out of jail, but a true friend would be right there beside you saying: "DAMN that was fun!" ~


Posting Permissions

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