Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

Easy UO Script: Mining at Mt. Kendall
#16

I've been having problems with EUO and just found out about OEUO that is scripted with lua that is a rather decent scripting language compared with the nonsense of the old EUO language and converted this script to OEUO It seems a bit faster mining so test it out.
I know it isn't perfect yet but is very usable in my opinion

Code:
-- Change this to the ID of container in your bank where you would like
-- your ingots to be placed.
ingotContainer=1082676472

ingotType=7151
toolTypes=3718
status="idle"
bankType=1074118237
idle="idle"

print("Starting OzMining 1.0 moded by Morwen")
status ="idle"
os=""
ref=0

function MineThisSpot(status)
    if ( status ~= "idle" ) then
       return status
    end
        local cnt=0
        for i=1,UO.ScanItems(true) do
            nID,type= UO.GetItem(i)  
                if type==3718 then
                cnt=cnt+1
                break
            end
        end
        if cnt > 0 then
            UO.LObjectID=nID
                   UO.Macro(17,0)
            local oldX=UO.CharPosX
            local oldY=UO.CharPosY
            local oldZ=UO.CharPosZ
            UO.TileInit (true)
            local nType,nZ,sName,nFlags=UO.TileGet(oldX,oldY,2)
            UO.LTargetTile=nType
            UO.LTargetX=oldX
            UO.LTargetY=oldY
            UO.LTargetZ=oldZ
            UO.LTargetKind=3
            --target 10s
            wait(200)
            UO.Macro(22,0)
            wait(400)
            UO.Macro(22,0)
            wait(800)
            UO.Macro(22,0)
            status="mining"
         end
    
    return status
end

function scanJournalFor(refArg,str)  
   nRef, nCnt = UO.ScanJournal(refArg)  
   for ji=nCnt-1,0,-1 do
         text,colour=UO.GetJournal(ji)
         if string.find(text,str) then
            print(ji)
            ref=nRef
            return true
         end
   end  
   return false
end

function ProcessResults(status,jrnl)
    while status == "mining" do
          
            if scanJournalFor(ref,"dig some") then
                                 print("You dug something")  
                 status="idle"
            end
            if scanJournalFor(ref,"loosen some rocks") then
                    print("FAIL LOL")
                                status="idle"
            end
            
            if scanJournalFor(ref,"You have moved too far") then
                print("Stupid biatx")
                                status="idle"
            end
            if scanJournalFor(ref,"Someone has gotten") then
               print("huh?")
                status="idle"
            end
    
            if scanJournalFor(ref,"target cannot be seen") then
                                 print("stupid blind ****er")
                status="no_more_ore"
                --MoveToNextSpot()
            end
            if scanJournalFor(ref,"is no metal here to mine") then
                                         print("Resource depleeted")
                status="no_more_ore"
                
            end
            if scanJournalFor(ref,"can't mine that") then
                print("You can only mine rocks... you know like... rocks")
                                status="idle"
                --MoveToNextSpot()
            end
            if scanJournalFor(ref,"save complete.") then
                           print("God save us from Eru")
                      status="no_more_ore"
                
            end
            if scanJournalFor(ref,"that is too far away") then
                print("You are not so big now!")
                                status="no_more_ore"
                
            end
            if scanJournalFor(ref,"for validating your presence") then
                UO.Msg("Dont forget to VOTE\n")
                                status="no_more_ore"
                
            end
            if scanJournalFor(ref,"stand closer") then
                print("Its ingot melting time!!!")
                                status="idle"
                                GoSmelt()
                
            end
            if status~=os then
            os=status
            print("new status "..status)
            end
        
    end
    return status
end

function MoveToNextSpot()
         print("Finding next mining spot\n")

--FindNextSpot:
    local oldX=UO.CharPosX
    local oldY=UO.CharPosY
    local randomInc=math.random(-5,5)
    local newX=oldX + randomInc
      randomInc = math.random(-5,5)
    local newY=oldY + randomInc

    print("Checking tile data")
      UO.TileInit (true)
    nType,nZ,sName,nFlags=UO.TileGet(newX,newY,2)

        while sName~="cave floor" do
              print("tile wasn't in a cave.")
              print("Checking another tile to go.")
              math.random()
              randomInc = math.random(-5,5)
              newX=oldX + randomInc
            randomInc = math.random(-5,5)
          newY=oldY + randomInc
          print("X:"..newX.." Y:"..newY)
                nType,nZ,sName,nFlags=UO.TileGet(newX,newY,2)
        end
        print("Going to "..newX.."-"..newY)
           UO.Pathfind(newX,newY)
           local countTry=0
    while UO.CharPosX~=newX and UO.CharPosY~=newY do
        wait(2000)
        UO.Pathfind(newX,newY)
        if countTry==15 then
           break
           else
             countTry=countTry+1
        end
    end
    
  
    
    status="idle"
