Log in

View Full Version : Knight Keeps depositing?!



Beo
04-26-2013, 09:42 PM
I need a bit of help, my script is messing me up. :cool:

I have the following;


-- Mana Potions
local MinMana = 30 -- Manas to deposit on.
local MaxMana = 100 -- Amount of manas to buy.
local ManaId = 266 -- Id of Mana Potion.
local ManaPrice = 45 -- How much Mana Potions cost.

-- Health Potions
local MaxHealth = 2 -- Amount of healths to buy.
local HealthId = 268 -- Id of Health Potion.
local HealthPrice = 50 -- How much Health Potions cost.

Manas I changed to Health

Health I changed to Manas

Because the lua was written to refill manas, I want to refill healths.

There are two checkers

CheckManas

CheckManas2

Check manas is to check the correct manas before hunting

Check manas 2 is to check to leave or not

When it hits Check Manas 2 it immidiately goes to bank even if I haven't used a single pot.

Could someone help?

Using @InfernalBolt Outside OF lua script and my own .xbst file.

The Outside OF Script

--[[

THAIS UNDEADS BY BEO

ORIGINAL CODE BY INFERNAL BOLT

]]

-- Cap
local MinCap = 30 -- Cap to deposit on.

-- Mana Potions
local MinMana = 30 -- Manas to deposit on.
local MaxMana = 100 -- Amount of manas to buy.
local ManaId = 266 -- Id of Mana Potion.
local ManaPrice = 45 -- How much Mana Potions cost.

-- Health Potions
local MaxHealth = 2 -- Amount of healths to buy.
local HealthId = 268 -- Id of Health Potion.
local HealthPrice = 50 -- How much Health Potions cost.

-- BP Opener
local GoldBP = "Orange Backpack" -- Name of Gold Backpack
local LootBP = "Beach Backpack" -- Name of Loot Backpack

-- Depositer // 0 = first backpack, 1 = second and so on...
local RareDP = 1 -- BP in DP to put Non-Stackable Items Into
local StackDP = 0 -- BP in DP to put Stackable Items Into

--- DON'T CHANGE ANYTHING BELOW THIS LINE ---

print("Thais Undeads By Beo - Original Code by Infernal Bolt")
registerEventListener(WALKER_SELECTLABEL, "onWalkerSelectLabel")

function onWalkerSelectLabel(labelName)
if (labelName == "CheckManas") then
print("Current Manas: " .. Self.ItemCount(ManaId))
if (Self.Cap() > MinCap and Self.ItemCount(ManaId) > MinMana) then
gotoLabel("start")
end
elseif (labelName == "CheckManas2") then
print("Current Manas: " .. Self.ItemCount(ManaId))
if (Self.ItemCount(ManaId) < MaxMana) then
gotoLabel("goBank")
end
elseif (labelName == "depositGold") then
local withdrawManas = (MaxMana-Self.ItemCount(ManaId))*ManaPrice
local withdrawHealth = (MaxHealth-Self.ItemCount(HealthId))*HealthPrice
setWalkerEnabled(false)
Self.SayToNpc({"hi", "deposit all", "yes"}, 65)
if (withdrawManas > 0) then
Self.SayToNpc({"withdraw " .. withdrawManas, "yes"}, 65)
end
if (withdrawHealth > 0) then
Self.SayToNpc({"withdraw " .. withdrawHealth, "yes"}, 65)
end
Self.SayToNpc({"balance"}, 65)
setWalkerEnabled(true)
wait(2000)
elseif (labelName == "buyManas") then
setWalkerEnabled(false)
if (Self.ItemCount(ManaId) < MaxMana or Self.ItemCount(HealthId) < MaxHealth) then
Self.SayToNpc({"hi", "vials", "yes", "trade"}, 65)
wait(2000)
if (Self.ItemCount(ManaId) < MaxMana) then
Self.ShopBuyItemsUpTo(ManaId, MaxMana)
wait(2000)
end
if (Self.ItemCount(HealthId) < MaxHealth) then
Self.ShopBuyItemsUpTo(HealthId, MaxHealth)
wait(2000)
end
wait(200, 500)
end
setWalkerEnabled(true)
elseif (labelName == "sellHalberds") then
setWalkerEnabled(false)
Self.SayToNpc({"hi", "trade"}, 65)
wait(2000, 3700)
Self.ShopSellAllItems(3269)
wait(900, 1200)
setWalkerEnabled(true)
elseif (labelName == "Deposit") then
Self.DepositItems(
{10291, StackDP}, -- orc trophy
{11467, StackDP}, -- slingshot
{11484, StackDP} -- gold ring
)
elseif (labelName == "bpOpen") then
setWalkerEnabled(false)
Self.CloseContainers()
repeat
wait(900)
until (Self.UseItemFromEquipment("backpack") > 0)
wait (1000)
Container.GetFirst():OpenChildren(Item.GetID(GoldB P), Item.GetID(LootBP))
setWalkerEnabled(true)
end
end

