Log in

View Full Version : Problem with script



Bastiat
09-30-2012, 05:53 AM
I'm having trouble getting my script to work reliably.. I tried several times but it seems to work only randomly.. Sometimes it works, usually it doesn't, sometimes it buys only 1 royal spear instead of the proper amount. It's giving a headache help please!!


local idlmanas = 70-(Self.ItemCount(268))
local idlspears = 20-(Self.ItemCount(7378))
local GTW = (idlmanas*50)+(idlspears*15)

--== LABEL MANAGER ==--

registerEventListener(WALKER_SELECTLABEL, "onWalkerSelectLabel")
function onWalkerSelectLabel(labelName)
local func = loadstring(labelName)
if(func)then func()
end
end

--== SHOPPERS ==--

function buyPots()
delayWalker(math.random(10000, 15000))
Self.SayToNpc({"hi", "vials", "no", "yes", "trade"}, 65)
wait(1000, 5000)
Self.ShopBuyItem(268, idlmanas)
end

function buySpears()
delayWalker(math.random(10000, 15000))
Self.SayToNpc({"hi", "trade"}, 65)
wait(1000, 5000)
Self.ShopBuyItem(7378, idlspears)
end

--== DEPOSITERS ==--

function DepositGold()
delayWalker(math.random(10000, 15000))
Self.SayToNpc({"hi", "deposit all", "yes", "withdraw " .. GTW, "yes", "balance"}, 65)
end

function DepositItems()
delayWalker(math.random(15000, 20000))
Self.DepositItems(
3369, -- warrior helmet
7438, -- elvish bow
3073, -- wand of cosmic energy
5922, -- holy orchid
5880, -- iron ore
5896, -- bear paw
3037, -- yellow gem
7398, -- cyclops trophy
7401, -- minotaur trophy
7425, -- taurus mace
5921, -- heaven blossom
3351, -- steel helmet
3384, -- dark helmet
2991, -- doll
3033, -- small amethyst
5897, -- wolf paw
5902, -- honeycomb
3307, -- scimitar
10196, -- orc tooth
11473, -- purple robe
3093, -- club ring
3082, -- elven amulet
5940, -- wolf tooth chain
3091, -- sword ring
3012, -- wolf tooth chain
3092, -- axe ring
236, -- strong health potion
11465, -- elven astral observer
11477, -- orcish gear
3061, -- life crystal
11480, -- skull belt
237, -- strong mana potion
5878, -- minotaur leather
11472, -- minotaur horn
9657, -- cyclops toe
11482, -- piece of warrior armor
11464, -- elven scouting glass
9635, -- elvish talisman
266, -- health potion
11451, -- broken crossbow
11479, -- orc leather
9651, -- scorpion tail
3347, -- hunting spear
11483, -- piece of archer armor
3298, -- throwing knife
3661, -- grave flower
3738, -- sling herb
3147, -- blank rune
3448, -- poison arrow
3582, -- ham
7363, -- piercing bolt
12600, -- coal
3577 -- meat
)
end

The fact that SOMETIMES the script works as it should just makes me even more confused. I'm not even sure syntax is the issue.

Infernal Bolt
09-30-2012, 08:56 AM
Try this


-- Potions
local PotID = 268
local PotPrice = 50
local MaxPot = 70

-- Spears
local SpearID = 7378
local SpearPrice = 15
local MaxSpear = 20

--== LABEL MANAGER ==--

registerEventListener(WALKER_SELECTLABEL, "onWalkerSelectLabel")
function onWalkerSelectLabel(labelName)
local func = loadstring(labelName)
if(func)then func()
end
end

--== SHOPPERS ==--

function buyPots()
local idlmanas = MaxPot-(Self.ItemCount(PotID))
setWalkerEnabled(false)
Self.SayToNpc({"hi", "vials", "no", "yes", "trade"}, 65)
wait(1000, 5000)
if (Self.ItemCount(PotID) < MaxPot) then
Self.ShopBuyItem(PotID, idlmanas)
end
setWalkerEnabled(true)
end

function buySpears()
local idlspears = MaxSpear-(Self.ItemCount(SpearID))
setWalkerEnabled(false)
Self.SayToNpc({"hi", "trade"}, 65)
wait(1000, 5000)
if (Self.ItemCount(SpearID) < MaxSpear) then
Self.ShopBuyItem(SpearID, idlspears)
end
setWalkerEnabled(true)
end

--== DEPOSITERS ==--

function DepositGold()
local idlmanas = MaxPot-(Self.ItemCount(PotID))
local idlspears = MaxSpear-(Self.ItemCount(SpearID))
local GTW = (idlmanas*PotPrice)+(idlspears*SpearPrice)
setWalkerEnabled(false)
Self.SayToNpc({"hi", "deposit all", "yes"}, 65)
if (GTW > 0) then
Self.SayToNpc({"withdraw " .. GTW, "yes", "balance"}, 65)
end
setWalkerEnabled(true)
end

function DepositItems()
Self.DepositItems(
3369, -- warrior helmet
7438, -- elvish bow
3073, -- wand of cosmic energy
5922, -- holy orchid
5880, -- iron ore
5896, -- bear paw
3037, -- yellow gem
7398, -- cyclops trophy
7401, -- minotaur trophy
7425, -- taurus mace
5921, -- heaven blossom
3351, -- steel helmet
3384, -- dark helmet
2991, -- doll
3033, -- small amethyst
5897, -- wolf paw
5902, -- honeycomb
3307, -- scimitar
10196, -- orc tooth
11473, -- purple robe
3093, -- club ring
3082, -- elven amulet
5940, -- wolf tooth chain
3091, -- sword ring
3012, -- wolf tooth chain
3092, -- axe ring
236, -- strong health potion
11465, -- elven astral observer
11477, -- orcish gear
3061, -- life crystal
11480, -- skull belt
237, -- strong mana potion
5878, -- minotaur leather
11472, -- minotaur horn
9657, -- cyclops toe
11482, -- piece of warrior armor
11464, -- elven scouting glass
9635, -- elvish talisman
266, -- health potion
11451, -- broken crossbow
11479, -- orc leather
9651, -- scorpion tail
3347, -- hunting spear
11483, -- piece of archer armor
3298, -- throwing knife
3661, -- grave flower
3738, -- sling herb
3147, -- blank rune
3448, -- poison arrow
3582, -- ham
7363, -- piercing bolt
12600, -- coal
3577 -- meat
)
end

Bastiat
10-01-2012, 08:43 PM
Seems to be working fine! Thanks a lot! ;)

There's still the item depositer that sometimes is skipped. I believe it's due to the food eater trying to eat food and open the depot at the same time.

Is there a something to stop then start the food eater like setWalkerEnabled(false) / setWalkerEnabled(true) for the walker??