Post by nefariis on Nov 26, 2020 17:30:58 GMT
I wanted to create a script that could fish unattended all day using a user selected "fishing field"
To run this script -
1. Fill out checkAndDefend() (optional if you are fishing out of town)
2. "until not goodFishing" allows the user to install some sort of break if they want a hard stop point (overweight, attacked, etc.)
3. Run the script
4. You will be prompted to select the upper left bound of the desired "fishing field"
5. After five seconds, you will then be prompted for the lower left bound of your "fishing field"
6. Enjoy
math.randomseed(os.time())
local ulx, ulz, lrx, lrz
function getBounds()
print("Please define top left fishing location...")
sleep(5000)
ulx, ulz = CLICKWORLDX, CLICKWORLDZ
print(string.format(" - Upper Bounds x: %s, z: %s", ulx, ulz))
print("Please define lower right fishing location...")
sleep(5000)
lrx, lrz = CLICKWORLDX, CLICKWORLDZ
print(string.format(" - Lower Bounds x: %s, z: %s", lrx, lrz))
end
function checkFishingRod()
if RIGHTHANDNAME == "Fishing Rod" then
return true
else
FindItem ("fishing rod", BACKPACKID)
if FINDITEM then
print("Equipping Fishing Rod")
ContextMenu(FINDITEM[1].ID, "Equip")
return true
end
end
print("No Fishing Pole")
return false
end
function checkAndDefend()
-- Optional checkAndDefendField
end
function startFishing()
FindItem("school of ")
if FINDITEM and FINDITEM[1].DISTANCE < 25 then
x, z = math.floor(FINDITEM[1].X), math.floor(FINDITEM[1].Z)
distance = math.floor(FINDITEM[1].DISTANCE)
print(string.format("\tFound a school x: %s, z: %s Distance: %s", x, z, distance))
else
x, z = math.random(ulx, lrx), math.random(ulz, lrz)
print(string.format("\tNow fishing x: %s, z: %s", x, z))
end
while true do
print("\t\tCasting...")
Macro(28)
TargetLoc(x, CHARPOSY, z)
start = TIME
repeat
checkAndDefend()
ScanJournal(TIME)
if TIME - start > 25 or string.match(SCANJOURNALMESSAGE, "seem to be any")
or string.match(SCANJOURNALMESSAGE, "cast into water") or string.match(SCANJOURNALMESSAGE, "too far away")then
sleep(2000)
return
end
until string.match(SCANJOURNALMESSAGE, "caught") or string.match(SCANJOURNALMESSAGE, "fish are biting")
or string.match(SCANJOURNALMESSAGE, "slippery") or string.match(SCANJOURNALMESSAGE, "you fish up")
sleep(1000)
end
end
-- The start of script
getBounds()
repeat
if not checkFishingRod() then return end
goodFishing = startFishing()
until not goodFishing