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

Wroking portion of a script, suddenly not working.

1401061848

Edited 1401062258
So I finally completed the new version of my combat resolution script. The portion that set the names of who and whoTarg have not changed. However, when I do a send chat reference these variables, they show up as object Object. When I log whoTarg I get "{"name":"Orc Warrior", ..ect... }" So I know it capturing the name. Here is the sendChat: sendChat(msg.who, '/emas '+ who +' attacks ' + whoTarg + ' and scores a hit!'); and the message in chat: " object t Object] attacks [object Object] and scores a hit!" I don't understand why it isn't working. var who = getObj('character', selectedToken.get('represents')); if (!who) { who = selectedToken.get('name'); } var whoTarg = getObj('character', targetToken.get('represents')); if (!whoTarg) { whoTarg = targetToken.get('name'); }
1401064730
Sam M.
Pro
Sheet Author
maybe you have to set var who = getObj('character', selectedToken.get('represents'))['name'];
1401066299

Edited 1401066606
I don't know... all I know is that this worked earlier. The only revisions were basically cutting out the need to pass 100 things to the script from the macro (I was still learning) but now it doesn't want to work. Here is the gist of the entire script. Ill try it your way and see.
For some reason, the API doesn't like me using the same who for the sendChat and getAttrByName. I just made secondaries whoName and whoTargName for the sendChat, and it works fine now. Now on to the next script. I'll try not to spam the forums, but I can give no promises.
1401089063
Lithl
Pro
Sheet Author
API Scripter
sendChat and getAttrByName are expecting different values for their first parameter; you shouldn't be using the same thing. sendChat expects one of: "character|"+characterid, "player|"+playerid, or a string which is interpreted as a name. getAttrByName expects a characterid.
Yea, I see that, and I corrected it. Thank you again.