-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.tw
4708 lines (3434 loc) · 221 KB
/
index.tw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
:: Start [center fade4]
! 5:43am
<<timedcontinue 1s>> First Cycle, 2037
<<timedgoto "wakeup" 4s>>
:: replace [script]
(function(){version.extensions.replaceMacrosCombined={major:1,minor:1,revision:7};var nullobj={handler:function(){}};function showVer(n,notrans){if(!n){return;}n.innerHTML="";
new Wikifier(n,n.tweecode);n.setAttribute("data-enabled","true");n.style.display="inline";n.classList.remove("revision-span-out");if(!notrans){n.classList.add("revision-span-in");
if(n.timeout){clearTimeout(n.timeout);}n.timeout=setTimeout(function(){n.classList.remove("revision-span-in");n=null;},20);}}function hideVer(n,notrans){if(!n){return;
}n.setAttribute("data-enabled","false");n.classList.remove("revision-span-in");if(n.timeout){clearTimeout(n.timeout);}if(!notrans){n.classList.add("revision-span-out");
n.timeout=setTimeout(function(){if(n.getAttribute("data-enabled")=="false"){n.classList.remove("revision-span-out");n.style.display="none";n.innerHTML="";}n=null;
},1000);}else{n.style.display="none";n.innerHTML="";n=null;}}function tagcontents(b,starttags,desttags,endtags,k){var l=0,c="",tg,a,i;function tagfound(i,e,endtag){for(var j=0;
j<e.length;j++){if(a.indexOf("<<"+e[j]+(endtag?">>":""),i)==i){return e[j];}}}a=b.source.slice(k);for(i=0;i<a.length;i++){if(tg=tagfound(i,starttags)){l++;}else{if((tg=tagfound(i,desttags,true))&&l==0){b.nextMatch=k+i+tg.length+4;
return[c,tg];}else{if(tg=tagfound(i,endtags,true)){l--;if(l<0){return null;}}}}c+=a.charAt(i);}return null;}var begintags=[];var endtags=[];function revisionSpanHandler(g,e,f,b){var k=b.source.indexOf(">>",b.matchStart)+2,vsns=[],vtype=e,flen=f.length,becomes,c,cn,m,h,vsn;
function mkspan(vtype){h=insertElement(m,"span",null,"revision-span "+vtype);h.setAttribute("data-enabled",false);h.style.display="none";h.tweecode="";return h;}if(this.shorthand&&flen){while(f.length>0){vsns.push([f.shift(),(this.flavour=="insert"?"gains":"becomes")]);
}}else{if(this.flavour=="insert"||(this.flavour=="continue"&&this.trigger=="time")){vsns.push(["","becomes"]);}}if(this.flavour=="continue"&&flen){b.nextMatch=k+b.source.slice(k).length;
vsns.push([b.source.slice(k),vtype]);}else{becomes=["becomes","gains"];c=tagcontents(b,begintags,becomes.concat(endtags),endtags,k);if(c&&endtags.indexOf(c[1])==-1){while(c){vsns.push(c);
c=tagcontents(b,begintags,becomes,endtags,b.nextMatch);}c=tagcontents(b,begintags,["end"+e],endtags,b.nextMatch);}if(!c){throwError(g,"can't find matching end"+e);
return;}vsns.push(c);if(this.flavour=="continue"){k=b.nextMatch;b.nextMatch=k+b.source.slice(k).length;vsns.push([b.source.slice(k),""]);}}if(this.flavour=="remove"){vsns.push(["","becomes"]);
}cn=0;m=insertElement(g,"span",null,e);m.setAttribute("data-flavour",this.flavour);h=mkspan("initial");vsn=vsns.shift();h.tweecode=vsn[0];showVer(h,true);while(vsns.length>0){if(vsn){vtype=vsn[1];
}vsn=vsns.shift();h=mkspan(vtype);h.tweecode=vsn[0];}if(typeof this.setup=="function"){this.setup(m,g,f);}}function quantity(m){return(m.children.length-1)+(m.getAttribute("data-flavour")=="remove");
}function revisionSetup(m,g,f){m.className+=" "+f[0].replace(" ","_");}function keySetup(m,g,f){var key=f[0];m.setEventListener("keydown",function l(e){var done=!revise("revise",m);
if(done){m.removeEventListener("keydown",l);}});}function timeSetup(m,g,f){function cssTimeUnit(s){if(typeof s=="string"){if(s.slice(-2).toLowerCase()=="ms"){return Number(s.slice(0,-2))||0;
}else{if(s.slice(-1).toLowerCase()=="s"){return Number(s.slice(0,-1))*1000||0;}}}throwError(g,s+" isn't a CSS time unit");return 0;}var tm=cssTimeUnit(f[0]);var s=state.history[0].passage.title;
setTimeout(function timefn(){if(state.history[0].passage.title==s){var done=!revise("revise",m);if(!done){setTimeout(timefn,tm);}}},tm);}function hoverSetup(m){var fn,noMouseEnter=(document.head.onmouseenter!==null),m1=m.children[0],m2=m.children[1],gains=m2.className.indexOf("gains")>-1;
if(!m1||!m2){return;}m1.onmouseenter=function(e){var efp=document.elementFromPoint(e.clientX,e.clientY);while(efp&&efp!==this){efp=efp.parentNode;}if(!efp){return;
}if(this.getAttribute("data-enabled")!="false"){revise("revise",this.parentNode);}};m2.onmouseleave=function(e){var efp=document.elementFromPoint(e.clientX,e.clientY);
while(efp&&efp!==this){efp=efp.parentNode;}if(efp){return;}if(this.getAttribute("data-enabled")!="false"){revise("revert",this.parentNode);}};if(gains){m1.onmouseleave=m2.onmouseleave;
}if(noMouseEnter){fn=function(n){return function(e){if(!event.relatedTarget||(event.relatedTarget!=this&&!(this.compareDocumentPosition(event.relatedTarget)&Node.DOCUMENT_POSITION_CONTAINED_BY))){this[n]();
}};};m1.onmouseover=fn("onmouseenter");m2.onmouseout=fn("onmouseleave");if(gains){m1.onmouseout=m2.onmouseout;}}m=null;}function mouseSetup(m){var evt=(document.head.onmouseenter===null?"onmouseenter":"onmouseover");
m[evt]=function(){var done=!revise("revise",this);if(done){this[evt]=null;}};m=null;}function linkSetup(m,g,f){var l=Wikifier.createInternalLink(),p=m.parentNode;
l.className="internalLink replaceLink";p.insertBefore(l,m);l.insertBefore(m,null);l.onclick=function(){var p,done=false;if(m&&m.parentNode==this){done=!revise("revise",m);
scrollWindowTo(m);}if(done){this.parentNode.insertBefore(m,this);this.parentNode.removeChild(this);}};l=null;}function visitedSetup(m,g,f){var i,done,shv=state.history[0].variables,os="once seen",d=(m.firstChild&&(this.flavour=="insert"?m.firstChild.nextSibling:m.firstChild).tweecode);
shv[os]=shv[os]||{};if(d&&!shv[os].hasOwnProperty(d)){shv[os][d]=1;}else{for(i=shv[os][d];i>0&&!done;i--){done=!revise("revise",m,true);}if(shv[os].hasOwnProperty(d)){shv[os][d]+=1;
}}}[{name:"insert",flavour:"insert",trigger:"link",setup:linkSetup},{name:"timedinsert",flavour:"insert",trigger:"time",setup:timeSetup},{name:"insertion",flavour:"insert",trigger:"revisemacro",setup:revisionSetup},{name:"later",flavour:"insert",trigger:"visited",setup:visitedSetup},{name:"keyinsert",flavour:"insert",trigger:"key",setup:keySetup},{name:"replace",flavour:"replace",trigger:"link",setup:linkSetup},{name:"timedreplace",flavour:"replace",trigger:"time",setup:timeSetup},{name:"mousereplace",flavour:"replace",trigger:"mouse",setup:mouseSetup},{name:"hoverreplace",flavour:"replace",trigger:"hover",setup:hoverSetup},{name:"revision",flavour:"replace",trigger:"revisemacro",setup:revisionSetup},{name:"keyreplace",flavour:"replace",trigger:"key",setup:keySetup},{name:"timedremove",flavour:"remove",trigger:"time",setup:timeSetup},{name:"mouseremove",flavour:"remove",trigger:"mouse",setup:mouseSetup},{name:"hoverremove",flavour:"remove",trigger:"hover",setup:hoverSetup},{name:"removal",flavour:"remove",trigger:"revisemacro",setup:revisionSetup},{name:"once",flavour:"remove",trigger:"visited",setup:visitedSetup},{name:"keyremove",flavour:"remove",trigger:"key",setup:keySetup},{name:"continue",flavour:"continue",trigger:"link",setup:linkSetup},{name:"timedcontinue",flavour:"continue",trigger:"time",setup:timeSetup},{name:"mousecontinue",flavour:"continue",trigger:"mouse",setup:mouseSetup},{name:"keycontinue",flavour:"continue",trigger:"key",setup:keySetup},{name:"cycle",flavour:"cycle",trigger:"revisemacro",setup:revisionSetup},{name:"mousecycle",flavour:"cycle",trigger:"mouse",setup:mouseSetup},{name:"timedcycle",flavour:"cycle",trigger:"time",setup:timeSetup},{name:"keycycle",flavour:"replace",trigger:"key",setup:keySetup}].forEach(function(e){e.handler=revisionSpanHandler;
e.shorthand=(["link","mouse","hover"].indexOf(e.trigger)>-1);macros[e.name]=e;macros["end"+e.name]=nullobj;begintags.push(e.name);endtags.push("end"+e.name);});function insideDepartingSpan(elem){var r=elem.parentNode;
while(!r.classList.contains("passage")){if(r.classList.contains("revision-span-out")){return true;}r=r.parentNode;}}function reviseAll(rt,rname){var rall=document.querySelectorAll(".passage [data-flavour]."+rname),ret=false;
for(var i=0;i<rall.length;i++){if(!insideDepartingSpan(rall[i])){ret=revise(rt,rall[i])||ret;}}return ret;}function revise(rt,r,notrans){var ind2,curr,next,ind=-1,rev=(rt=="revert"),rnd=(rt.indexOf("random")>-1),fl=r.getAttribute("data-flavour"),rc=r.childNodes,cyc=(fl=="cycle"),rcl=rc.length-1;
function doToGainerSpans(n,fn){for(var k=n-1;k>=0;k--){if(rc[k+1].classList.contains("gains")){fn(rc[k],notrans);}else{break;}}}for(var k=0;k<=rcl;k++){if(rc[k].getAttribute("data-enabled")=="true"){ind=k;
}}if(rev){ind-=1;}curr=(ind>=0?rc[ind]:(cyc?rc[rcl]:null));ind2=ind;if(rnd){ind2=(ind+(Math.floor(Math.random()*rcl)))%rcl;}next=((ind2<rcl)?rc[ind2+1]:(cyc?rc[0]:null));
var docurr=(rev?showVer:hideVer);var donext=(rev?hideVer:showVer);var currfn=function(){if(!(next&&next.classList.contains("gains"))||rnd){docurr(curr,notrans);doToGainerSpans(ind,docurr,notrans);
}};var nextfn=function(){donext(next,notrans);if(rnd){doToGainerSpans(ind2+1,donext,notrans);}};if(!rev){currfn();nextfn();}else{nextfn();currfn();}return(cyc?true:(rev?(ind>0):(ind2<rcl-1)));
}macros.revert=macros.revise=macros.randomise=macros.randomize={handler:function(a,b,c){var l,rev,rname;function disableLink(l){l.style.display="none";}function enableLink(l){l.style.display="inline";
}function updateLink(l){if(l.className.indexOf("random")>-1){enableLink(l);return;}var rall=document.querySelectorAll(".passage [data-flavour]."+rname),cannext,canprev,i,ind,r,fl;
for(i=0;i<rall.length;i++){r=rall[i],fl=r.getAttribute("data-flavour");if(insideDepartingSpan(r)){continue;}if(fl=="cycle"){cannext=canprev=true;}else{if(r.firstChild.getAttribute("data-enabled")==!1+""){canprev=true;
}if(r.lastChild.getAttribute("data-enabled")==!1+""){cannext=true;}}}var can=(l.classList.contains("revert")?canprev:cannext);(can?enableLink:disableLink)(l);}function toggleText(w){w.classList.toggle(rl+"Enabled");
w.classList.toggle(rl+"Disabled");w.style.display=((w.style.display=="none")?"inline":"none");}var rl="reviseLink";if(c.length<2){throwError(a,b+" macro needs 2 parameters");
return;}rname=c.shift().replace(" ","_");l=Wikifier.createInternalLink(a,null);l.className="internalLink "+rl+" "+rl+"_"+rname+" "+b;var v="";var end=false;var out=false;
if(c.length>1&&c[0][0]=="$"){v=c[0].slice(1);c.shift();}switch(c[c.length-1]){case"end":end=true;c.pop();break;case"out":out=true;c.pop();break;}var h=state.history[0].variables;
for(var i=0;i<c.length;i++){var on=(i==Math.max(c.indexOf(h[v]),0));var d=insertElement(null,"span",null,rl+((on)?"En":"Dis")+"abled");if(on){h[v]=c[i];l.setAttribute("data-cycle",i);
}else{d.style.display="none";}insertText(d,c[i]);l.appendChild(d);}l.onclick=function(){reviseAll(b,rname);var t=this.childNodes,u=this.getAttribute("data-cycle")-0,m=t.length,n,lall,i;
if((end||out)&&u>=m-(end?2:1)){if(end){n=this.removeChild(t[u+1]||t[u]);n.className=rl+"End";n.style.display="inline";this.parentNode.replaceChild(n,this);}else{this.parentNode.removeChild(this);
return;}}else{toggleText(t[u]);u=(u+1)%m;if(v){h[v]=c[u];}toggleText(t[u]);this.setAttribute("data-cycle",u);}lall=document.getElementsByClassName(rl+"_"+rname);
for(i=0;i<lall.length;i++){updateLink(lall[i]);}};disableLink(l);setTimeout((function(l){return function(){updateLink(l);};}(l)),1);l=null;}};macros.mouserevise=macros.hoverrevise={handler:function(a,b,c,d){var endtags=["end"+b],evt=(window.onmouseenter===null?"onmouseenter":"onmouseover"),t=tagcontents(d,[b],endtags,endtags,d.source.indexOf(">>",d.matchStart)+2);
if(t){var rname=c[0].replace(" ","_"),h=insertElement(a,"span",null,"hoverrevise hoverrevise_"+rname),f=function(){var done=!reviseAll("revise",rname);if(b!="hoverrevise"&&done){this[evt]=null;
}};new Wikifier(h,t[0]);if(b=="hoverrevise"){h.onmouseover=f;h.onmouseout=function(){reviseAll("revert",rname);};}else{h[evt]=f;}h=null;}}};macros.instantrevise={handler:function(a,b,c,d){reviseAll("revise",c[0].replace(" ","_"));
}};macros.endmouserevise=nullobj;macros.endhoverrevise=nullobj;}());
:: Untitled Stylesheet 1 [stylesheet center]
.passage {
text-align: center;
}
:: cellphone [stylesheet cell]
/* Your story will use the CSS in this passage to style the page.
Give this passage more tags, and it will only affect passages with those tags.
Example selectors: */
body {
background: #121212;
}
.passage {
color: #fff;
background: radial-gradient(ellipse at center, rgba(1,123,136,0.5) 0%, rgb(17,17,17) 70%);
overflow: hidden;
padding-top: 10px;
}
.passage span a {
border: 0px;
border-radius: 0px;
margin-top: 0px;
margin-bottom: 0px;
font-size: 24px;
}
.Chat-message {
background: rgba(17,17,17,0.05);
padding: 9px;
border-radius: 10px;
border-bottom: 2px solid #324931;
margin-bottom: 5px;
transition: visiblity 0.5s ease-in, opacity 0.3s ease-in;
}
.cellphone, .cellphone1 {
cursor: [img[cursor2]] 0 0, auto;
margin: 0 auto;
top: 2px;
width: 40%;
height: 450px;
border: 8px solid #121212;
border-radius: 20px;
color: #324931;
background-color: #9ED5B5;
overflow: scroll;
padding: 20px;
}
.scanlines::before {
content: " ";
position: absolute;
top: 20px;
left: 243px;
bottom: 68px;
right: 236px;
background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
z-index: 2;
background-size: 100% 2px, 3px 100%;
pointer-events: none;
border-radius: 10px;
}
.passage {
/* This only affects passages */
font-family: nokiafc22;
font-size: 12px;
}
.passage a {
/* This affects passage links */
display: block;
text-align: center;
border: 3px solid #324931;
border-radius: 5px;
background-color: #324931;
color: #9ED5B5;
margin-top: 2px;
margin-bottom: 2px;
cursor: [img[pointer2]] 0 0, auto;
}
.passage a:hover{
color: #9ED5B5;
text-decoration: none;
animation: shake 0.5s cubic-bezier(.36,.07,.19,.97) both;
animation-fill-mode: forwards;
}
@keyframes shake {
from {
transform: scale(1,1);
}
to {
transform: scale(1.05, 1.05);
}
:: y1local3a [layout yellow]
<img src="img/local_y.gif" height="422"/> <<display inv>>
<p class="bottom"><<timedcontinue 1s>>Yes, of course I knew her. <<timedcontinue 1s>> We were working together. <<timedcontinue 1s>>
[[Doing what?|y1local3b]]</p>
:: y1start2 [layout yellow]
<img src="img/local_y.gif" height="422"/> <<display inv>>
<p class="bottom"><<timedcontinue 1s>>I'm awake? <<timedcontinue 2s>> That can't be right. <<timedcontinue 1s>> This isn't my body. Or... <<timedcontinue 3s>>
[[Or?|y1start3]]</p>
:: y1start3 [layout yellow]
<img src="img/local_y.gif" height="422"/> <<display inv>>
<p class="bottom"><<timedcontinue 1s>>Or at least, <<timedcontinue 1s>>I'm pretty sure it isn't. <<timedcontinue 1s>>Did I even have a body? Everything is all fucking <<timedcontinue 1s>>- jumbled up. <<timedcontinue 2s>><div class="next">[img[arrowtest][y1start3a]]</div></p>
:: y1start4 [layout yellow]
<img src="img/local_y.gif" height="422"/> <<display inv>>
<p class="bottom"><<timedcontinue 1s>> I'm okay. I'm <<timedcontinue 2s>> -- I feel sick. <<timedcontinue 2s>>Not sick. <<timedcontinue 3s>> I know I don't know what sick is.<<timedcontinue 2s>><div class="next">[img[arrowtest][y1start4a]]</div></p>
:: y1start5 [layout yellow]
<img src="img/local_y.gif" height="422"/> <<display inv>>
<p class="bottom"><<timedcontinue 1s>>You're no help. <<timedcontinue 1s>> What body is this? <<timedcontinue 2s>>
[["LOC-192." That's the serial code.|y1start6]]</p>
:: y1start [layout yellow firstload]
<<set $drivevisit += 1>> <<fadeinsound "aud/yellow.mp3">> <img src="img/local_y.gif" height="422"/> <<display inv>>
<p class="bottom">Whoa. <<timedcontinue 1s>> Whoa. <<timedcontinue 2s>> Okay. <<timedcontinue 2s>> Don't do that again. Whatever it was. <<timedcontinue 1s>> Hold on.
<<timedcontinue 1s>>
[[What?|y1start2]]</p>
:: y1start6 [layout yellow]
<img src="img/local_y.gif" height="422"/> <<display inv>>
<p class="bottom"><<timedcontinue 1s>>LOC-192. <<timedcontinue 1s>> LOC. <<timedcontinue 2s>> I've heard that. <<timedcontinue 2s>> Hold on, that's Local. <<timedcontinue 2s>>
[[Local?|y1start7]]</p>
:: y1start7 [layout yellow]
<img src="img/local_y.gif" height="422"/> <<display inv>>
<p class="bottom"><<timedcontinue 1s>>Can you stop <<timedcontinue 1s>>just <<timedcontinue 2s>>repeating whatever I say?<<timedcontinue 2s>> It's really annoying. <<timedcontinue 1s>> Why'd you put me in Local's body <<timedcontinue 2s>>-- wait.
<<timedcontinue 2s>><div class="next">[img[arrowtest][y1start7a]]</div></p>
:: y1local3b [layout yellow]
<img src="img/local_y.gif" height="422"/> <<display inv>>
<p class="bottom">You don't know much, huh? <<timedcontinue 1s>> Local was an assistant to the boss. <<timedcontinue 1s>>
[[Your boss?|y1local3c]]</p>
:: y1local3c [layout yellow]
<img src="img/local_y.gif" height="422"/> <<display inv>>
<p class="bottom"><<timedcontinue 1s>>No, not my boss. <<timedcontinue 1s>> Her boss. <<timedcontinue 1s>> They broke down the bodies and made new things to sell.<<timedcontinue 2s>><div class="next">[img[arrowtest][y1local3d]]</div></p>
:: y1local3d [yellow layout]
<img src="img/local_y.gif" height="422"/> <<display inv>>
<p class="bottom"><<timedcontinue 1s>>I just did delivery. <<timedcontinue 2s>>If they needed parts picked up from somewhere...<<timedcontinue 1s>>well, somewhere like this. <<timedcontinue 1s>>
[[Wait, bodies? Whose bodies?|y1local3e]]
</p>
:: y1local3f [layout yellow]
<<set $y1local to 1>> <img src="img/local_y.gif" height="422"/> <<display inv>>
<p class="bottom"><<timedcontinue 1s>>Guts, parts, <<timedcontinue 1s>>whatever you want to call them.<<timedcontinue 1s>>
You're not good at this, are you?<<timedcontinue 1s>>
[[I'm just trying to figure out what I'm doing.|y1hub1]]</p>
:: y1local [yellow layout]
<img src="img/local_y.gif" height="422"/> <<display inv>>
<p class="bottom"><<timedcontinue 1s>>Well, this is her body. <<timedcontinue 2s>> I'd think you would know.<<timedcontinue 1s>>
[[Well, I don't.|y1local2a]]
[[You knew her?|y1local3a]]
</p>
:: y1local3e [layout yellow]
<img src="img/local_y.gif" height="422"/> <<display inv>>
<p class="bottom"><<timedcontinue 1s>>You know. <<timedcontinue 1s>>Any body. Plastic, silicon, whatever. <<timedcontinue 2s>> You've got tons of them here. <<timedcontinue 1s>>And lots of guts.
[[By guts, do you mean...|y1local3f]]</p>
:: yellowload
<<fadeoutsound "aud/workspace.mp3">> <img id="screamyellow" class="scream"/> <<set $menu to 0>> <<set $yellow to 1>> <<set $playmusicyellow to 1>>
<<if $y2fin is 1>><<timedgoto "y3Start" 4s>><<else if $y1fin is 1>><<timedgoto "y2Start" 4s>><<elseif visited("y1hub1") and $y1fin is 0>><<timedgoto "y1hub1" 4s>> <<else>><<timedgoto "y1start" 4s>><<endif>>
<<silently>>
<<if (function() {
setTimeout(function() {
document.querySelector('#screamyellow').src =
'img/scream_yellow.gif?cachebust=' +
Math.round(Math.random() * 10000000000);
});
}())>>
<<endif>>
<<endsilently>>
<<timedcontinue 1s>> <<playsound "aud/scream-1.mp3">>
:: audio [script]
/*
sqTwineSound HTML5 Sound Macro Suite
Copyright 2014 Tory Hoke
Program URI: http://www.sub-q.com/plugins/sqTwineSound/
Description: Sound macros for Twine creations, including controls for volume, fade interval, and playing multiple tracks at once.
Version: 0.8.0
Author: Tory Hoke
Author URI: http://www.toryhoke.com
License: GNU General Public License
License URI: http://www.opensource.org/licenses/gpl-license.php
Repository: https://github.com/AteYourLembas/sqTwineSound
FAQ / Q & A: http://sub-q.com/questions (password: ThinkVast)
Bug Reports/Feature Requests: http://sub-q.com/forums/topic/what-would-you-like-to-see-sqtwinesound-do-that-its-not-doing/ (password: ThinkVast)
sub-Q.com is password-protected while it's in beta (until January 2015.)
Please kick the tires and report any issues with the website
via the sub-Q.com Contact form.
This program based on:
Twine: HTML5 sound macros by Leon Arnott of Glorious Trainwrecks
the source and influence of which appear under a Creative Commons CC0 1.0 Universal License
This program uses
easeInOutSine()
Copyright © 2001 Robert Penner
All rights reserved.
As distributed by Kirupa
http://www.kirupa.com/forum/showthread.php?378287-Robert-Penner-s-Easing-Equations-in-Pure-JS-(no-jQuery)
Open source under the BSD License.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of
conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list
of conditions and the following disclaimer in the documentation and/or other materials
provided with the distribution.
Neither the name of the author nor the names of contributors may be used to endorse
or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
OF THE POSSIBILITY OF SUCH DAMAGE.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*/
(function () {
version.extensions.soundMacros = {
major: 0,
minor: 8,
revision: 0
};
var globalVolume = 1.0;
var updateInterval = 10; //Update sound volume, etc. once every 10 ms
var defaultOverlap = 1000; //Default track overlap is 1000 ms
var minVolume = 0.01; // Minimum possible volume -- 0 is mute, so we want somethings slightly above that
var soundInterval = 0.1; // Creates an interval of 1/10 creates ten stages of loudness. Used by quieter/louder. Feel free to tweak
var fileExtensions = ["ogg", "mp3", "wav", "webm"]; // Acceptable file extensions for audio
var clips = {};
// Convenience vars
var clipNameLabel = "Clip Name";
var overlapLabel = "Overlap";
var volumeProportionLabel = "Volume Proportion";
var loopLabel = "Loop?";
//------------ Robert Penner via Kirupa math methods ----------
//-------------------------------------------------------------
function easeInOutSine(currentIteration, startValue, changeInValue, totalIterations) {
return changeInValue / 2 * (1 - Math.cos(Math.PI * currentIteration / totalIterations)) + startValue;
}
//------------ End Math methods -------------------------------
//-------------------------------------------------------------
function error(message) {
return throwError(message);
}
function getArgs(givenArgs) {
var args = Array.prototype.slice.call(givenArgs);
//alert(" split args " + args);
//alert("typeof " + typeof(givenArgs[givenArgs.length-1]));
//alert(givenArgs[givenArgs.length-1].fullArgs());
var tempArgs = [];
if (args.length > 2) {
tempArgs = args[2].toString().split(",");
}
for (var i = 0; i < tempArgs.length; i++) {
if (typeof(tempArgs[i]) == "string" && tempArgs[i].indexOf("$") === 0) {
var varName = tempArgs[i].slice(1, tempArgs[i].length);
if (state.history[0].variables.hasOwnProperty(varName)) tempArgs[i] = state.history[0].variables[varName];
}
}
return tempArgs;
}
//------------- pausableTimeout ---------
//--------------------------------------
function pausableTimeout(func, params) {
this.funcToRun = func;
this.waitStartTime = -1;
this.waitEndTime = -1;
this.waitDuration = -1;
this.activate = function(waitDuration) {
if (this.pausedAt !== undefined) { this.waitDuration = this.timeRemaining(); }
else if (waitDuration !== undefined) this.waitDuration = waitDuration;
else if (this.waitDuration > -1 ) { console.log("Warning: No wait duration given to pausableTimeout. Using last specified one."); }
else return; // Don't bother to start a loop with no wait duration
this.waitStartTime = new Date().getTime();
this.waitEndTime = new Date().getTime() + this.waitDuration;
this.timeout = setTimeout(this.funcToRun, this.waitDuration, params);
};
this.deactivate = function() {
this.pausedAt = this.timeElapsed();
if (this.timeout !== undefined) clearTimeout(this.timeout);
};
this.stopAndClear = function() {
if (this.pausedAt !== undefined) delete this.pausedAt;
if (this.timeout !== undefined) { clearTimeout(this.timeout); delete this.timeout; }
};
this.timeElapsed = function() {
return new Date().getTime() - this.waitStartTime;
};
this.timeRemaining = function() {
if (this.pausedAt !== undefined) return this.waitDuration - this.pausedAt;
return this.waitEndTime - new Date().getTime();
};
}
//------------- /pausableTimeout --------
//--------------------------------------
//------------- sqAudio ----------------
//--------------------------------------
function sqAudio(fullPath, clipName, fileExt) {
this.fullPath = fullPath;
this.clipName = clipName; // Let a clip know its own name
this.fileExt = fileExt;
// Defaults
this.volumeProportion = 1.0; // By default, full volume
this.overlap = defaultOverlap; // By default, defaultOverlap ms
this.isPlayable = false; // Assume audio is not playable
this.looping = false; // Assume audio not looping
this.alternate = false;
this.mainAudio = new Audio();
this.partnerAudio = new Audio();
this.mainAudio.setAttribute("src", this.fullPath);
if (this.mainAudio.canPlayType) {
for (var i = -1; i < fileExtensions.length; i += 1) {
if (i >= 0) fileExt = fileExtensions[i];
if (this.mainAudio.canPlayType("audio/" + fileExt)) break;
}
if (i < fileExtensions.length) {
this.mainAudio.interval = null;
this.partnerAudio.setAttribute("src", this.fullPath);
this.partnerAudio.interval = null;
this.isPlayable = true;
} else {
console.log("Browser can't play '" + this.clipName + "'");
}
}
// Convenience method for getting duration
// TODO : protect this against audio not being loaded yet
//
this.getDuration = function () {
return this.mainAudio.duration;
};
// Get what we consider the current audio track
//
this._getActiveAudio = function() {
return (this.alternate) ? this.partnerAudio : this.mainAudio;
};
// Get what we consider the idle audio track
//
this._getIdleAudio = function() {
return (this.alternate) ? this.mainAudio : this.partnerAudio;
};
// Perform fade on specified audio
// Use ease
//
this.__fadeSound = function(audioObj, fadeIn) {
var startVolume = fadeIn ? 0 : globalVolume * this.volumeProportion;
var deltaVolume = globalVolume * this.volumeProportion * (fadeIn ? 1 : -1);
//alert("__fadeSound! fadeIn " + fadeIn + ", globalVolume " + globalVolume + ", volProp " + this.volumeProportion + " startVol " + startVolume + " deltaVolume " + deltaVolume);
// Handy vars for easing
var totalIterations = this.overlap/updateInterval;
var currentIteration = 1;
audioObj.interval = setInterval(function() {
//Use easing to prevent sound popping in or out
//
var desiredVolume = easeInOutSine(currentIteration, startVolume, deltaVolume, totalIterations);
//alert("Well desiredVol is " + desiredVolume + " cos currIter " + currentIteration + " startVol " + startVolume + " delta vol " + deltaVolume + " total iter " + totalIterations);
//This should never happen, but if it does, skip the fade
if (isNaN(desiredVolume)) {
audioObj.volume = startVolume + deltaVolume;
console.log("There was a problem with the fade. Possibly overlap " + this.overlap + " is shorter than updateInterval " + updateInterval + "? ");
} else {
audioObj.volume = desiredVolume;
}
currentIteration += 1;
if (audioObj.volume === (startVolume + deltaVolume)) {
//alert("Grats! You reached your destination of " + audioObj.volume);
clearInterval(audioObj.interval);
}
//This effectively stops the loop and poises the volume to be played again
//That way the clip isn't needlessly looping when no one can hear it.
if (audioObj.volume === 0) {
audioObj.pause();
audioObj.currentTime = 0;
}
}, updateInterval);
};
// Manages starting one loop before the last play has ended
// and cross-fading the ends
//
this._crossfadeLoop = function(params) {
var sqAudioObj = params[0];
var currAudioObj = params[1];
// Let loop expire if no longer looping
//
if (!sqAudioObj.looping) { return; }
var nextAudioObj = sqAudioObj.alternate ? sqAudioObj.mainAudio : sqAudioObj.partnerAudio;
sqAudioObj.alternate = !sqAudioObj.alternate;
// Don't even bother with crossfade if there's no overlap
if (sqAudioObj.overlap !== undefined && sqAudioObj.overlap > 1) {
// fade out current sound
//
sqAudioObj._fadeSound(currAudioObj, false);
// And fade in our partner
//
//nextAudioObj.volume = 0;
//if (nextAudioObj.currentTime > 0) nextAudioObj.currentTime = 0;
//nextAudioObj.play();
sqAudioObj._fadeSound(nextAudioObj, true);
}
else {
sqAudioObj.updateVolume();
nextAudioObj.currentTime = 0;
nextAudioObj.play();
}
// Kick off the next timer to crossfade
// Might as well garbage collect the old crossfadeTimeout, too.
//
//if (sqAudioObj.crossfadeTimeout !== undefined) { sqAudioObj.crossfadeTimeout.stopAndClear(); delete sqAudioObj.crossfadeTimeout; }
//if (isNaN(sqAudioObj.getDuration())) { error("Can't loop because duration is not known (audio not loaded, probably not found.)"); return; }
//sqAudioObj.crossfadeTimeout = new pausableTimeout(sqAudioObj._crossfadeLoop, [sqAudioObj, nextAudioObj]);
//sqAudioObj.crossfadeTimeout.activate(sqAudioObj.getDuration()*1000-sqAudioObj.overlap);
};
this._fadeSound = function(activeAudioObj, fadeIn) {
// Set the goal volume as a proportion of the global volume
// (e.g. if global volume is 0.4, and volume proportion is 0.25, overall the goal volume is 0.1)
//
var goalVolume = globalVolume * this.volumeProportion;
if (activeAudioObj.interval) clearInterval(activeAudioObj.interval);
if (fadeIn) {
if (activeAudioObj.currentTime > 0) activeAudioObj.currentTime = 0;
activeAudioObj.volume = 0;
this.loop();
} else {
if (!activeAudioObj.currentTime) return;
activeAudioObj.volume = goalVolume;
activeAudioObj.play();
}
this.__fadeSound(activeAudioObj, fadeIn);
};
// Fade sound on whatever the active audio is
//
this.fadeSound = function(fadeIn) {
if (fadeIn) {
this.stopAndClear();
this.looping = true;
}
else {
this.looping = false;
}
this._fadeSound(this._getActiveAudio(), fadeIn);
};
// Update volume proportion and volume of both audio clips
//
this.setVolumeProportion = function(volumeProportion) {
this.volumeProportion = volumeProportion;
};
// Update volume of active audio clips (assumes vol proportion and global vol already set)
//
this.updateVolume = function() {
this._getActiveAudio().volume = globalVolume * this.volumeProportion;
};
// Play the current audio object and reactivate any paused timer
//
this.play = function(loop) {
//If it's a loop we want, just loop and don't make a big deal out of it
if (loop) this.loop();
else {
var activeAudioObj = this._getActiveAudio();
if (activeAudioObj) {
activeAudioObj.play();
}
}
};
// Pause whatever audio is currently playing and pause the timer, too
//
this.pause = function() {
if (this.crossfadeTimeout !== undefined) this.crossfadeTimeout.deactivate();
this._getActiveAudio().pause();
};
// Stop whatever audio is currently playing and dump the timer
//
this.stopAndClear = function() {
var activeAudioObj = this._getActiveAudio();
activeAudioObj.pause();
if (activeAudioObj.currentTime > 0) activeAudioObj.currentTime = 0;
if (this.crossfadeTimeout !== undefined) { this.crossfadeTimeout.stopAndClear(); delete this.crossfadeTimeout; }
};
// Loop the track
//
this.loop = function() {
this.looping = true;
var activeAudioObj = this._getActiveAudio();
// Create new timeout if one does not already exist; otherwise just reuse the existing one
//
this.crossfadeTimeout = (this.crossfadeTimeout === undefined) ? new pausableTimeout(this._crossfadeLoop, [this, activeAudioObj]) : this.crossfadeTimeout;
if (isNaN(this.getDuration())) { error("Can't loop because duration is not known (audio not loaded, probably not found.)"); return; }
this.crossfadeTimeout.activate((this.getDuration()*1000)-this.overlap);
activeAudioObj.play();
};
}
//------------ /sqAudio ----------------
//--------------------------------------
/***********************************************************
* MAIN METHOD
/***********************************************************
/
/ Here be monsters. Proceed with caution.
/
*/
// Verify that the audio can be played in browser
//
function parseAudio(c) {
var d = c.exec(div.innerHTML);
while(d) {
if (d) {
if (!clips.hasOwnProperty(d[1])) {
var parser = document.createElement('a');
parser.href = d[1].toString();
var pathnameSubstrings = parser.pathname.split("/");
var clipName = pathnameSubstrings[pathnameSubstrings.length-1];
var sqAudioObj = new sqAudio(parser.href + "." + d[2].toString(), clipName, d[2].toString());
if (sqAudioObj.isPlayable) { clips[clipName] = sqAudioObj;}
}
}
d = c.exec(div.innerHTML); // yes, we could just do a do/while, but some envs don't like that
}
}
// Parse all used audio file names
// Use whatever store area element is available in the story format
//
var storeElement = (document.getElementById("store-area") ? document.getElementById("store-area") : document.getElementById("storeArea"));
var div = storeElement.firstChild;
while (div) {
var b = String.fromCharCode(92);
var q = '"';
var re = "['" + q + "]([^" + q + "']*?)" + b + ".(" + fileExtensions.join("|") + ")['" + q + "]";
parseAudio(new RegExp(re, "gi"));
div = div.nextSibling;
}
/***********************************************************
* END MAIN METHOD
/***********************************************************/
/***********************************************************
* SUPPORTING FUNCTIONS FOR THE MACROS
/***********************************************************
/
/ Here be monsters.
/
*/
// Given the clipName, get the active soundtrack
//
function getSoundTrack(clipName) {
clipName = cleanClipName(clipName.toString());
if (!clips.hasOwnProperty(clipName)) { return error("Given clipName " + clipName + " does not exist in this project. Please check your variable names."); }
return clips[clipName];
}
// Centralized function for sound fading
//
function fadeSound(clipName, fadeIn) {
var soundtrack = getSoundTrack(clipName);
if (soundtrack === "undefined") { return error("audio clip " + clipName + " not found"); }
soundtrack.fadeSound(fadeIn);
}
// Adjust the volume of ALL audio in the page
//
function adjustVolume(direction) {
// Note soundInterval and minVolume are declared globally (at top of the script)
var maxVolume = 1.0; // This is native to JavaScript. Changing will cause unexpected behavior
globalVolume = Math.max(minVolume, Math.min(maxVolume, globalVolume + (soundInterval * direction)));
for (var soundIndex in clips) {
if (clips.hasOwnProperty(soundIndex)) {
clips[soundIndex].updateVolume();
}
}
}
// Common argument management
// Because of the total expected arguments (one string, one float, one int, one boolean)
// This method attempts to be forgiving of sequence.
// Be advised if there were even one more argument, it probably couldn't be so forgiving anymore!
//
function manageCommonArgs(plainArgs, requiredArgs) {
// Look at the list of available arguments, clean them up, and take the first one of each desired type:
// Recreate the arguments as a list in required sequence [clipName, volumeProportion, overlap, loop]
var clipName;
var volumeProportion;
var overlap;
var loop;
var args = getArgs(plainArgs);
for (var i = 0; i < args.length; i++) {
if (!isNaN(args[i])) {
var tempNum = parseFloat(args[i]);
if (volumeProportion === undefined && tempNum <= 1.0) volumeProportion = tempNum;
else if (overlap === undefined && tempNum >=updateInterval) overlap = tempNum;
}
else if (args[i] == "true" || args[i] == "false") {
if (loop === undefined) loop = (args[i] == "true");
}
else {
if (clipName === undefined) clipName = args[i].toString();
}
}
for (var requiredArg in requiredArgs) {
if (requiredArgs.hasOwnProperty(requiredArg)) {
switch (requiredArg) {
case clipNameLabel :
if (clipName === undefined) { return error("No audio clip name specified."); }
break;
case volumeProportionLabel :
if (volumeProportion === undefined || volumeProportion > 1.0 || volumeProportion < 0.0) { return error("No volume proportion specified (must be a decimal number no smaller than 0.0 and no bigger than 1.0.)"); }
break;
case overlapLabel :
if (overlap === undefined) { return error("No fade duration specified (must be a number in milliseconds greater than + " + updateInterval + " ms.)"); }
break;
case loopLabel :
if (loop === undefined) { return error("No loop flag provided (must be a boolean, aka true or false.)"); }
break;
}
}
}
return [clipName, volumeProportion, overlap, loop];
}
// Get the clipName up to the . if a . exists, otherwise do no harm
//
function cleanClipName(clipName) {
var parser = document.createElement('a');
parser.href = clipName.toString();
var pathnameSubstrings = parser.pathname.split("/");
clipName = pathnameSubstrings[pathnameSubstrings.length-1];
return clipName.lastIndexOf(".") > -1 ? clipName.slice(0, clipName.lastIndexOf(".")) : clipName;
}
/***********************************************************
* END SUPPORTING FUNCTIONS FOR THE MACROS
/***********************************************************/
/***********************************************************
/***********************************************************
* MACROS
/***********************************************************
/***********************************************************
*/
/* updatevolume
Given a decimal between 0.0 and 1.0,
updates the clip's volume proportion and the clip's actual volume
*/
macros.updatevolume = {
handler: function () {
var args = manageCommonArgs(arguments, [clipNameLabel, volumeProportionLabel]);
var soundtrack = getSoundTrack(args[0]);
soundtrack.setVolumeProportion(args[1]);
soundtrack.updateVolume();
}
};
/**
playsound
This version of the macro lets you do a little bit of sound mixing.
Parameters:
REQUIRED: clipName
OPTIONAL: decimal proportion of volume (0.0 being minimum/mute, and 1.0 being maximum/default)
OPTIONAL: number of milliseconds to overlap/crossfade the loop (0 ms by default)
OPTIONAL: true if you'd like to loop, false if no
*/
macros.playsound = {
handler : function () {
var args = manageCommonArgs(arguments, [clipNameLabel]);
var soundtrack = getSoundTrack(args[0]);
var volumeProportion = args[1] !== undefined ? args[1] : soundtrack.volumeProportion;
soundtrack.overlap = args[2] !== undefined ? args[2] : defaultOverlap;
var loop = args[3] !== undefined ? args[3] : false;
soundtrack.setVolumeProportion(volumeProportion);
soundtrack.updateVolume();
soundtrack.play(loop);
}
};
/* playsounds
Play multiple sounds at once (picking up where we left off)
If you give it no sounds to play, it quietly ignores the command.
Parameters:
OPTIONAL: clipName
OPTIONAL: decimal proportion of volume (0.0 being minimum/mute, and 1.0 being maximum/default)
OPTIONAL: number of milliseconds to overlap/crossfade (0 ms by default)
OPTIONAL: true if you'd like to loop, false if no
/
*/
macros.playsounds = {
handler: function () {
var clipNameString = args[0];
if (args[0] === undefined || args[0] === "") return;
clipNameString = args[0].toString();
if (clipNameString == "[]") return;
var clipNames = clipNameString.split(",");
if (clipNames.length < 1) return;
var args = manageCommonArgs(arguments);
for (var index = 0; index < clipNames.length; index++) {
var soundtrack = getSoundTrack(cleanClipName(clipNames[index]));
var volumeProportion = args[1] !== undefined ? args[1] : soundtrack.volumeProportion;
soundtrack.overlap = args[2] !== undefined ? args[2] : defaultOverlap;
var loop = args[3] !== undefined ? args[3] : false;
soundtrack.setVolumeProportion(volumeProportion);
soundtrack.updateVolume();
soundtrack.play(loop);
}
}
};
/* pausesound
Pauses audio at its current location.
Use playsound to resume it.
Parameters:
REQUIRED: clipName
*/
macros.pausesound = {
handler: function() {
var args = manageCommonArgs(arguments, [clipNameLabel]);
getSoundTrack(args[0]).pause();
}
};
/* <<pauseallsound>>
Pauses all sounds at their current location.
If you'd like the option to start multiple sounds,
take a look at <<playsounds>> and <<fadeinsounds>>
*/
macros.pauseallsound = {
handler: function () {
for (var clipName in clips) {
if (clips.hasOwnProperty(clipName)) {
getSoundTrack(clipName).pause();
}
}
}
};
/* stopsound
Stop the given sound immediately
If the sound is played again, it will play from the beginning
Parameters:
REQUIRED: clipName
*/
macros.stopsound = {
handler: function() {
var args = manageCommonArgs(arguments, [clipNameLabel]);
getSoundTrack(args[0]).stopAndClear();
}
};