My Labels [In Order]



<item text="Deposit:" tag="255"/>

<item text="bpOpen:" tag="255"/>

<item text="CheckManas:" tag="255"/>

<item text="Start:" tag="255"/>

<item text="depositGold:" tag="255"/>

<item text="buyManas:" tag="255"/>

<item text="ToHunt:" tag="255"/>

<item text="CheckManas2:" tag="255"/>

<item text="goBank:" tag="255"/>


Thanks

xitoz
04-26-2013, 10:19 PM
--[[

THAIS UNDEADS BY BEO

ORIGINAL CODE BY INFERNAL BOLT

]]

-- Cap
local MinCap = 30 -- Cap to deposit on.

-- Mana Potions
local MinMana = 30 -- Manas to deposit on.
local MaxMana = 100 -- Amount of manas to buy.
local ManaId = 266 -- Id of Mana Potion.
local ManaPrice = 45 -- How much Mana Potions cost.

-- Health Potions
local MaxHealth = 2 -- Amount of healths to buy.
local HealthId = 268 -- Id of Health Potion.
local HealthPrice = 50 -- How much Health Potions cost.

-- BP Opener
local GoldBP = "Orange Backpack" -- Name of Gold Backpack
local LootBP = "Beach Backpack" -- Name of Loot Backpack

-- Depositer // 0 = first backpack, 1 = second and so on...
local RareDP = 1 -- BP in DP to put Non-Stackable Items Into
local StackDP = 0 -- BP in DP to put Stackable Items Into

--- DON'T CHANGE ANYTHING BELOW THIS LINE ---

print("Thais Undeads By Beo - Original Code by Infernal Bolt")
registerEventListener(WALKER_SELECTLABEL, "onWalkerSelectLabel")

function onWalkerSelectLabel(labelName)
if (labelName == "CheckManas") then
print("Current Manas: " .. Self.ItemCount(ManaId))
if (Self.Cap() <= MinCap) or (Self.ItemCount(ManaID)) <= MinMana then
gotoLabel("start")
end
elseif (labelName == "CheckManas2") then
print("Current Manas: " .. Self.ItemCount(ManaId))
if (Self.ItemCount(ManaId) <= MinMana) then
gotoLabel("goBank")
end
elseif (labelName == "depositGold") then
local withdrawManas = (MaxMana-Self.ItemCount(ManaId))*ManaPrice
local withdrawHealth = (MaxHealth-Self.ItemCount(HealthId))*HealthPrice
setWalkerEnabled(false)
Self.SayToNpc({"hi", "deposit all", "yes"}, 65)
if (withdrawManas > 0) then
Self.SayToNpc({"withdraw " .. withdrawManas, "yes"}, 65)
end
if (withdrawHealth > 0) then
Self.SayToNpc({"withdraw " .. withdrawHealth, "yes"}, 65)
end
Self.SayToNpc({"balance"}, 65)
setWalkerEnabled(true)
wait(2000)
elseif (labelName == "buyManas") then
setWalkerEnabled(false)
if (Self.ItemCount(ManaId) < MaxMana or Self.ItemCount(HealthId) < MaxHealth) then
Self.SayToNpc({"hi", "vials", "yes", "trade"}, 65)
wait(2000)
if (Self.ItemCount(ManaId) < MaxMana) then
Self.ShopBuyItemsUpTo(ManaId, MaxMana)
wait(2000)
end
if (Self.ItemCount(HealthId) < MaxHealth) then
Self.ShopBuyItemsUpTo(HealthId, MaxHealth)
wait(2000)
end
wait(200, 500)
end
setWalkerEnabled(true)
elseif (labelName == "sellHalberds") then
setWalkerEnabled(false)
Self.SayToNpc({"hi", "trade"}, 65)
wait(2000, 3700)
Self.ShopSellAllItems(3269)
wait(900, 1200)
setWalkerEnabled(true)
elseif (labelName == "Deposit") then
Self.DepositItems(
{10291, StackDP}, -- orc trophy
{11467, StackDP}, -- slingshot
{11484, StackDP} -- gold ring
)
elseif (labelName == "bpOpen") then
setWalkerEnabled(false)
Self.CloseContainers()
repeat
wait(900)
until (Self.UseItemFromEquipment("backpack") > 0)
wait (1000)
Container.GetFirst():OpenChildren(Item.GetID(GoldB P), Item.GetID(LootBP))
setWalkerEnabled(true)
end
end

Beo
04-26-2013, 10:38 PM
I also tried the MinMana, and it didn't work :s I'll test again.

xitoz
04-26-2013, 10:39 PM
If it doesn't work, I'll take a better look on it

Beo
04-26-2013, 10:45 PM
Uploaded Video because it still happened even when I used your script. :s

https://www.youtube.com/watch?feature=player_detailpage&v=MHSL8zmoEj4#t=15s

Tibtrak
04-26-2013, 10:49 PM
Uploaded Video because it still happened even when I used your script. :s

https://www.youtube.com/watch?feature=player_detailpage&v=MHSL8zmoEj4#t=15s
On the video it looks like u arent executing the labels, are u sure you've loaded the lua file? Remember you have to load the lua file after you load the xbst file.

Beo
04-26-2013, 10:50 PM
On the video it looks like u arent executing the labels, are u sure you've loaded the lua file? Remember you have to load the lua file after you load the xbst file.

I know how to load lua files and I'm 100% sure it is loaded.

I can open my stream if you'd like to check?

xitoz
04-26-2013, 11:03 PM
--[[
THAIS UNDEADS BY BEO
ORIGINAL CODE BY INFERNAL BOLT
Polished by Adky
]]--



local MinCap = 20
-- Mana Potions
local MinMana = 30
local MaxMana = 130
local MPotID = 266
local MPCost = 45
-- Health Potions

-- BP Opener
local GoldBP = "Orange Backpack" -- Name of Gold Backpack
local LootBP = "Beach Backpack" -- Name of Loot Backpack
-- Depositer // 0 = first backpack, 1 = second and so on...
local RareDP = 1 -- BP in DP to put Non-Stackable Items Into
local StackDP = 0 -- BP in DP to put Stackable Items Into



registerEventListener(WALKER_SELECTLABEL, "onWalkerSelectLabel")
function onWalkerSelectLabel(labelName)
if (labelName == "CheckManas") then
if (Self.Cap() <= MinCap) or (Self.ItemCount(MPotID) <= MinMana) then
gotoLabel("start")
end
elseif (labelName == "CheckManas2") then
if (Self.Cap() <= MinCap) or (Self.ItemCount(MPotID) <= MinMana) then
gotoLabel("goBank")
end
elseif (labelName == "depositGold") then
local withdrawManas = (MPCost*(MaxMana-Self.ItemCount(MPotID)))
Walker.Stop()
Self.SayToNpc({"hi", "deposit all", "yes", "balance"}, 65)
Self.WithdrawMoney(withdrawManas)
wait(2500)
Walker.Start()
elseif (labelName == "buyManas") then
Walker.Stop()
if (Self.ItemCount(MPotID) < MaxMana) then
Self.SayToNpc({"hi", "trade"}, 65)
wait(2000)
if (Self.ItemCount(MPotID) < MaxMana) then
Self.ShopBuyItem(MPotID, (MaxMana-Self.ItemCount(MPotID)))
wait(500)
Walker.Start()
end
end
elseif (labelName == "sellHalberds") then
Walker.Stop()
Self.SayToNpc({"hi", "trade"}, 65)
wait(1000, 2000)
Self.ShopSellAllItems(3269)
wait(900, 1200)
Walker.Start()
elseif (labelName == "Deposit") then
Self.DepositItems(
{10291, StackDP}, -- orc trophy
{11467, StackDP}, -- slingshot
{11484, StackDP} -- gold ring
)
elseif (labelName == "bpOpen") then
Walker.Stop()
Self.CloseContainers()
repeat
wait(900)
until (Self.UseItemFromEquipment("backpack") > 0)
wait (1000)
Container.GetFirst():OpenChildren(Item.GetID(GoldB P), Item.GetID(LootBP))
Walker.Start()
end
end

