How to count 345+556

Ask for help

Moderators: Murderator+, Murderator

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

How to count 345+556

Post by Shokarta »

Hey guys, on my shard we got a kind of jail (like a warning before they put you into real jail)
that you have to answer on a mtch questions for like 15 minutes....

question type:
<nick>: How much is 456 + 34?

and got to answer in 3s...

I dont know how to catch those two numbers into variables, so for now i have all that row from journal saved in variable ROW...

and now i need to separate those two numbers to work with that... could anybody help me please?

PS: each of those two numbers can have 1 (x), 2 (xx) or 3 (xxx) digits so i cant realy just set an exact position to cut part of the variable....
Scripts Writer
Posts: 2259
Joined: 2005-04-19 18:00:29
Location: Московская область
Contact:

Re: How to count 345+556

Post by Scripts Writer »

Interesting question if there could be more operators, than '+' (-, *, /).
ZeroDX
Posts: 718
Joined: 2006-12-08 10:51:50
Location: Москва
Contact:

Re: How to count 345+556

Post by ZeroDX »

Парню бы помогли полезности с переведённым описанием)
Shokarta
Posts: 19
Joined: 2010-12-01 08:01:12

Re: How to count 345+556

Post by Shokarta »

so i have done some work which works up to half way

Code: Select all

sub karibik()

  var row
  var num1 = 0
  var num2 = 0
  var i = 0
  var multiply = 1

  uo.deletejournal()

  while NOT uo.injournal("How much is")
    wait(200)
  wend

  row = uo.journal(uo.injournal('How much is')-1)

  while NOT row[i] == "?"
    i = i + 1
  wend

  i = i - 1

repeat
#uo.print(row[i])
  num2 = num2 + (row[i] * multiply)
  i = i - 1
  multiply = multiply * 10
until row[i] == " "

end sub


the variable ROW is "<NICK>: How much is 345+556?"

so if i untag the row uo.print(row[i]) then injection will print into yournal this:
6
5
5

which is GOOD!

but this script has an error BAD OPERATION FOR THIS TYPE OF VARIABLE: NUM2 on row:
num2 = num2 + (row[i] * multiply)

if i try to put a INT() or VAL() in front of row[i] then the error is gonem but uo.print(int(row[i])) or uo.print(val(row[i])) does show NOTHING at all....

so please if anybodyu can correct me?
Scripts Writer
Posts: 2259
Joined: 2005-04-19 18:00:29
Location: Московская область
Contact:

Re: How to count 345+556

Post by Scripts Writer »

Well done, guy. U wrote nice start of script and i just correct this a little and finish. Now it's good calc ;)

Code: Select all

sub karibik()
  var row
  var result = 0
  var i = 0
  var multiply = 1
  uo.deletejournal()
  while NOT uo.injournal("How much is")
    wait(200)
  wend
  row = uo.journal(uo.injournal('How much is')-1)
  while NOT row[i] == "?"
    i = i + 1
    wait(100)
  wend
  i = i - 1
  repeat
    if row[i] <> '+' then
      result = result + (val(row[i]) * multiply)
      multiply = multiply * 10
    else
      multiply = 1
    endif
    wait(500)
    i = i - 1 
  until row[i] == " "
  uo.Print('Result :' + STR(result))
end sub


Image
Post Reply