end

function GoToForge()
         local x=UO.CharPosX
         local y=UO.CharPosY
         local CountOres=0
         for i=1,UO.ScanItems(true) do
    local id,type = UO.GetItem(i)  
            if type==6585 then
            CountOres=CountOres+1
        end
    end
    if(CountOres>0)      then
        
    local minD=99999999
    local currD=-1
    local idx=-1
    local forgeXs={2568,2569,2575,2576,2568,2569,2570,2571,2572,2573,
            2574,2575,2576,2577,2568,2569,2570,2571,2572,2573,
            2574,2575,2576,2577,2568,2569,2570,2571,2572,2573,
            2574,2575,2576,2577,2572,2573,2574,2575,2576,2577,
            2578,2572,2573,2577,2578,2572,2573,2578,2572,2573,
            2577,2578,2572,2573,2574,2575,2576,2577,2578,2572,
            2573,2574,2575,2576,2577,2578,2572,2573,2574,2575,
            2576,2577,2578,2581,2581,2581,2581,2581,2581,2581,
            2582,2582,2582,2582,2582,2582,2582,2582,2583,2583,
            2583,2583,2583,2583,2583}    
    local forgeYs={474,474,474,474,475,475,475,475,475,475,475,475,475,
            475,476,476,476,476,476,476,476,476,476,476,477,
            477,477,477,477,477,477,477,477,477,486,486,486,
            486,486,486,486,487,487,487,487,488,488,488,489,
            489,489,489,490,490,490,490,490,490,490,491,491,
            491,491,491,491,491,492,492,492,492,492,492,492,
            490,491,492,493,494,496,497,490,491,492,493,494,
            495,496,497,490,491,492,493,494,495,496}    
    for i=1,95 do
        --calc min distance
        currD=math.sqrt(math.pow(x-forgeXs[i],2)+math.pow(y-forgeYs[i],2))
        if(currD<mind) then
                 minD=currD
            idx=i
        end
    end

    UO.Pathfind(forgeXs[idx],forgeYs[idx])
    local newX=forgeXs[idx]
    local newY=forgeYs[idx]
    while UO.CharPosX~=newX and UO.CharPosY~=newY do
        wait(5000)
        UO.Pathfind(newX,newY)
    end
    while UO.CharPosX ~= newX and UO.CharPosY ~= newY  do
        wait(1000)
    end
    print("Reached forge")
    wait(1000)
    --Melt ores
    for i=1,UO.ScanItems(true) do
    local id,type = UO.GetItem(i)  
            if type==6585 then
            UO.LObjectID=id
                   UO.Macro(17,0)
                   print("Smelts ore")
            wait(200)
        end
    end
    else
        print("No Ores to Smelt")
    end
end

function GoSmelt()
--TODO Find nearest forge from a list of forges
--    saves current position and go to forge
--    Once there smelt all the ores and
--    go back
    local oldX=UO.CharPosX
    local oldY=UO.CharPosY
--SmeltOre:
--  set %oldX #charposX
--  set %oldY #charposY
    GoToForge()
      if UO.Weight > UO.MaxWeight-10 then
        bankOre()
    end
    UO.Pathfind(oldX,oldY);
      while UO.CharPosX~=oldX and UO.CharPosY~=oldY do
        wait(2000)
        UO.Pathfind(oldX,oldY)
    end
    while UO.CharPosX ~= oldX and UO.CharPosY ~= oldY  do
        wait(1000)
    end
end


