Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

[Discussion] sendChat("player|-ABC123"...) and controlling GM

1439240997
Stephen S.
Pro
Marketplace Creator
Sheet Author
API Scripter
Anyone played around with this much? I do a lot of scripts which only should have one person controlling the script or part of a script.
1439241849
Stephen S.
Pro
Marketplace Creator
Sheet Author
API Scripter
checkOwnerName = function(players,ownerId) { var whoToTest = _.where(players, {id: ownerId})[0].get('displayname').split(' ')[0]; return _.chain(players).map(function(p){ return p.get('displayname').split(' ')[0]; }).filter(function(n){ return n === whoToTest; }).value().length === 1; }, refreshData = function() { var players = findObjs({type: 'player'}), ownerId = _.find(_.pluck(players,'id'),playerIsGM); if ( undefined === ownerId ){ chatOutput.Input({ action: 'alert', type: 'Halt', text: '<b>Script Halted.</b> Script halted. State failed to initialize due to <b>no GM</b> being found.' }); } if( !checkOwnerName(players,ownerId) ) { chatOutput.Input({ action: 'alert', type: 'Halt', text: '<b>Script Halted.</b> Script halted. State failed to initialize due to <b>GMs not having unique names.<b>' }); } //more stuff },
1439241914
Stephen S.
Pro
Marketplace Creator
Sheet Author
API Scripter
That sample code above is to find GMs with unique names.... but now I guess I can work more of the ids. 
1439247625
Stephen S.
Pro
Marketplace Creator
Sheet Author
API Scripter
Well, I clearly didn't understand this update and its not quite what I hoped for. Was hoping you could target the listener based on ID. Still quoted names is better than it was.
1439248879

Edited 1439248924
I still target display name (except for instances of a GM check). I might migrate over to player id. I'm curious if there will ever be universal id support; at least in the checking and verifying of things.
1439251663

Edited 1439251701
Stephen S.
Pro
Marketplace Creator
Sheet Author
API Scripter
Yeah. The wrinkle is you can still have named that are not distinct and you cannot programmatically change them (read only.) You can test for it.... but might have to halt a script until that name conflict was addressed.