Abutaka
12-28-2012, 01:43 AM
loadSettings("[Mage] Port Hope Water Elementals", "All")
This line reloads the .XBST file, causing it to close all Lua scripts. What you need to do is remove this line of code, load the .XBST and then load the .LUA. Save the .XBST. Now, when you load the .XBST, it will auto-load the .LUA.
Incase anyone had the same problem as me :)
Hello,
im tryging to execute PH water elemental script but It wont execute. When I try to run the script, it goes back to "found scripts". On the tibia screen it says that script successfully loaded, but still wont work. I got the Forgee script too, so dont bother to ask.
Any solution guys?
Code
--== [Mage] Port Hope Water Elementals v2.1 ==--
--==# SETUP #==--
local minCap = 0 -- Minimum capacity to keep hunting.
local GoldBP = "Purple Backpack" -- Gold Backpack
local LootBP = "Red Backpack" -- Loot Backpack.
local StackDP = 0 -- Slot of BP that will be Stackable Items.
local RareDP = 1 -- Slot of BP that will be Non-Stackable Items.
local mpID = 237 -- Mana Potion ID.
local minMP = 35 -- If less then script will exit spawn.
local buyMP = 140 -- Amount of MPs to buy.
local costMP = 80 -- Potion Price.
--[[
Mana Potions IDs:
Normal(268);
Strong(237);
Great(238).
]]--
--- DO NOT CHANGE BELOW UNLESS YOU KNOW WHAT YOU'RE DOING ---
registerEventListener(WALKER_SELECTLABEL, "onWalkerSelectLabel")
loadSettings("[Mage] Port Hope Water Elementals", "All")
local info = [[
Free script made by:
rikardo]]
function onWalkerSelectLabel(labelName)
if (labelName == "checking") then
if (Self.ItemCount(mpID) > minMP) then
gotoLabel("beginHunt")
end
elseif (labelName == "checkPos1") then
wait(1300,1500)
if (Self.Position().z ~= 7) then
gotoLabel("pos1")
end
elseif (labelName == "checkPos2") then
wait(1300,1500)
if (Self.Position().z ~= 7) then
gotoLabel("pos2")
end
elseif (labelName == "openDoor") then
setWalkerEnabled(false)
Self.UseItemFromGround(32554, 32860, 9)
wait(1300,2000)
setWalkerEnabled(true)
elseif (labelName == "atBank") then
local cashMP = costMP*(buyMP-Self.ItemCount(mpID))
setWalkerEnabled(false)
Self.SayToNpc({"hi", "deposit all", "yes", "balance"}, 65,10)
if (cashMP > 0) then
Self.SayToNpc({"withdraw " .. cashMP, "yes"}, 65)
wait(500,900)
end
setWalkerEnabled(true)
elseif (labelName == "buyPotions") then
setWalkerEnabled(false)
Self.SayToNpc({"hi"}, 65)
wait(700,1000)
while ((Self.ItemCount(283)+Self.ItemCount(284)+Self.Ite mCount(285)) > 0) do
Self.SayToNpc({"vials", "yes", "yes"}, 65, 10)
wait(1200,1500)
end
Self.SayToNpc({"trade"}, 65)
wait(1500,3000)
while (Self.ItemCount(mpID) < buyMP) do
Self.ShopBuyItemsUpTo(mpID, buyMP)
wait(600,1100)
end
setWalkerEnabled(true)
elseif (labelName == "atDepot") then
setWalkerEnabled(false)
Self.ReachDepot()
Self.DepositItems(
{236,StackDP}, -- Strong Health Potion
{11489,StackDP}, -- Mantassin Tail
{3028,StackDP}, -- Small Diamond
{3032,StackDP}, -- Small Emerald
{3026,StackDP}, -- White Pearl
{3029,StackDP}, -- Small Sapphire
{7158,StackDP}, -- Rainbow Trout
{7159,StackDP}, -- Green Perch
{281,StackDP}, -- Giant Shimmering Pearl
{5895,StackDP}, -- Fish Fin
{9303,RareDP}, -- Leviathan's Amulet
{3049,RareDP}, -- Stealth Ring
{3052,RareDP}, -- Life Ring
{3051,RareDP} -- Energy Ring
)
wait(1500)
setWalkerEnabled(true)
end
end
--==## FUNCTIONS ##==--
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
Self.ReachDepot = function (tries)
local tries = tries or 3
setWalkerEnabled(false)
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
setWalkerEnabled(true)
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
This line reloads the .XBST file, causing it to close all Lua scripts. What you need to do is remove this line of code, load the .XBST and then load the .LUA. Save the .XBST. Now, when you load the .XBST, it will auto-load the .LUA.
Incase anyone had the same problem as me :)
Hello,
im tryging to execute PH water elemental script but It wont execute. When I try to run the script, it goes back to "found scripts". On the tibia screen it says that script successfully loaded, but still wont work. I got the Forgee script too, so dont bother to ask.
Any solution guys?
Code
--== [Mage] Port Hope Water Elementals v2.1 ==--
--==# SETUP #==--
local minCap = 0 -- Minimum capacity to keep hunting.
local GoldBP = "Purple Backpack" -- Gold Backpack
local LootBP = "Red Backpack" -- Loot Backpack.
local StackDP = 0 -- Slot of BP that will be Stackable Items.
local RareDP = 1 -- Slot of BP that will be Non-Stackable Items.
local mpID = 237 -- Mana Potion ID.
local minMP = 35 -- If less then script will exit spawn.
local buyMP = 140 -- Amount of MPs to buy.
local costMP = 80 -- Potion Price.
--[[
Mana Potions IDs:
Normal(268);
Strong(237);
Great(238).
]]--
--- DO NOT CHANGE BELOW UNLESS YOU KNOW WHAT YOU'RE DOING ---
registerEventListener(WALKER_SELECTLABEL, "onWalkerSelectLabel")
loadSettings("[Mage] Port Hope Water Elementals", "All")
local info = [[
Free script made by:
rikardo]]
function onWalkerSelectLabel(labelName)
if (labelName == "checking") then
if (Self.ItemCount(mpID) > minMP) then
gotoLabel("beginHunt")
end
elseif (labelName == "checkPos1") then
wait(1300,1500)
if (Self.Position().z ~= 7) then
gotoLabel("pos1")
end
elseif (labelName == "checkPos2") then
wait(1300,1500)
if (Self.Position().z ~= 7) then
gotoLabel("pos2")
end
elseif (labelName == "openDoor") then
setWalkerEnabled(false)
Self.UseItemFromGround(32554, 32860, 9)
wait(1300,2000)
setWalkerEnabled(true)
elseif (labelName == "atBank") then
local cashMP = costMP*(buyMP-Self.ItemCount(mpID))
setWalkerEnabled(false)
Self.SayToNpc({"hi", "deposit all", "yes", "balance"}, 65,10)
if (cashMP > 0) then
Self.SayToNpc({"withdraw " .. cashMP, "yes"}, 65)
wait(500,900)
end
setWalkerEnabled(true)
elseif (labelName == "buyPotions") then
setWalkerEnabled(false)
Self.SayToNpc({"hi"}, 65)
wait(700,1000)
while ((Self.ItemCount(283)+Self.ItemCount(284)+Self.Ite mCount(285)) > 0) do
Self.SayToNpc({"vials", "yes", "yes"}, 65, 10)
wait(1200,1500)
end
Self.SayToNpc({"trade"}, 65)
wait(1500,3000)
while (Self.ItemCount(mpID) < buyMP) do
Self.ShopBuyItemsUpTo(mpID, buyMP)
wait(600,1100)
end
setWalkerEnabled(true)
elseif (labelName == "atDepot") then
setWalkerEnabled(false)
Self.ReachDepot()
Self.DepositItems(
{236,StackDP}, -- Strong Health Potion
{11489,StackDP}, -- Mantassin Tail
{3028,StackDP}, -- Small Diamond
{3032,StackDP}, -- Small Emerald
{3026,StackDP}, -- White Pearl
{3029,StackDP}, -- Small Sapphire
{7158,StackDP}, -- Rainbow Trout
{7159,StackDP}, -- Green Perch
{281,StackDP}, -- Giant Shimmering Pearl
{5895,StackDP}, -- Fish Fin
{9303,RareDP}, -- Leviathan's Amulet
{3049,RareDP}, -- Stealth Ring
{3052,RareDP}, -- Life Ring
{3051,RareDP} -- Energy Ring
)
wait(1500)
setWalkerEnabled(true)
end
end
--==## FUNCTIONS ##==--
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
Self.ReachDepot = function (tries)
local tries = tries or 3
setWalkerEnabled(false)
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
setWalkerEnabled(true)
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