function bankOre()
    local oldX=UO.CharPosX
    local oldY=UO.CharPosY
    local countIng =0
    for i=1,UO.ScanItems(true) do
    local nID,nType,nKind, nContID, nX, nY, nZ, nStack, nRep, nCol  = UO.GetItem(i)  
            if nType==7151 then--ingotType then
                    countIng=countIng+1
        end
    end
    if(countIng>0)  then
    print("Going to bank ingots...")
    UO.Pathfind(2569,488);
      while UO.CharPosX~=2569 and UO.CharPosY~=488 do
        wait(5000)
        UO.Pathfind(2569,488);
    end
      while UO.CharPosX~=2569 and UO.CharPosY~=489 do
        wait(1000)
    end
    UO.Pathfind(2561,510);
      while UO.CharPosX~=2561 and UO.CharPosY~=510 do
        wait(5000)
        UO.Pathfind(2561,510);
    end    
        while UO.CharPosX~=2561 and UO.CharPosY~=510 do
        wait(1000)
    end
    print("Reached banking spot")
        wait(500)
    UO.LObjectID=bankType
      UO.Macro(17,0)
    wait(2000)
      print("Opened bankbox")
    for i=1,UO.ScanItems(true) do
    local nID,nType,nKind, nContID, nX, nY, nZ, nStack, nRep, nCol  = UO.GetItem(i)  
            if nType==ingotType then
                           wait(200)
            UO.Drag(nID,nStack)
            wait(400)
            UO.DropC(ingotContainer)
            wait(800)
        end
    end

    print("Going back...")
    UO.Pathfind(2569,488);
      while UO.CharPosX~=2569 and UO.CharPosY~=489 do
        wait(5000)
        UO.Pathfind(2569,488);
    end
      while UO.CharPosX~=2569 and UO.CharPosY~=489 do
        wait(1000)
    end
    UO.Pathfind(oldX,oldY);
      while UO.CharPosX~=oldX and UO.CharPosY~=oldY do
        wait(5000)
        UO.Pathfind(oldX,oldY)
    end
    while UO.CharPosX ~= oldX and UO.CharPosY ~= oldY  do
        wait(1000)
    end
        end
end











function Main()
    local status="idle"

    while UO.Hits > 0 do
        if ( UO.Weight > UO.MaxWeight )  then
                     print("gosmelt")
              GoSmelt()
        end
        if status == "no_more_ore" then
           print("move next")
            status= "idle"
                 MoveToNextSpot()
        end
        if ( UO.Weight > UO.MaxWeight )   then
             print("gosmelt")
            GoSmelt()
        end
        local nNewRef = UO.ScanJournal(0)
        status=MineThisSpot(status)
        status=ProcessResults(status,nNewRef)
    end
end

Main()    --Run biatx


