aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--examples/nword.js23
1 files changed, 13 insertions, 10 deletions
diff --git a/examples/nword.js b/examples/nword.js
index 5012bea..f4d362e 100644
--- a/examples/nword.js
+++ b/examples/nword.js
@@ -21,14 +21,14 @@ var wq = new Queue(1000, 200, (w,max)=>{
while (id = ids.shift()) {
if (id > max) break;
if (writeids[globid]) writeids[globid].push(idcall.shift());
- else writeids[globid] = [];
+ else writeids[globid] = [idcall.shift()];
}
});
main.on('write', (acc)=>{
for (let id in writeids)
- if (acc.indexOf(id) > -1){
+ if (acc.indexOf(parseInt(id)) > -1){
for (let it of writeids[id])
- writeids[id]();
+ it();
delete writeids[id];
}
});
@@ -48,15 +48,17 @@ main.on('tileUpdate', (send, source, tiles)=>{
clearTimeout(expire[loc]);
search.del(loc);
}
- search.add(loc, spc);
+ search.add(loc, spc, send);
expire[loc] = setTimeout(() => {search.del(loc); delete expire[loc];},
300*1000);
}
});
-makeclean('I am racist', '[Nn] *[1Ii] *[Gg] *[Gg] *([3Ee] *[Rr]|[4@Aa])');
-makeclean('I am ableist', '[Rr] *[3Ee] *[Tt] *[4@Aa] *[Rr] *[Dd]');
+makeclean('','BLACK NIGGERS');
+makeclean('I am racist', '[Nn]+ *[1Ii]+ *[Gg]+ *[Gg]+ *([3Ee]+ *[Rr]+|[4@Aa]+)');
+makeclean('I am ableist', '[Rr]+ *[3Ee]+ *[Tt]+ *[4@Aa]+ *[Rr]+ *[Dd]+');
+let dolecture = false;
let lecture = {};
function makeclean(resp, reg){
let response = new Space().adhoc(resp);
@@ -64,15 +66,16 @@ function makeclean(resp, reg){
function clean(coord, send, space){
let out = new Space().adhoc(space.print().replace(regex,
match=>' '.repeat(match.length)));
- if (!lecture[send]){
+ out.loc = space.loc;
+ if (dolecture && !lecture[send]){
response.loc = coord;
- out.comb(response, comb.add);
+ out.comb(response, comb.flip(comb.add));
lecture[send] = true;
- setTimeout(() => {delete lecture[send];}, 1000);
+ setTimeout(() => {delete lecture[send];}, 10000);
}
out.comb(space, comb.sub);
ids.push(wq.enqueue(out.towrite()));
- idcall.push(() => {search.update(response);});
+ idcall.push(() => {search.update(out);});
}
search.match([reg], clean);
}