Log in

View Full Version : Help with my script.



DarkRoses
06-26-2013, 05:57 PM
Alright, so I've been working on a script but when I start the script I get this error:

Line #: 208
Chunk: ...athias\Documents\XenoBot\Scripts\[ED] DLs Darashia v1.0 by DarkRoses.lua
Error: 'end' expected (to close 'function' at line 57) near '<eof>'

However, could someone help me? I cannot find the fault I've made.

I'll attach my .lua file and if you could have a look I would be greatful. :)

Xeromex
06-26-2013, 06:01 PM
---------------------------------
------Dragon Lords Darashia------
----------By DarkRoses-----------
-------------Enjoy!--------------
---------------------------------


----------- DP SETUP ------------
-- [DP 1] - Rares
-- [DP 2] - Products
-- [DP 3] - Potions & Gems

----------- BP SETUP ------------
-- [BP 1] - Main
-- [BP 2] - Potions
-- [BP 3] - Products
-- [BP 4] - Rares
-- [BP 5] - Gold

-------- REFILL SETTINGS --------
local MinMana = 50
local MaxMana = 150

local MinSD = 50
local MaxSD = 300

--------- HUNT SETTINGS ---------
local MainBp = "Backpack of Holding" --- Your main backpack.
local SuppBP = "Demon Backpack" --- Supply/Pot backpack.
local NonstackableBP = "Beach Backpack" --- Non stackable loot backpack.
local StackableBP = "Jewelled Backpack" --- Stackable loot backpack.
local GoldBP = "Brocade Backpack" --- Gold backpack.

local MinCap = 50 --- If less then script will exit spawn.
local HideEquipment = true --- Do you want to minimize your equipment?
local HuntHardcore = true --- Hunt Hardcore

Targeting.Start()
Looter.Start()

--------------------------------------------------------------------
--------------------------------------------------------------------
--------------------------------------------------------------------
--------------------------------------------------------------------
--------------------------------------------------------------------

local info = [[
Dragon Lords Darashia
ED Version 1.0
By Darkroses]]

print(info)
wait(1000)

registerEventListener(WALKER_SELECTLABEL, "onWalkerSelectLabel")

function onWalkerSelectLabel(labelName)
if (labelName == "Checker") then -- Check Supplies or Cap to decide if Leave or Cont. Hunt
Walker.ConditionalGoto((Self.ItemCount(238) <= MinMana) or (Self.Cap() < LeaveCap) or (Self.ItemCount(3155) <= MinSD), "Leave", "BeginHunt")

elseif (labelName == "Start") then
print(info)
wait(1000)

elseif (labelName == "Banker") then -- Deposit Gold, Withdraw Gold, Check Balance.
Walker.Stop()
Self.SayToNpc({"hi", "deposit all", "yes"}, 100)

local withdrawManas = math.max(MaxMana - Self.ItemCount(238), 0)*120
local withdrawSD = math.max(MaxSD - Self.ItemCount(3155), 0)*110
local total = math.abs(withdrawManas + withdrawSD + 1000)

if total >= 1 then
Self.SayToNpc({"withdraw " .. total, "yes", "balance"}, 100)
end
Walker.Start()

elseif (labelName == "Deposit") then -- Deposit Items
Walker.Stop()
Self.ReachDepot(10)
Self.DepositItems({5882, 1}, {3028, 1}, {3029, 1}, {5948, 1}, {239, 1}, {236, 1}, {3061, 1})
Self.DepositItems({5919, }, {3386, }, {3392, }, {7402, }, {7399, }, {3428, }, {3416, }, {3280, }, {3071, }, {3322, }, {3297, }, {3301, }, {3373, }, {3351, }, {3275, }, {2903, }, {3075, }, {3051, }, {3349, }, {3557, }, {3409, }, {3285, }, {3286, }, {3294, })
Walker.Start()

