Lumberjackin script problem

Anything and all.

Moderators: Murderator+, Murderator

Post Reply
primate
Posts: 3
Joined: 2006-08-02 06:17:59

Lumberjackin script problem

Post by primate »

Why this script is saving me the all the tiles for target the trees in the file al in 1 x y and z like this:

1 1 1
1 1 1
1 1 1

Code: Select all

sub Lumber()
var i=0,j=0,k=0,r=0,q=0,ii,jj
var TopX=0,TopY=0
dim TreeX[100], TreeY[100],TreeT[100]
dim TreeTile[100]
var flag=0,treeCount=0,clicks=0,flag2=0
var f=file("C:\arboles.dat")  ## archivo donde guarda los arboles

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
var Treesnum=5 ## Numero de arboles para una ruta nueva maximo 100
var GetFromFile=0 ## 0 para crear primero una nueva  ruta, 1 para que lea una ruta ya guardada.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
uo.print('Selecciona tu hacha')
uo.exec('addobject hacha')
while uo.targeting()
wait(100)
wend

uo.print('Selecciona tu daga')
uo.exec('addobject daga')
while uo.targeting()
wait(100)
wend

if GetFromFile==1 then
uo.print('Recuperando datos de archivo')
f.open()
TreeCount=safe call f.readNumber()
for i=1 to TreeCount
TreeT=safe call f.ReadNumber()
TreeX=safe call f.ReadNumber()
TreeY=safe call f.ReadNumber()
next
f.close()
else

uo.print('Selecciona los arboles de 1 en 1...')

for i=1 to Treesnum

uo.DeleteJournal()
uo.useobject('daga')
WaitForTarget()
while uo.targeting()
wait(100)
wend

treeCount=treeCount+1
TreeX[treeCount]=uo.LastTile(1)
treeY[treeCount]=uo.lastTile(2)
TreeT[treeCount]=uo.LastTile(0)
uo.print('Nuevo arbol añadido: x='+str(uo.lasttile(1))+' y='+str(uo.lastTile(2)))

next
uo.print('Ruta completa. Coordenadas salvadas en C:\arboles.dat')
guardarruta(treeCount,TreeX,TreeY,TreeT)

end if
uo.print('Arboles totales: '+str(treeCount))
wait(2000)

while 1==1
if treeCount>0 then
   for i=1 to treeCount
      uo.print('Camino al arbol '+str(i)+': x='+str(treex)+' y='+str(treey))
      #move(treex+1,treey+1)
      move(treex,treey)
      talar(str(treeT),str(treeX),str(TreeY))
   next
end if
wend
end sub


sub guardarruta(TreeCount,TreeX,TreeY,TreeT)
var f=file("C:\arboles.dat")
var s=0,i=0
f.open()
f.create()
s=safe call f.writeln(TreeCount)
for i=1 to TreeCount
s=safe call f.writeln(str(TreeT)+' '+str(treeX)+' '+str(TreeY))
next
f.close()
end sub

sub WaitForTarget()
for var i=0 to 50
if uo.Targeting()==1 then
return 1
end if
wait(200)
next
return 0
end sub

sub talar(t,x1,y1)
var a=0
uo.deletejournal()
while a < 7
if UO.InJournal('There are no logs here to chop') then
   a=8
   uo.deletejournal()
end if
if a < 7 then

uo.waittargettile(t,x1,y1,0)
wait(1600)

uo.useobject('hacha')
wait(7000)
a = a + 1
end if
wend

end sub



sub Move(x,y)
  var cx,cy,e=0,dir=1,M="-40-231-657"
  while dir<>0
     cx=uo.getx()
     cy=uo.gety()
     dir=(cy<y)+2*(cy>y)+4*(cx<x)+8*(cx>x)
     if dir<>0 then
        MoveK(val(M[dir]))
        if cx==uo.getx() && cy==uo.gety() then
           e=e+1
           if e>=2 then
              stack_solving()
           endif
           if e==40 then
              return 0
           endif
          else
             e=0
        endif
     endif
  wend
  return 1
endsub

sub MoveK(dir)
  var x,y,time,Key="06172435"
  if UO.GetDir()<>dir then
     UO.Press(val(Key[dir])+33)
     time=500
     if UO.GetDir()<>dir then
        if time==0 then
           return 0
        endif
        wait(5)
        time=time-5
     endif
  endif
  x=UO.GetX()
  y=UO.GetY()
  time=500
  UO.Press(val(Key[dir])+33)
  while x==UO.GetX() && y==UO.GetY() && time>0
     time=time-5
     wait(5)
  wend
  return time>0   
end sub
sub stack_solving()
        uo.press(38)
        uo.press(38)
        uo.press(37)
   uo.press(37)
   uo.press(38)
        uo.press(38)
        uo.press(39)
        uo.press(39)
end sub



sub main()
lumber()
end sub








Nmy
Expert!
Posts: 2152
Joined: 2005-09-14 15:31:58
Location: Latvia

Post by Nmy »

you mean he saves nothing ? only "1 1 1" ? I guess then you have some errors in script.
if he saves normal numbers with cord. X Y and Z then you have nothing to worry about, the script will walk and chop by those cordinates...
primate
Posts: 3
Joined: 2006-08-02 06:17:59

Post by primate »

yes is saving like this and i can't find the mistake:

Code: Select all

5   #number of trees
1 1 1  #number 1 x y z
1 1 1   #number 2  x y z
1 1 1  #number 3   x y z
1 1 1  #number 4   x y z
1 1 1   #number 5   x y z
 
DIDron
Posts: 54
Joined: 2007-07-09 18:48:42

Post by DIDron »

Ребят переведите етот скрипт пожауйста! первый таргет на Топор, на что надо вешать втрой таргет и он у меня почему то у меня упорно кудато идёт (Camino al arbol 1: x=0 y=0). ПОдскажите что и где мне надо поменять что бы просто рубить !
Post Reply