Log in

View Full Version : my lua work 50% of the time :O



Petit Ours
07-04-2012, 03:10 AM
as I say in the title, my lua for my xbst script id only working when it want to do so now i dont know hat to do :/

My script is complete but there still few thing to add like a bp reseter (im not able to configure it) and make work all the other thing like depot, bank, ammo buyer, because the bot skip my label sometime:

take a look at the code if you can help and i can even make it try to you if you want to help


--SETTINGS-------------------------------------------------------------------------
MaxAmmo = 25 -- The number of ammo the bot will buy.
SpearsToLeave = 14 --How many spears to leave cave?
ManasToLeave = 40 --How many manas to leave cave?
ManaId = 237 -- Change Mana Pot ID
AmmoId = 7378 -- This is set for royalspears. You can use enchanted spears (ID:7367) But this will be waste!
MaxMana = 110 -- Bot wont go to hunt with lower than 190 manas - custom accordingly to cap!
ShovelID = 3457 -- This is for light shovel. Change to normal shovel if you prefer.
ManaPrice = 80
AmmoPrice = 15
GoldBp = "Red Backpack" -- name of your backpack for gold, use capital letters
GoldBpID = 2867 -- ID of your backpack for gold


local Goldbp = 2867 -- Id of Gold Backpack (Default is 2871 = Golden Backpack)
local Lootbp = 5949 -- Id of Loot Backpack (Default is 5949 = Beach Backpack)

-----------------------------------------------------------------------------------
--END OF SETTINGS--DONT CHANGE BELOW IF YOUR NOT 100% SURE OF WHAT YOU'RE DOING----
registerEventListener(WALKER_SELECTLABEL, "onWalkerSelectLabel")
function onWalkerSelectLabel(labelName)
if (labelName == "check") then
if (Self.ItemCount(AmmoId) < SpearsToLeave) or (Self.ItemCount(ManaId) < ManasToLeave) then
gotoLabel("refill")
else
gotoLabel("hunt")
end

elseif (labelName == "check2") then
if (Self.ItemCount(AmmoId) < SpearsToLeave) or (Self.ItemCount(ManaId) < ManasToLeave) then
gotoLabel("refill2")
end

elseif (labelName == "bank") then
local withdrawManas = (MaxMana-Self.ItemCount(ManaId))*ManaPrice
local withdrawAmmo = (MaxAmmo-Self.ItemCount(AmmoId))*AmmoPrice
local amount = (withdrawManas + withdrawAmmo)
delayWalker(9000)
Self.SayToNpc({"hi", "deposit all", "yes"}, 65)
if (amount > 0) then
Self.SayToNpc({"withdraw " .. amount, "yes", "balance"}, 65)
end

elseif (labelName == "potion") then
local manaCount = (MaxMana-Self.ItemCount(ManaId))
delayWalker(8000)
Self.SayToNpc({"hi", "vials", "yes", "trade"}, 65)
wait(2000)
while (Self.ItemCount(ManaId) < MaxMana) do
Self.ShopBuyItem(ManaId, manaCount)
wait(200, 500)
end

elseif (labelName == "spear") then
local ammoCount = (MaxAmmo-Self.ItemCount(AmmoId))
delayWalker(8000)
wait(2000)
while (Self.ItemCount(AmmoId) < MaxAmmo) do
Self.ShopBuyItem(AmmoId, ammoCount)
wait(200, 500)
end

elseif (labelName == "shovel") then
Self.UseItemWithGround(ShovelID, 33233, 32704, 7)
elseif (labelName == "holecheck") then
delayWalker(2000)
local pos = Self.Position()
if (pos.x == 33233 and pos.y == 32704 and pos.z == 8) then
gotoLabel("haja")
else
gotoLabel("shovel")
end
elseif (labelName == "teleport") then
delayWalker(5000) --time in seconds*1000 you want the walker to delay
local pos = Self.Position()
Self.DropItems((pos.x - 1) , pos.y, pos.z, 3042)
elseif (labelName == "teleportcheck") then
delayWalker(2000)
local pos = Self.Position()
if (pos.x == 33234 and pos.y == 32692 and pos.z == 13) then
gotoLabel("teleport")
else
gotoLabel("hunt")
end


elseif (labelName == "depot") then
setBotEnabled(false) -- Turn off targeting/looter/walker
Self.DepositItems({3028,0},{10283,0},{11467,0},{10 291,0},{11484,0},{9649,0},{10315,0},{10278,0},{114 66,0},{9647,0},{10310,0},{11449,0},{3027,0},{9685, 0},{10227,0},{9690,0},{5925,0},{10277,0})
Self.DepositItems({3434,1},{10244,1},{3415,1},{328 4,1},{3039,1},{3010,1},{3049,1},{5914,1},{5913,1}, {5909,1},{5880,1},{10290,1},{3271,1})
wait(1500)
setBotEnabled(true)

elseif (labelName == "scarabCoin") then
setBotEnabled(false) -- Turn off targeting/looter/walker
Self.WithdrawItems(0,{3042,10,1})
setBotEnabled(true) -- Turn on targeting/looter/walker
end

end

function closeBackpacks(...) -- CREDITS TO FORGEE
local tmpBP = Container.GetFirst()
local cascaded = {...}
while tmpBP:isOpen() do
for spot = 0, tmpBP:ItemCount() do
local item = tmpBP:GetItemData(spot)
if item.id == tmpBP:ID() then
table.insert(cascaded, tmpBP:ID())
tmpBP = tmpBP:GetNext()
end
end
tmpBP = Container.GetFirst()
if not table.contains(cascaded, tmpBP:ID()) or tmpBP:ItemCount() == 0 then -- Backpack is main or last cascaded. Closing...
Self.UseItem(tmpBP:ID())
wait(500, 900)
end
if #cascaded > 0 then -- Any cascaded backpacks?
for i = 1, #cascaded do
if tmpBP:ID() == cascaded[i] then -- Found cascaded backpack.
if tmpBP:ItemCount() > 0 then -- Backpack contains atleast one item, check for anoter bp.
for spot = 0, tmpBP:ItemCount() do
local item = tmpBP:GetItemData(spot)
if item.id == tmpBP:ID() then -- Found anoter cascade bp, opening...
tmpBP:UseItem(spot)
break
end
end
end
end
end
end
wait(500, 900)
tmpBP = Container.GetFirst() -- Get a new bp to check.
if tmpBP:ID() == 0 then -- No more open backpacks.
print("All backpacks were successfully closed.")
end
end
return true
end

function openBackpacks(...) -- openBackpacks(id1, id2, id3)
Self.UseItem(Self.Backpack().id)
wait(1900, 3700)
for _, input in ipairs(arg) do
local Bp = Container.GetFromIndex(input[2])
for spot = 0, Bp:ItemCount() do
local item = Bp:GetItemData(spot)
if(item.id == input[1]) then
Bp:UseItem(spot)
break
end
end
wait(900, 1700)
end
end