mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jun 2014
Posts: 248
B
Fjord artisan
OP Offline
Fjord artisan
B
Joined: Jun 2014
Posts: 248
Code:
alias spell {
  var %word = 1, %letter = 1
  while (%word <= $0) {
    while (%letter <= $len($($+($,%word),2))) {
      sendletter $mid($($+($,%word),2),%letter,1)
      inc %letter
    }
    inc %word
    var %letter 1
  }
}
alias sendletter {
  set %currentpictureline %currentpictureline $+ $1
  drawtext @picture 0 verdana 20 $calc(30 + $width(%currentpictureline,verdana,20)) 30 $1
}
on *:text:*:#belhifet: {
  spell $1-
}


So to start with, yes I really do want it to print one letter at a time.
So this is what I get when someone types "thisisasinglelongword"
http://i.imgur.com/QEI7aiS.png

Obv that means I'm doing something wrong with the width. But I'm not really clear as to what. I can totally sort out the rest of the nonsense in my script, but I'm stumped frown Any help I'd take. Thanks.

Joined: Jul 2006
Posts: 4,149
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,149
$width(t,verdana,20) is 8
drawtext @picture 0 verdana 20 $calc(30 + $width(%currentpictureline,verdana,20)) 30 $1
starts drawing at 30 + 8 = 38 pixels, a letter that is 8 pixels, so that first letter occupies the range 38-(38+8)=38-46 in pixels

$width(th,verdana,20) is 8+13=21
drawtext @picture 0 verdana 20 $calc(30 + $width(%currentpictureline,verdana,20)) 30 $1
draws at 30 + 21 = 51, letter 'h' occupies the range 51-(51+13)=51-64 in pixels

$width(thi,verdana,20) is 8+13+6=27
drawtext @picture 0 verdana 20 $calc(30 + $width(%currentpictureline,verdana,20)) 30 $1
draws at 30 + 27 = 57, letter 'i' occupies the range 57-(57+6)=57-63. previous range was 51-64 so clearly the letter 'i' overlaps the letter 'h'.

The problem is clear here, your starting point for drawing a letter is based on the width of the current letters drawn + 30, where you should be adding 30 for each letter drawn, not just one 30.

Here is a modified example which use 6 pixels between each letter:
Code:
alias spell {
  window -dpf @picture -1 -1 600 400
  ;start at 30 pixels (24 + 6)
  var %word = 1, %letter,%width = 24
  while (%word <= $0) {
    %letter = 1
    while (%letter <= $len($($+($,%word),2))) {
      %width = $sendletter($mid($($+($,%word),2),%letter,1),%width)
      inc %letter
    }
    inc %word
  }
}
alias sendletter {
  drawtext @picture 0 verdana 20 $calc($2 + 6) 30 $1
  return $calc($2 + $width($1,verdana,20) + 6)
}


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Jun 2014
Posts: 248
B
Fjord artisan
OP Offline
Fjord artisan
B
Joined: Jun 2014
Posts: 248
WELL..what you gave me gave me a bunch of overlapped letters. That can't be quite right.

The 30 I was using is just suppose to be the length from the edge I start at, not the distance between the letters.

SOo ok I'ma gonna think outloud.

The indent is 30. T is 8..AHHH THANK YOU

Code:
alias sendletter {  
  drawtext @picture 0 verdana 20 $calc(30 + $width(%currentpictureline,verdana,20)) 30 $1
  set %currentpictureline %currentpictureline $+ $1
}


This *was* in the wrong order.

Joined: Jun 2014
Posts: 248
B
Fjord artisan
OP Offline
Fjord artisan
B
Joined: Jun 2014
Posts: 248
Code:
alias spell {
  var %word = 1, %letter = 1
  while (%word <= $0) {
    while (%letter <= $len($($+($,%word),2))) {
      sendletter $mid($($+($,%word),2),%letter,1)
      inc %letter
    }
    inc %word
    var %letter 1
  }
}
alias sendletter {  
  drawtext @picture 0 verdana 20 $calc(30 + $width(%currentpictureline,verdana,20)) 30 $1
  set %currentpictureline %currentpictureline $+ $1
}
on *:text:*:#belhifet: {
  spell $1-
}


Ok so I want the letters to appear as if they are appearing 1 frame at a time on a old video game console running at 60fps.

So here is the thought. First thing I do when I start the script is set the current time... The more I think about *this* it seems pretty nightmarish. Is there a better way to maybe delay the draw input than millisecond timers?

If not I guess the right place in the code I have to add the timers is drawtext line in the sendletter alias?

Joined: Jul 2006
Posts: 4,149
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,149
Ah ok.
Well if you want to delay the drawing, yes, use a timer smile


#mircscripting @ irc.swiftirc.net == the best mIRC help channel

Link Copied to Clipboard