This commit is contained in:
choelzl 2022-02-23 19:38:39 +01:00
parent 9012cf1d64
commit 1e96fa1846
Signed by: sora
GPG Key ID: A362EA0491E2EEA0
2 changed files with 57 additions and 40 deletions

View File

@ -1,9 +1,8 @@
(function() {
function getEmotes(event, message){
function getNoTwitchEmotes(event, message){
var emotes = event.getTags().get('emotes'),
str = message,
i;
str = message, i;
if (emotes.length() > 0) {
emotes = emotes.replaceAll('[0-9]+:', '').split('/');
@ -15,59 +14,65 @@
}
function sendData(tpe, data) {
function sendData(tpe, te, ce) {
$.panelsocketserver.sendJSONToAll(JSON.stringify({
'eventFamily': 'emote',
'eventType': tpe,
'data': data
'data': {
twitch: te,
custom: ce,
}
}));
}
$.bind('ircChannelMessage', function(event){
var sender = event.getSender(),
message = event.getMessage().toLowerCase(),
messageLength = message.length(),
message = event.getMessage();
tags = event.getTags();
$.consoleLn(message)
$.consoleLn(tags)
if(messsage[0] != '!')
sendData('bounce',event.getTags().get('emotes'), getNoTwitchEmotes(event,message))
})
$.bind('command', function(event) {
const sender = "" + event.getSender().toLowerCase(),
command = event.getCommand(),
args = event.getArgs(),
action = args[0],
value = args[1];
action = args[0];
if (command.equalsIgnoreCase('overlay')) {
if (command.equalsIgnoreCase('ew')) {
if (!action) {
$.say($.whisperPrefix(sender) + $.lang.get('ew.help', ' Use "!ew [follow | subscribe | donation | timer] value" to set overlay data.'));
} else if (action.equalsIgnoreCase('follow')) {
sendData(action, value);
} else if (action.equalsIgnoreCase('subscribe')) {
sendData(action, value);
} else if (action.equalsIgnoreCase('donation')) {
sendData(action, value);
} else if (action.equalsIgnoreCase('timer')) {
sendData(action, new Date(Date.now().getTime()+value*1000*60));
$.say($.whisperPrefix(sender) + $.lang.get('ew.help', ' Use "!ew [rain | firework | volcano | bomb | explosion] emote" to render emotes.'));
} else if (action.equalsIgnoreCase('rain')) {
sendData('rain',event.getTags().get('emotes'), getNoTwitchEmotes(event,event.messsage))
} else if (action.equalsIgnoreCase('firework')) {
sendData('firework',event.getTags().get('emotes'), getNoTwitchEmotes(event,event.messsage))
} else if (action.equalsIgnoreCase('volcano')) {
sendData('volcano',event.getTags().get('emotes'), getNoTwitchEmotes(event,event.messsage))
} else if (action.equalsIgnoreCase('bomb')) {
sendData('bomb',event.getTags().get('emotes'), getNoTwitchEmotes(event,event.messsage))
} else if (action.equalsIgnoreCase('explosion')) {
sendData('explosion',event.getTags().get('emotes'), getNoTwitchEmotes(event,event.messsage))
} else {
$.say($.whisperPrefix(sender) + $.lang.get('ew.help'));
$.say($.whisperPrefix(sender) + $.lang.get('ew.help', ' Use "!ew [rain | firework | volcano | bomb | explosion] emote" to render emotes.'));
}
}
});
$.bind('twitchFollow', function(event) {
sendData('follow', event.getFollower());
sendData('firework', [],['AYAYA'])
});
$.bind('twitchSubscriber', function(event) {
sendData('subscribe', event.getSubscriber());
sendData('volcano', [], ['AYAYA']);
});
$.bind('initReady', function() {
$.registerChatCommand('./custom/custom/customOverlay.js', 'ew');
$.registerChatSubcommand('ew', 'follow', 2);
$.registerChatSubcommand('ew', 'rain', 2);
$.registerChatSubcommand('ew', 'firework', 2);
$.registerChatSubcommand('ew', 'volcano', 2);
$.registerChatSubcommand('ew', 'bomb', 2);
$.registerChatSubcommand('ew', 'explosion', 2);
});
})();

View File

@ -220,7 +220,7 @@ $(async function () {
super(emote,data)
let speed = randRange(5,15);
let fang = 2*Math.PI* (args.angle/360)
let ang = randRange(-fang/2, +fang/2)+Math.PI/2 ;//+ 2*(angle/360)*Math.PI;
let ang = randRange(-fang/2, +fang/2)+Math.PI/2;
this.setPhysics(args.x,args.y,
Math.cos(ang)*speed,
-Math.sin(ang)*speed,
@ -244,7 +244,7 @@ $(async function () {
super.update(tick);
if(this.y <= canvas.height/4 && this.time < drt){
this.time = drt;
genExplosion(this.x,this.y,360)
genExplosion(this.x,this.y,360, this.sete)
}
}
}
@ -263,7 +263,7 @@ $(async function () {
super.update(tick);
if(this.y >= canvas.height - this.size && this.time < drt){
this.time = drt;
genExplosion(this.x,this.y,60)
genExplosion(this.x,this.y,60, this.sete)
}
}
}
@ -275,25 +275,25 @@ $(async function () {
setTimeout(()=>{particles.pop()}, drt*1000+2000);
}
const genExplosion = (x,y,ang) =>{
for(let i=0; i<100; ++i) createParticule(ExplosionP, randEmote(), {},{x:x,y:y,angle:ang});
const genExplosion = (x,y,ang,em) =>{
for(let i=0; i<100; ++i) createParticule(ExplosionP, em? em:randEmote(), {},{x:x,y:y,angle:ang});
}
const genRain = () => {
const genRain = (em) => {
let xpos = randRange(0, canvas.width);
let time = 0;
const interval = setInterval(()=>{
for(let i=0; i<10; ++i) createParticule(RainP, randEmote(), {},{});
for(let i=0; i<10; ++i) createParticule(RainP, em? em:randEmote(), {},{});
++time;
if(time > 50) clearInterval(interval);
}, 100);
}
const genVolcano = () => {
const genVolcano = (em) => {
let xpos = randRange(0, canvas.width);
let time = 0;
const interval = setInterval(()=>{
for(let i=0; i<10; ++i) createParticule(ExplosionP, randEmote(), {},{x:xpos,y:canvas.height,angle:30});
for(let i=0; i<10; ++i) createParticule(ExplosionP, em? em:randEmote(), {},{x:xpos,y:canvas.height,angle:30});
++time;
if(time > 50) clearInterval(interval);
}, 100);
@ -336,13 +336,25 @@ $(async function () {
let rawMessage = e.data,
message = JSON.parse(rawMessage);
if(!message.hasOwnProperty('eventFamily') || message.eventFamily != 'emotewall' ||
if(!message.hasOwnProperty('eventFamily') || message.eventFamily != 'emote' ||
!message.hasOwnProperty('eventType') || !message.hasOwnProperty('data'))
return;
console.log(message.eventType, message.data)
if(message.eventType == 'message') {
//....
if(message.eventType == 'bounce') {
createParticule(BounceP, message.data, {}, {})
}else if(message.eventType == 'rain') {
genRain(message.data)
}else if(message.eventType == 'firework') {
genFirework(message.data)
}else if(message.eventType == 'volcano') {
genVolcano(message.data)
}else if(message.eventType == 'bomb') {
createParticule(BombP, message.data, {}, {})
}else if(message.eventType == 'explosion') {
//genExplosion(message.data)
}else {
console.log("unhandled:", message.eventType)
}
} catch (ex) {
console.log(ex)
@ -353,7 +365,7 @@ $(async function () {
jQuery(async ()=>{
try{
socket.addFamilyHandler("overlay", handleSocketMessage);
socket.addFamilyHandler("emote", handleSocketMessage);
if(socket){
while(socket.getReadyState() === 0){
await new Promise(r => setTimeout(r, 500));