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

Trying to make GUMSHOE-Roll20.js work for Night's Black Agents

1475902165
chatty
KS Backer
Sheet Author
Let's leave aside for a moment how Gumshoe actually works. Once I figure this out I think I can make the script adhere to the rules. I'm trying to edit Ramblurr's (Casey Link's) GUMSHOE-Roll20.js so it 1) works for Night's Black Agents and 2) does what I want it to. Unfortunately, I have very little idea how javascript works, so it's kind of like trying to reverse engineer alien technology. Take, for instance, these lines of code: var gumABILITIES = [ {name:'hand_to_hand',pretty:'Hand to Hand'}, ... ] How would I output the "pretty" term if I wanted to?  I don't want to dump the whole .js file here, but it looks like the variable %s is somehow set to "archaeology" when one tries to roll the skill, so the roll looks like "Rolling %s" in the code and outputs as "Rolling hand_to_hand". How would I make it say "Rolling Hand to Hand" instead? Eventually I want to make the buttons just spend for Investigative skills, and then customize the CSS so it looks like a Night's Black Agents sheet but this is bugging me more. Thanks C
1475918767
Lithl
Pro
Sheet Author
API Scripter
chatty said: Take, for instance, these lines of code: var gumABILITIES = [ {name:'hand_to_hand',pretty:'Hand to Hand'}, ... ] How would I output the "pretty" term if I wanted to? gumABILITIES is an array, and each element in the array is an object with two properties. To get one of the objects, you would use gumABILITIES[N] , where N is some number (or variable with a number as its value). 0 is the first index in the array, while gumABILITIES.length - 1 is the last index in the array. Accessing a property of an object can be done with myObject.myProperty  (assuming the property name doesn't have any illegal characters like space or hyphen), or myObject['myProperty']  (you could also have a variable with the property name as its value, instead of a constant string). Putting them together, for example, the second object in the array's "pretty" value would be gumABILITIES[1].pretty . chatty said: I don't want to dump the whole .js file here, but it looks like the variable %s is somehow set to "archaeology" when one tries to roll the skill, so the roll looks like "Rolling %s" in the code and outputs as "Rolling hand_to_hand". How would I make it say "Rolling Hand to Hand" instead? The script appears to be implementing  NodeJS's util.format function. Given a string like "Rolling %s", you could get "Rolling hand_to_hand" with format("Rolling %s", gumABILITIES[0].name)  and you could get "Rolling Hand to Hand" with format("Rolling %s", gumABILITIES[0].pretty) .
1475930925
chatty
KS Backer
Sheet Author
Thanks! I'm about to go away for the weekend, but I'll try working with this when I get some time in front of a computer.