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

[Help]Get character sheet even when 'ooc' name selected in dropdown

1390935085

Edited 1390935234
DXWarlock
Sheet Author
API Scripter
This may be an easy one to answer. Problem Im having is I have an 'onchat' script that runs to give out money based on a !loot command they use when looting bodies to return random results, and apply it to a 'credits' attribute on the players character sheet. The issue is if they have thier name selected to chat as, vs character name the script throw a 'Cannot read property 'id' because of course the playername doesn't return anything it can use. causing the entire API sandbox to stop. My question, is there a way to do it so the code below returns the players character name, even if they forget to set it in the chat dropdown? I assume its to do with msg.who, just not sure what other to try to return the right name. (if it helps they only ever have one character they control..so it will never return more than 1 result if possible) var cWho = findObjs({_type: 'character',name: msg.who})[0]; var oC = findObjs({name: "Credits",_type: "attribute",_characterid: cWho.id}, {caseInsensitive: true})[0];
Use !loot @{selected|token_id} and make them select their token before running that macro. You could also use !loot @{selected|token_id} @{target| |token_name} to loot a specific dead corpse.
1390935719
DXWarlock
Sheet Author
API Scripter
That could work, and have it do nothing if they didn't select anything. Better than all my scripts stopping because someone forgot to switch in character before doing it.
1390937377
DXWarlock
Sheet Author
API Scripter
Thanks Badger that works great, better than my idea, more interactive. They get to pick something to loot vs me just telling them they are looting it :)
1390952892
Stephen S.
Pro
Marketplace Creator
Sheet Author
API Scripter
I use one word names for both player and character for a number of reasons.... You can always put the full character name in the record sheet. And if two Jimmys' are playing one of them is using "James." It just helps everything.