Page 1 of 1

'bug' or not? [b87]

Posted: Wed Nov 09, 2011 3:37 pm
by wolph42
I was working on my back of tricks and decided to remove the
[h:''] from the [h:'<!-- bla -->'], so you're left with <!-- bla -->, however it turns out that this ports a blank line to the chat. E.g. run this macro

Code: Select all

<!-- Test -->
and you'll notice that a blank line is shown in the chat.

I've been using the [h:] for so long that I don't even know if this is supposed to happen, but obviously this is 'unwanted' behaviour. E.g. in ontokenmove now every time you move a token a blank line is added to the chat...

The main reason to remove the [h:''] is because its significantly faster.

Re: 'bug' or not? [b87]

Posted: Wed Nov 09, 2011 3:56 pm
by aliasmask
Yeah, html comments are still sent to output, but you just don't see them. So, if the comment is in onTokenMove, then you should use the [H: ], but if not and it's a called UDF then you should set it to ignore output. I try to keep the onTokenMove hook as small as possible. By default, all my UDFs have ignore output set.

Code: Select all

@@ @onMultipleTokensMove
[H: ids = macro.args]
[H, if(am.play.doVBLMove(ids)), code: {
   [H: tokens.denyMove = 1]
   [H: am.play.VBLMove(ids)]
};{}]

!!
@@ @onTokenMove
[H: id = currentToken()]
[H, if(tokens.moveCount <= 1 && am.play.doVBLMove(id)), code: {
   [H: tokens.denyMove = 1]
   [H: am.play.VBLMove(id)]
};{}]

!!
@@ @doVBLMove
[H: ids = arg(0)]
[H: doVBLMove = 0]
[H: counter = 0]
<!-- ignore if vision is off for map -->
[H: mapVisionOn =  if(json.get(getInfo("map"),"vision type") != "off",1,0)]
[H, if(json.type(ids) == "ARRAY"): ids = json.toList(ids)]
[H: numIds = listCount(ids)]
[H, while(! doVBLMove && counter < numIds && mapVisionOn), code: {
   [H: id = listGet(ids,counter)]
   [H: switchToken(id)]
   [H: name = lower(getName())]
   <!-- only need one valid token to use VBLMove macro -->
   [H, if(! startsWith(name,"lib:") && ! startsWith(name,"image:")): doVBLMove = 1]
   [H: counter = counter + 1]
}]
[H: macro.return = doVBLMove]

!!
 

Re: 'bug' or not? [b87]

Posted: Wed Nov 09, 2011 5:01 pm
by wolph42
Yup I've changed it back, but I thought I mentioned it.

Re: 'bug' or not? [b87]

Posted: Wed Nov 09, 2011 5:24 pm
by CoveredInFish
Yeah, this is expected behaviour. Days ago any macro would cause an output line to appear. Then one lone but knowadays forgotten hero appeared and he mangled some code so that macro creating no output were from now on hindered to cause that line. The hero was wise and great but he couldnt see the difference between output and comments as before the html parser all was one.

Re: 'bug' or not? [b87]

Posted: Wed Nov 09, 2011 11:19 pm
by Winter
Thanks much for the information about the blank output line and the caution about the size of onTokenMove calls. It'll help keep my framework clean and responsive.

Re: 'bug' or not? [b87]

Posted: Wed Nov 09, 2011 11:23 pm
by Azhrei
CoveredInFish wrote:Then one lone but knowadays forgotten hero appeared [...]
Help us, Obiwan Kenobi. You're our only hope.