elseif (labelName == "BuySupplies") then -- Buy Manas and Runes
Walker.Stop()
if (Self.ItemCount(238) < MaxMana) or (Self.ItemCount(3155) < MaxSD) then
Self.SayToNpc({"hi", "trade"}, 65)
wait(2000)
if (Self.ItemCount(238) < MaxMana) then
BuyItems(238, MaxMana)
wait(500)
BuyItems(238, MaxMana)
wait(500)
end
if (Self.ItemCount(3155) < MaxSD) then
BuyItems(3155, MaxSD)
wait(500)
BuyItems(3155, MaxSD)
wait(500)
end
wait(200, 500)
end
Walker.Start()

elseif (labelName == "Verify") then -- Verify Supplies
Walker.ConditionalGoto((Self.ItemCount(238) >= MaxMana) or (Self.ItemCount(3155) >= MaxSD), "SuppliesOk", "NotVerify")

elseif (labelName == "ResetBps1") then -- Reset backpacks
Walker.Stop()
Self.CloseContainers()
wait(900,1000)
Self.OpenMainBackpack(true):OpenChildren({SuppBP, true},{NonstackableBP, true},{StackableBP, true},{GoldBP, true})
Container.GetFirst():Minimize()
if (HideEquipment) then
Client.HideEquipment()
wait(1000)
end
Walker.Start()

elseif (labelName == "ResetBps2") then -- Reset backpacks
Walker.Stop()
Self.CloseContainers()
wait(900,1000)
Self.OpenMainBackpack(true):OpenChildren({SuppBP, true},{NonstackableBP, true},{StackableBP, true},{GoldBP, true})
Container.GetFirst():Minimize()
Walker.Start()

elseif (labelName == "CheckHardcore") then
Walker.Stop()
Walker.ConditionalGoto((HuntHardcore) and (Self.ItemCount(238) > MinMana) and (Self.ItemCount(3155) > MinRune), "Hardcore", "HardcoreDone")
Walker.Start()
end
end



-----------------------------------------------------------------------------
--------------------------------- Functions ---------------------------------
-----------------------------------------------------------------------------
function BuyItems(item, count) -- item = item id, count = how many you want to buy up to
wait(900, 1200)
if (Self.ItemCount(item) < count) then
Self.ShopBuyItem(item, (count-Self.ItemCount(item)))
wait(200, 500)
end
end

Self.ReachDepot = function (tries)
local tries = tries or 3
Walker.Stop()
local DepotIDs = {3497, 3498, 3499, 3500}
local DepotPos = {}
for i = 1, #DepotIDs do
local dps = Map.GetUseItems(DepotIDs[i])
for j = 1, #dps do
table.insert(DepotPos, dps[j])
end
end
local function gotoDepot()
local pos = Self.Position()
print("Depots found: " .. tostring(#DepotPos))
for i = 1, #DepotPos do
location = DepotPos[i]
Self.UseItemFromGround(location.x, location.y, location.z)
wait(1000, 2000)
if Self.DistanceFromPosition(pos.x, pos.y, pos.z) >= 1 then
wait(5000, 6000)
if Self.DistanceFromPosition(location.x, location.y, location.z) == 1 then
Walker.Start()
return true
end
else
print("Something is blocking the path. Trying next depot.")
end
end
return false
end

repeat
reachedDP = gotoDepot()
if reachedDP then
return true
end
tries = tries - 1
sleep(100)
print("Attempt to reach depot was unsuccessfull. " .. tries .. " tries left.")
until tries <= 0

return false
end

Map.GetUseItems = function (id)
if type(id) == "string" then
id = Item.GetID(id)
end
local pos = Self.Position()
local store = {}
for x = -7, 7 do
for y = -5, 5 do
if Map.GetTopUseItem(pos.x + x, pos.y + y, pos.z).id == id then
itemPos = {x = pos.x + x, y = pos.y + y, z = pos.z}
table.insert(store, itemPos)
end
end
end
return store
end

DarkRoses
06-26-2013, 06:03 PM
Thanks alot! :D