diff --git a/Emas/Emas.js b/Emas/Emas.js new file mode 100644 index 0000000000..431517680a --- /dev/null +++ b/Emas/Emas.js @@ -0,0 +1,203 @@ +// GIST: https://gist.github.com/shdwjk/42f34ecfd167ec56c9f7 + +var Emas = Emas || (function() { + 'use strict'; + + var version = 0.7, + + ch = function (c) { + var entities = { + '<' : 'lt', + '>' : 'gt', + "'" : '#39', + '@' : '#64', + '{' : '#123', + '|' : '#124', + '}' : '#125', + '[' : '#91', + ']' : '#93', + '"' : 'quot', + '-' : 'mdash', + ' ' : 'nbsp' + }; + + if(_.has(entities,c) ){ + return ('&'+entities[c]+';'); + } + return ''; + }, + + + showHelp = function(who) { + sendChat('', + '/w '+who+' ' ++'
' + +'
' + +'Emas v'+version + +'
' + +'
' + +'

Emas provides the !emas command, which looks like /emas but ' + +'works for everyone, as well as the !as command, which looks like ' + +'/as but works for everyone. !w, !r, !gr as ' + +'well.

' + +'
' + +'Commands' + +'
' + +'!emas '+ch('<')+'message'+ch('>')+'' + +'
' + +'

Sends a message in the same manner as /emas does for GMs.

' + +'
    ' + +'
  • ' + +''+ch('<')+'message'+ch('>')+' '+ch('-')+' The message to output as part of the emote.' + +'
  • ' + +'
' + +'
' + +'
' + +'
' + +'!as '+ch('<')+'target'+ch('>')+' '+ch('<')+'message'+ch('>')+'' + +'
' + +'

Sends a message in the same manner as /as does for GMs.

' + +'
    ' + +'
  • ' + +''+ch('<')+'target'+ch('>')+' '+ch('-')+' The person to speak as.' + +'
  • ' + +'
  • ' + +''+ch('<')+'message'+ch('>')+' '+ch('-')+' The message to output as part of the emote.' + +'
  • ' + +'
' + +'
' + +'
' + +'
' + +'!w '+ch('<')+'target'+ch('>')+' '+ch('<')+'message'+ch('>')+'' + +'
' + +'

Sends a message in the same manner as /w does.

' + +'
    ' + +'
  • ' + +''+ch('<')+'target'+ch('>')+' '+ch('-')+' The target of the whisper.' + +'
  • ' + +'
  • ' + +''+ch('<')+'message'+ch('>')+' '+ch('-')+' The message to whisper.' + +'
  • ' + +'
' + +'
' + +'
' + +'
' + +'!r '+ch('<')+'expression'+ch('>')+'' + +'
' + +'

Sends a expression in the same manner as /r does.

' + +'
    ' + +'
  • ' + +''+ch('<')+'expression'+ch('>')+' '+ch('-')+' The dice expression to output.' + +'
  • ' + +'
' + +'
' + +'
' + +'
' + +'!gr '+ch('<')+'expression'+ch('>')+'' + +'
' + +'

Sends a message in the same manner as /gr does.

' + +'
    ' + +'
  • ' + +''+ch('<')+'expression'+ch('>')+' '+ch('-')+' The dice expression to whisper to the GM (blindly).' + +'
  • ' + +'
' + +'
' + +'
' + +'
' + +'!desc '+ch('<')+'message'+ch('>')+'' + +'
' + +'

Sends a message in the same manner as /desc does.

' + +'
    ' + +'
  • ' + +''+ch('<')+'message'+ch('>')+' '+ch('-')+' The message to output as part of the description.' + +'
  • ' + +'
' + +'
' + +'
' ++'
' + ); + }, + + handleInput = function(msg_orig) { + var args, who, msg = _.clone(msg_orig); + + if (msg.type !== "api") { + return; + } + + if(_.has(msg,'inlinerolls')){ + msg.content = _.chain(msg.inlinerolls) + .reduce(function(m,v,k){ + m['$[['+k+']]']="[["+v.expression+"]]"; + return m; + },{}) + .reduce(function(m,v,k){ + return m.replace(k,v); + },msg.content) + .value(); + } + + + args = msg.content.split(/\s+/); + who=getObj('player',msg.playerid).get('_displayname').split(' ')[0]; + switch(args[0]) { + case '!emas': + if(1 === args.length) { + showHelp(who); + } else { + sendChat('','/emas '+_.rest(args).join(' ')); + } + break; + case '!as': + if(1 === args.length) { + showHelp(who); + } else { + sendChat('','/as '+_.rest(args).join(' ')); + } + break; + case '!w': + if(1 === args.length) { + showHelp(who); + } else { + sendChat(msg.who,'/w '+who+' '+_.rest(args,2).join(' ')); + sendChat(msg.who,'/w '+_.rest(args).join(' ')); + } + break; + case '!r': + if(1 === args.length) { + showHelp(who); + } else { + sendChat('','/r '+_.rest(args).join(' ')); + } + break; + case '!gr': + if(1 === args.length) { + showHelp(who); + } else { + sendChat('','/gr '+_.rest(args).join(' ')); + } + break; + case '!desc': + if(1 === args.length) { + showHelp(who); + } else { + sendChat('','/desc '+_.rest(args).join(' ')); + } + break; + } + }, + + registerEventHandlers = function() { + on('chat:message', handleInput); + }; + + return { + RegisterEventHandlers: registerEventHandlers + }; +}()); + +on("ready",function(){ + 'use strict'; + + Emas.RegisterEventHandlers(); +}); diff --git a/Emas/package.json b/Emas/package.json new file mode 100644 index 0000000000..f01e566fa9 --- /dev/null +++ b/Emas/package.json @@ -0,0 +1,13 @@ +{ + "name": "emas", + "version": "0.7", + "description": "Provides player !emas and !as commands.", + "authors": "The Aaron", + "roll20userid": "104025", + "dependencies": { + }, + "modifies": { + }, + "conflicts": [ + ] +}