It looks like you're new here. If you want to get involved, click one of these buttons!
:: Typewriter [script] (function(){ postrender.typewriter = function (b) { if(this.tags){ var r=new RegExp("t8n.typewriter.([0-9]+)(?:[^0-9]|$)","g"); var t=r.exec(this.tags.toString()); if(t){ typeout(b,t[1]+0); } } return b; }; var typeout=function(c,t){ var Furl=function(current){ this.n=current; this.out=false; this.data=current.nodeValue; current.nodeValue=""; this.kids=[]; var cn=current.childNodes; if(current.style && current.style.display=="none"){ return; } while(cn.length>0){ var f=new Furl(cn[0]); current.removeChild(cn[0]); f.out=true; this.kids.push(f); } }; var nodes=new Furl(c); var unfurl=function(furled,d){ var n=furled.n; if(furled.out){ d.appendChild(n); furled.out=false; } if(furled.data){ n.nodeValue+=furled.data[0]; furled.data=furled.data.slice(1); return true; } for(var j=0;j<furled.kids.length;j++){ var ret=unfurl(furled.kids[j],n); if(ret){ return true; } } return false; }; var title=state.active.title; var intr=setInterval(function(){ if(state.active.title==title&&unfurl(nodes,null)){ return; } clearInterval(intr); },t); }; }());
Comments
That's a typewriter effect plus carriage returns without the above script, albeit a bit more fiddly, but useful enough for very short segments of typing.
-where to check for a newline
character,
-best way to manage two different types of setInterval
-How to call sugarcube audio functions from within JavaScript
Sent from phone
That said, you could check for <br> elements instead, which amounts to the same thing, really.
Details?
First. If you only need the audio to trigger at the start of a passage, just use the macros normally. They should work fine, even with your script, since they're processed by the Wikifier before your script ever sees the output buffer.
Second. You don't, currently—at least, not directly anyway*. I suppose that's something I can add to the TODO list.
* I assume you want this for the typing sounds. So, though it's a bit hacky, you could do so via Wikifier calls. For example: