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

setWithWorker working example?

1486106048
GiGs
Pro
Sheet Author
API Scripter
I want to use setWithWorker, but up till now I have been setting attributes using this syntax createObj("attribute", { name: stat, current: value, characterid: character }); and I dont know how to use the .set and .get versions. Can someone post a working example of how you would define an attribute (named, say, "Horse_Type"), and set it using setWithWorker?
1486109801
Jakob
Sheet Author
API Scripter
// get character object from somewhere // Assumes that character has no attribute with name horse_type, otherwise you'll get a duplicate let stat = "horse_type", charid = character.id, attr = createObj("attribute", { name: stat, characterid: charid }); attr.setWithWorker({ current: 27, max: 30 });
1486112593
GiGs
Pro
Sheet Author
API Scripter
Awesome, thank you very much. I got it working in my script.