Tibtrak
04-26-2013, 11:04 PM
You have MaxMana = 100, and in your bp you only have 99 healthpots (you changed mana to healthpots right?).

elseif (labelName == "CheckManas2") then
print("Current Manas: " .. Self.ItemCount(ManaId))
if (Self.ItemCount(ManaId) < MaxMana) then
gotoLabel("goBank")
end

This means that you will go to the label "goBank" if you have less than 100 health pots on you. And you have less than 100 health pots as u only have 99 in your bp. And MaxMana is ofc the maximum amount of healths you wanna buy, so after you've used just 1 healthpots it will return to bank, lol.

You might wanna change it to MinMana, which will be the lowest amount of healthpots before it goes to refill.

elseif (labelName == "CheckManas2") then
print("Current Manas: " .. Self.ItemCount(ManaId))
if (Self.ItemCount(ManaId) < MinMana) then
gotoLabel("goBank")
end

Edit: You do realice that your "goBank" label is the next wpt/label in the walker after "checkmanas2"? So even if you have enough healthpots it will just continue to "goBank" as that is the next wpt. What label do you want it to go to after "checkmanas2" if you have enough healthpots?

Also, why would you ever wanna use healthpots instead of manas?

xitoz
04-26-2013, 11:11 PM
You have MaxMana = 100, and in your bp you only have 99 healthpots (you changed mana to healthpots right?).

elseif (labelName == "CheckManas2") then
print("Current Manas: " .. Self.ItemCount(ManaId))
if (Self.ItemCount(ManaId) < MaxMana) then
gotoLabel("goBank")
end

This means that you will go to the label "goBank" if you have less than 100 health pots on you. And you have less than 100 health pots as u only have 99 in your bp.

You might wanna change it to

elseif (labelName == "CheckManas2") then
print("Current Manas: " .. Self.ItemCount(ManaId))
if (Self.ItemCount(ManaId) < MinMana) then
gotoLabel("goBank")
end

I tested that aldready, but I spotted the problem by watching the video.

If it passes this check:
if (Self.ItemCount(ManaId) < MaxMana) then


Then it would just jump to the next line. The next line is goBank.


--[[
THAIS UNDEADS BY BEO
ORIGINAL CODE BY INFERNAL BOLT
Polished by Adky
]]--



local MinCap = 20
-- Mana Potions
local MinMana = 30
local MaxMana = 130
local MPotID = 266
local MPCost = 45
-- Health Potions

-- BP Opener
local GoldBP = "Orange Backpack" -- Name of Gold Backpack
local LootBP = "Beach Backpack" -- Name of Loot Backpack
-- Depositer // 0 = first backpack, 1 = second and so on...
local RareDP = 1 -- BP in DP to put Non-Stackable Items Into
local StackDP = 0 -- BP in DP to put Stackable Items Into



registerEventListener(WALKER_SELECTLABEL, "onWalkerSelectLabel")
function onWalkerSelectLabel(labelName)
if (labelName == "CheckManas") then
if (Self.Cap() <= MinCap) or (Self.ItemCount(MPotID) <= MinMana) then
gotoLabel("start")

