
I want to write a script that watches for a token to be moved, and any time it is moved it makes sure the bars are set. It doesn't seem to be working. Since I'm not familiar with the API, it's difficult to tell if I'm not properly packaging my instructions, or if my instructions are incorrect. Any ideas? on("change:graphic",function(obj) {
if (obj.get("bar1_link")==""){
obj.set("bar1_link","hp_temp");
obj.set("bar2_link","ac");
obj.set("bar3_link","hp");
}
})
EDIT: I'm also trying to get the script to check to see if gender is set on the linked character. Since that is a custom attribute that I'm adding, how do I if () test for whether an attribute exists? for this, I imagine: having to API test to see if gen1 exists on the character that the selected token represents call a macro to pull up a dialog to ask what the gender should be have the macro run a chat string that would be parsed to set the gender of the token.