how to uo.print this variable?

Ask for help

Moderators: Murderator+, Murderator

Post Reply
Shokarta
Posts: 19
Joined: 2010-12-01 08:01:12

how to uo.print this variable?

Post by Shokarta »

he guys, I am using a simple walking lumberjack script, which works fine...
but if it gets stuck in the middle i need to go back on the position is started and start over again...
so I wanted to put some ID when i start (so it will ask me where to start)... works fine but if i dont know the ID of the move (variable n in the script) then im fucked...

so al works fine, i can define ID where to start, but I need the script to show me the ID of every move i do

Code: Select all

UO.deletejournal()

n = readnumfromjournal()

while not uo.dead()
  While not (way[n] == "X")
     direction = ""
     While not (way[n] == " ")
        direction = direction + way[n]
        n = n + 1
     Wend
     UO.Print("Action: " + direction + ", ID# " + n)

... blabla ...

end sub

sub WaitForJournal(text)
     repeat
          wait(200)
     until uo.inJournal(text)
     wait(500)
end sub

sub readnumfromjournal()
  uo.deletejournal()
  uo.print("ID to start:")
  uo.click("self")
  repeat
    wait(100)
  until sayi("1|2|3|4|5|6|7|8|9|0")
  var radek = uo.injournal("1|2|3|4|5|6|7|8|9|0")-1

  var m   
  var name = uo.getname("self")
  while name == ""
    uo.click("self")
    wait(1000)
    name = uo.getname("self")
  wend
  uo.print("Starting at ID# " + mid(uo.journal(radek), len(name)+2, 10))
  return val(mid(uo.journal(radek), len(name)+2, 10))
end sub

sub sayi(text)
  if uo.journalserial(uo.injournal(text)-1) == uo.getserial('self') then
    return 1
  else
    return 0
  endif
end sub


when try it shows error "Runtime error - Invalid operation for this type" on row UO.Print("Action: " + direction + ", ID# " + n), well i dont know how to print the n variable

anyway on the row uo.print("Starting at ID# " + mid(uo.journal(radek), len(name)+2, 10)) it actually prints it, just dont know what mid() and len() does, so it could be my second question what those functions does
ZeroDX
Posts: 718
Joined: 2006-12-08 10:51:50
Location: Москва
Contact:

Re: how to uo.print this variable?

Post by ZeroDX »

1) UO.Print("Action: " + direction + ", ID# " + str(n))
2) len returns the length of the string
uo.Print(str(len('1234'))) => 4
uo.Print(str(len('123'))) => 3
3)

Code: Select all

var string = '0123456789'
  uo.print(mid(string, 2, 5))
=> '2345'
Post Reply