end
elseif (labelName == "CheckManas2") then
if (Self.Cap() <= MinCap) or (Self.ItemCount(MPotID) <= MinMana) then
gotoLabel("goBank")
else
gotoLabel("ToHunt")
end
elseif (labelName == "depositGold") then
local withdrawManas = (MPCost*(MaxMana-Self.ItemCount(MPotID)))
Walker.Stop()
Self.SayToNpc({"hi", "deposit all", "yes", "balance"}, 65)
Self.WithdrawMoney(withdrawManas)
wait(2500)
Walker.Start()
elseif (labelName == "buyManas") then
Walker.Stop()
if (Self.ItemCount(MPotID) < MaxMana) then
Self.SayToNpc({"hi", "trade"}, 65)
wait(2000)
if (Self.ItemCount(MPotID) < MaxMana) then
Self.ShopBuyItem(MPotID, (MaxMana-Self.ItemCount(MPotID)))
wait(500)
Walker.Start()
end
end
elseif (labelName == "sellHalberds") then
Walker.Stop()
Self.SayToNpc({"hi", "trade"}, 65)
wait(1000, 2000)
Self.ShopSellAllItems(3269)
wait(900, 1200)
Walker.Start()
elseif (labelName == "Deposit") then
Self.DepositItems(
{10291, StackDP}, -- orc trophy
{11467, StackDP}, -- slingshot
{11484, StackDP} -- gold ring
)
elseif (labelName == "bpOpen") then
Walker.Stop()
Self.CloseContainers()
repeat
wait(900)
until (Self.UseItemFromEquipment("backpack") > 0)
wait (1000)
Container.GetFirst():OpenChildren(Item.GetID(GoldB P), Item.GetID(LootBP))
Walker.Start()
end
end

Tibtrak
04-26-2013, 11:15 PM
I tested that aldready, but I spotted the problem by watching the video.

If it passes this check:
if (Self.ItemCount(ManaId) < MaxMana) then


Then it would just jump to the next line. The next line is goBank.


--[[
THAIS UNDEADS BY BEO
ORIGINAL CODE BY INFERNAL BOLT
Polished by Adky
]]--



local MinCap = 20
-- Mana Potions
local MinMana = 30
local MaxMana = 130
local MPotID = 266
local MPCost = 45
-- Health Potions

-- BP Opener
local GoldBP = "Orange Backpack" -- Name of Gold Backpack
local LootBP = "Beach Backpack" -- Name of Loot Backpack
-- Depositer // 0 = first backpack, 1 = second and so on...
local RareDP = 1 -- BP in DP to put Non-Stackable Items Into
local StackDP = 0 -- BP in DP to put Stackable Items Into



registerEventListener(WALKER_SELECTLABEL, "onWalkerSelectLabel")
function onWalkerSelectLabel(labelName)
if (labelName == "CheckManas") then
if (Self.Cap() <= MinCap) or (Self.ItemCount(MPotID) <= MinMana) then
gotoLabel("start")

end
elseif (labelName == "CheckManas2") then
if (Self.Cap() <= MinCap) or (Self.ItemCount(MPotID) <= MinMana) then
gotoLabel("goBank")
else
gotoLabel("ToHunt")
end
elseif (labelName == "depositGold") then
local withdrawManas = (MPCost*(MaxMana-Self.ItemCount(MPotID)))
Walker.Stop()
Self.SayToNpc({"hi", "deposit all", "yes", "balance"}, 65)
Self.WithdrawMoney(withdrawManas)
wait(2500)
Walker.Start()
elseif (labelName == "buyManas") then
Walker.Stop()
if (Self.ItemCount(MPotID) < MaxMana) then
Self.SayToNpc({"hi", "trade"}, 65)
wait(2000)
if (Self.ItemCount(MPotID) < MaxMana) then
Self.ShopBuyItem(MPotID, (MaxMana-Self.ItemCount(MPotID)))
wait(500)
Walker.Start()
end
end
elseif (labelName == "sellHalberds") then
Walker.Stop()
Self.SayToNpc({"hi", "trade"}, 65)
wait(1000, 2000)
Self.ShopSellAllItems(3269)
wait(900, 1200)
Walker.Start()
elseif (labelName == "Deposit") then
Self.DepositItems(
{10291, StackDP}, -- orc trophy
{11467, StackDP}, -- slingshot
{11484, StackDP} -- gold ring
)
elseif (labelName == "bpOpen") then
Walker.Stop()
Self.CloseContainers()
repeat
wait(900)
until (Self.UseItemFromEquipment("backpack") > 0)
wait (1000)
Container.GetFirst():OpenChildren(Item.GetID(GoldB P), Item.GetID(LootBP))
Walker.Start()
end
end

I know and I already edited my post saying that, lol:)
And are you sure the label "ToHunt" is reachable from where he is at "CheckManas2"? Have you seen the .xbst file/wpts?

xitoz
04-26-2013, 11:23 PM
Posted before your edit :(


edit: and yes, I've used IB's scripts before and he creates them in a weird order. Besides, check 1 went to start. and ToHunt didn't exist in the script.

Beo
04-26-2013, 11:39 PM
I tested that aldready, but I spotted the problem by watching the video.

If it passes this check:
if (Self.ItemCount(ManaId) < MaxMana) then


Then it would just jump to the next line. The next line is goBank.


--[[
THAIS UNDEADS BY BEO
ORIGINAL CODE BY INFERNAL BOLT
Polished by Adky
]]--



local MinCap = 20
-- Mana Potions
local MinMana = 30
local MaxMana = 130
local MPotID = 266
local MPCost = 45
-- Health Potions

-- BP Opener
local GoldBP = "Orange Backpack" -- Name of Gold Backpack
local LootBP = "Beach Backpack" -- Name of Loot Backpack
-- Depositer // 0 = first backpack, 1 = second and so on...
local RareDP = 1 -- BP in DP to put Non-Stackable Items Into
local StackDP = 0 -- BP in DP to put Stackable Items Into



registerEventListener(WALKER_SELECTLABEL, "onWalkerSelectLabel")
function onWalkerSelectLabel(labelName)
if (labelName == "CheckManas") then
if (Self.Cap() <= MinCap) or (Self.ItemCount(MPotID) <= MinMana) then
gotoLabel("start")

end
elseif (labelName == "CheckManas2") then
if (Self.Cap() <= MinCap) or (Self.ItemCount(MPotID) <= MinMana) then
gotoLabel("goBank")
else
gotoLabel("ToHunt")
end
elseif (labelName == "depositGold") then
local withdrawManas = (MPCost*(MaxMana-Self.ItemCount(MPotID)))
Walker.Stop()
Self.SayToNpc({"hi", "deposit all", "yes", "balance"}, 65)
Self.WithdrawMoney(withdrawManas)
wait(2500)
Walker.Start()
elseif (labelName == "buyManas") then
Walker.Stop()
if (Self.ItemCount(MPotID) < MaxMana) then
Self.SayToNpc({"hi", "trade"}, 65)
wait(2000)
if (Self.ItemCount(MPotID) < MaxMana) then
Self.ShopBuyItem(MPotID, (MaxMana-Self.ItemCount(MPotID)))
wait(500)
Walker.Start()
end
end
elseif (labelName == "sellHalberds") then
Walker.Stop()
Self.SayToNpc({"hi", "trade"}, 65)
wait(1000, 2000)
Self.ShopSellAllItems(3269)
wait(900, 1200)
Walker.Start()
elseif (labelName == "Deposit") then
Self.DepositItems(
{10291, StackDP}, -- orc trophy
{11467, StackDP}, -- slingshot
{11484, StackDP} -- gold ring
)
elseif (labelName == "bpOpen") then
Walker.Stop()
Self.CloseContainers()
repeat
wait(900)
until (Self.UseItemFromEquipment("backpack") > 0)
wait (1000)
Container.GetFirst():OpenChildren(Item.GetID(GoldB P), Item.GetID(LootBP))
Walker.Start()
end
end

Fixed, thanks! ;d