View Full Version : Need help with my Lua script please
Jagnasty
07-14-2012, 07:26 PM
New question, when my char gets to a label, the bot ignores them and skips over them.
Those are the two scripts, if anyone could help, I'd greatly appreciate it. Thanks.
Jagnasty
07-14-2012, 07:34 PM
I wonder if it's because that "end" is spaced out...
Edit: Tried it, didn't work.
Also, it's at the end of "banker" script.
Infernal Bolt
07-14-2012, 08:06 PM
This one should work, it executed just fine ingame anyway.
----------------------------------setting----------------------------------
MinCap = 70 --How much cap to leave cave? Set to 0 if you dont want to consider cap.
-- Ammunition --
MaxAmmo = 18 -- The number of ammunition the bot will buy.
AmmoId = 7378 -- the id of the spear you will use
ammoPrice = 15 -- Price of that ammunition.
LeaveAmmo = 10 -- amount of spear you want to leave your hunt
-- Potions --
MaxMana = 40 -- The number of mana potion the bot will buy.
ManaId = 237
LeaveMana = 10 --Number of mana potion you want to leave your hunt
manaPrice = 50 --Price of the mana potion.
HealthId = 266 -- potion id
LeaveHealth = 10 --Number of health potion you want to leave your hunt
HealthPrice = 80 --Price of the health potion.
----------------------------------------------------------------------------------------
registerEventListener(WALKER_SELECTLABEL, "onWalkerSelectLabel")
function onWalkerSelectLabel(labelName)
if (labelName == "check") then
if ((Self.ItemCount(healthId) < leaveHealth)) or ((Self.ItemCount(manaId) < leaveMana)) or ((Self.ItemCount(ammoId) < leaveAmmo)) or (Self.Cap() < MinCap) then
gotoLabel("refill")
else
gotoLabel("BeginHunt")
end
elseif (labelName == "Boat") then
setWalkerEnabled(false)
delayWalker(5000)
Self.Say("hi")
sleep(math.random(700, 1400))
Self.SayToNpc("destination") ---- Add the location you want to go right there !!!
sleep(math.random(600, 1000))
Self.SayToNpc("yes")
sleep(math.random(500, 1000))
setWalkerEnabled(true)
elseif (labelName == "WithdrawCash") then
setWalkerEnabled(false)
delayWalker(5000) --Call this immediately, before evr sleeping. Walker and scripter are in different threads so if we sleep before calling this walker will proceed a few wps before this bites
Self.Say("hi")
sleep(math.random(700, 1400)) --Sleep between everything we say. saying everything very quickly can be _highly_ suspicious
Self.WithdrawMoney((manaPrice*(maxMana-Self.ItemCount(manaId))))
sleep(math.random(800, 1500))
Self.SayToNpc("yes")
sleep(math.random(800, 1500))
Self.WithdrawMoney((ammoPrice*(maxAmmo-Self.ItemCount(AmmoId))))
sleep(math.random(800, 1500))
Self.SayToNpc("yes")
setWalkerEnabled(true)
elseif (labelName == "banker") then
setWalkerEnabled(false)
delayWalker(5000)
Self.Say("hi")
sleep(math.random(700, 1400))
Self.SayToNpc("deposit all")
sleep(math.random(300, 1000))
Self.SayToNpc("yes")
sleep(math.random(300, 1000))
delayWalker(2000)
setWalkerEnabled(true)
elseif (labelName == "depot") then
Self.DepositItems({10295,1}, {10296, 1}, {7432, 1}, {10307, 1}, {7381, 1}, {10299, 1})
elseif (labelName == "BuySpears") then
setWalkerEnabled(false)
delayWalker(5000)
Self.Say("hi")
sleep(math.random(700, 1400))
Self.SayToNpc("trade")
sleep(math.random(300, 1000))
Self.ShopBuyItem(ammoId, (MaxAmmo-Self.ItemCount(ammoId)))
sleep(math.random(300, 1000))
delayWalker(2000)
setWalkerEnabled(true)
elseif (labelName == "BuyPots") then
setWalkerEnabled(false)
delayWalker(5000)
Self.Say("hi")
sleep(math.random(700, 1400))
Self.SayToNpc("trade")
sleep(math.random(300, 1000))
Self.ShopBuyItem(ManaId, (MaxMana-Self.ItemCount(ManaId)))
sleep(math.random(300, 1000))
delayWalker(2000)
setWalkerEnabled(true)
end
end
Jagnasty
07-14-2012, 08:14 PM
Thanks Bolt, I was just wondering if you could tell me what I did wrong so if the problem arises in the future, I can address the problem appropriately. Thanks XD
Infernal Bolt
07-14-2012, 08:36 PM
Thanks Bolt, I was just wondering if you could tell me what I did wrong so if the problem arises in the future, I can address the problem appropriately. Thanks XD
You are supposed to use 'elseif' and not seperate 'if'.
Self.DepositItems({10295,7342}, {10296, 7342, {7432, 7342}, {10307, 7342}, {7381, 7342}, {10299, 7342}})
7342 is supposed to be the bp number and not the id, 0 is first bp in dp, 1 is second and so on.
the } marked with red is supposed to be at the second item, you accidentally moved it.
Just look at your script and compare it with my version and you'll see ;)
Jagnasty
07-14-2012, 08:42 PM
Oic, thanks, I'm dumb :P
Jagnasty
07-14-2012, 09:19 PM
Okay, now everything is working fine except that it now skips the labels. I do have "setWalkerEnabled(false)". Do you think it's because my time is too short? sleep(math.random(700, 1400))
Jagnasty
07-14-2012, 09:20 PM
You are supposed to use 'elseif' and not seperate 'if'.
Self.DepositItems({10295,7342}, {10296, 7342, {7432, 7342}, {10307, 7342}, {7381, 7342}, {10299, 7342}})
7342 is supposed to be the bp number and not the id, 0 is first bp in dp, 1 is second and so on.
the } marked with red is supposed to be at the second item, you accidentally moved it.
Just look at your script and compare it with my version and you'll see ;)
Okay, now everything is working fine except that it now skips the labels. I do have "setWalkerEnabled(false)". Do you think it's because my time is too short? sleep(math.random(700, 1400))
Infernal Bolt
07-15-2012, 11:43 AM
Okay, now everything is working fine except that it now skips the labels. I do have "setWalkerEnabled(false)". Do you think it's because my time is too short? sleep(math.random(700, 1400))
is the label the same in the waypoints as the one in the lua file?
For example if you have refill in lua file you cant have Refill in the waypoint, that wont work.
It needs to be the same.
Jagnasty
07-15-2012, 03:54 PM
is the label the same in the waypoints as the one in the lua file?
For example if you have refill in lua file you cant have Refill in the waypoint, that wont work.
It needs to be the same.
I'll double check again, I'm sure I might have messed up somewhere simply because I'm new to this, I'll let you know. Thanks.
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.