Messages In This Thread
Easy UO Script: Mining at Mt. Kendall - by Taran - 06-19-2011, 10:43 AM
Easy UO Script: Mining at Mt. Kendall - by Morwen - 06-27-2011, 12:39 AM
Easy UO Script: Mining at Mt. Kendall - by Taran - 06-27-2011, 05:08 PM
Easy UO Script: Mining at Mt. Kendall - by Morwen - 06-27-2011, 11:07 PM
Easy UO Script: Mining at Mt. Kendall - by BlackBeard - 07-06-2011, 05:15 PM
Easy UO Script: Mining at Mt. Kendall - by Eru - 07-06-2011, 05:23 PM
Easy UO Script: Mining at Mt. Kendall - by Taran - 07-06-2011, 08:02 PM
Easy UO Script: Mining at Mt. Kendall - by Cana - 07-06-2011, 10:10 PM
Easy UO Script: Mining at Mt. Kendall - by Morwen - 07-07-2011, 01:20 AM
Easy UO Script: Mining at Mt. Kendall - by Morwen - 07-07-2011, 02:05 AM
Easy UO Script: Mining at Mt. Kendall - by Eru - 07-07-2011, 02:20 AM
Easy UO Script: Mining at Mt. Kendall - by Morwen - 07-07-2011, 01:42 PM
Easy UO Script: Mining at Mt. Kendall - by Venos - 07-07-2011, 05:20 PM
Easy UO Script: Mining at Mt. Kendall - by zenith - 07-20-2011, 02:48 AM
Easy UO Script: Mining at Mt. Kendall - by Venos - 07-20-2011, 10:35 AM
Easy UO Script: Mining at Mt. Kendall - by Morwen - 08-02-2011, 09:39 PM
Easy UO Script: Mining at Mt. Kendall - by Morwen - 08-02-2011, 10:39 PM
Easy UO Script: Mining at Mt. Kendall - by Morwen - 08-03-2011, 01:06 AM
Easy UO Script: Mining at Mt. Kendall - by Taran - 08-03-2011, 12:11 PM
Easy UO Script: Mining at Mt. Kendall - by JointCh1L - 08-29-2011, 12:07 PM
Easy UO Script: Mining at Mt. Kendall - by Lamby - 08-29-2011, 08:07 PM
Easy UO Script: Mining at Mt. Kendall - by Morwen - 08-29-2011, 08:54 PM
Easy UO Script: Mining at Mt. Kendall - by Lamby - 08-29-2011, 10:21 PM
Easy UO Script: Mining at Mt. Kendall - by Morwen - 08-29-2011, 11:04 PM
Easy UO Script: Mining at Mt. Kendall - by Lamby - 08-30-2011, 01:28 AM
Easy UO Script: Mining at Mt. Kendall - by Morwen - 08-30-2011, 01:41 AM
Easy UO Script: Mining at Mt. Kendall - by Christina Thorn - 08-30-2011, 01:51 AM
Easy UO Script: Mining at Mt. Kendall - by Lamby - 08-30-2011, 01:40 PM
Easy UO Script: Mining at Mt. Kendall - by Morwen - 08-30-2011, 02:22 PM
Easy UO Script: Mining at Mt. Kendall - by Morwen - 08-30-2011, 02:25 PM
Easy UO Script: Mining at Mt. Kendall - by Lamby - 08-30-2011, 02:48 PM
Easy UO Script: Mining at Mt. Kendall - by Morwen - 08-30-2011, 03:29 PM
Easy UO Script: Mining at Mt. Kendall - by Lamby - 08-30-2011, 04:07 PM
Easy UO Script: Mining at Mt. Kendall - by Morwen - 08-30-2011, 04:53 PM
Easy UO Script: Mining at Mt. Kendall - by Lamby - 08-30-2011, 05:00 PM
Easy UO Script: Mining at Mt. Kendall - by Morwen - 08-30-2011, 05:27 PM
Easy UO Script: Mining at Mt. Kendall - by Morwen - 08-30-2011, 05:50 PM
Easy UO Script: Mining at Mt. Kendall - by Lamby - 08-30-2011, 05:51 PM
Easy UO Script: Mining at Mt. Kendall - by Morwen - 08-30-2011, 05:57 PM
Easy UO Script: Mining at Mt. Kendall - by Makaveli - 09-01-2011, 05:53 PM
Easy UO Script: Mining at Mt. Kendall - by Morwen - 09-01-2011, 07:47 PM
Easy UO Script: Mining at Mt. Kendall - by Ilithyia - 09-09-2011, 04:05 PM
Easy UO Script: Mining at Mt. Kendall - by Alexstrasza - 10-18-2011, 06:10 PM
Easy UO Script: Mining at Mt. Kendall - by Atlas - 10-18-2011, 07:04 PM
Easy UO Script: Mining at Mt. Kendall - by Morwen - 10-19-2011, 11:48 PM
Easy UO Script: Mining at Mt. Kendall - by Ilithyia - 10-20-2011, 02:39 AM
Easy UO Script: Mining at Mt. Kendall - by Morwen - 10-20-2011, 03:14 PM
Easy UO Script: Mining at Mt. Kendall - by Ilithyia - 10-22-2011, 07:38 PM
Easy UO Script: Mining at Mt. Kendall - by Morwen - 10-23-2011, 11:20 PM
Easy UO Script: Mining at Mt. Kendall - by Taran - 10-28-2011, 10:56 PM
Easy UO Script: Mining at Mt. Kendall - by Morwen - 10-29-2011, 11:00 AM
Easy UO Script: Mining at Mt. Kendall - by Lamby - 10-31-2011, 09:30 PM
Easy UO Script: Mining at Mt. Kendall - by Morwen - 10-31-2011, 10:59 PM
Easy UO Script: Mining at Mt. Kendall - by Ilithyia - 11-14-2011, 04:19 PM
Easy UO Script: Mining at Mt. Kendall - by Lamby - 11-14-2011, 04:35 PM
Easy UO Script: Mining at Mt. Kendall - by Morwen - 11-14-2011, 07:34 PM
Easy UO Script: Mining at Mt. Kendall - by Ilithyia - 11-15-2011, 02:50 AM
Easy UO Script: Mining at Mt. Kendall - by Craditz - 11-19-2011, 01:49 AM
Easy UO Script: Mining at Mt. Kendall - by Emerald - 11-19-2011, 05:35 AM
Easy UO Script: Mining at Mt. Kendall - by Azzo - 02-11-2012, 01:46 PM
Easy UO Script: Mining at Mt. Kendall - by Azzo - 02-13-2012, 12:50 PM
Easy UO Script: Mining at Mt. Kendall - by Azzo - 02-13-2012, 03:25 PM
Easy UO Script: Mining at Mt. Kendall - by pedrodilara - 02-16-2012, 04:32 PM
Easy UO Script: Mining at Mt. Kendall - by Elcid - 02-17-2012, 12:55 AM
Easy UO Script: Mining at Mt. Kendall - by Brandon - 02-18-2012, 01:42 AM
Easy UO Script: Mining at Mt. Kendall - by Eadred - 02-21-2012, 11:18 AM
Easy UO Script: Mining at Mt. Kendall - by igor - 03-16-2012, 05:19 PM
Easy UO Script: Mining at Mt. Kendall - by Syralia - 03-22-2012, 12:33 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)