Skip to content

Instantly share code, notes, and snippets.

@symposion
Forked from rileydutton/testscript.js
Created October 26, 2016 18:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save symposion/a1d5ef45629170de3a0dea7d665258d9 to your computer and use it in GitHub Desktop.
Save symposion/a1d5ef45629170de3a0dea7d665258d9 to your computer and use it in GitHub Desktop.
//To test, just add the script and the sheet to any blank game, then create a new blank Character in the game, then do any chat message.
//Expected behavior:
// "Found webworker script"
// "API Ready."
// "Hello from sheetworker"
// "Creating baseattribute..."
// "Base attribute heard change"
// "Created attribute heard change"
on("chat:message", function() {
//Find the first character and just use it
var firstChar = findObjs({type: "character"})[0];
if(!firstChar) {
log("You must make a character manually");
return;
}
log("Creating baseattribute...");
var newattrib = createObj("attribute", {characterid: firstChar.id, name: "baseattribute"});
newattrib.setWithWorker({
current: "1"
});
});
on("ready", function() {
log("API Ready.");
})
<input type="text" name="attr_baseattribute" />
<fieldset class="repeating_skills">
<input type="text" name="attr_skillname" />
<input type="text" name="attr_skilldependent" />
</fieldset>
<script type="text/worker">
log("Hello from sheetworker");
on("change:baseattribute", function() {
log("Base attribute heard change");
var attrName = 'repeating_skills_' + generateRowID() + '_skillname';
var object = {};
object[attrName] = 'myValue';
setAttrs(object);
});
on("change:repeating_skills:skillname", function() {
console.info('Here');
log("Repeating section created attribute listener fired");
setAttrs({
repeating_skills_skilldependent: 'testDepValue'
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment