// Github: https://github.com/shdwjk/Roll20API/blob/master/Emas/Emas.js // By: The Aaron, Arcane Scriptomancer // Contact: https://app.roll20.net/users/104025/the-aaron var Emas = Emas || (function() { 'use strict'; var version = '0.8.1', lastUpdate = 1427604244, 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 ''; }, checkInstall = function() { log('-=> Emas v'+version+' <=- ['+(new Date(lastUpdate*1000))+']'); }, 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 { CheckInstall: checkInstall, RegisterEventHandlers: registerEventHandlers }; }()); on("ready",function(){ 'use strict'; Emas.CheckInstall(); Emas.RegisterEventHandlers(); });