Skip to content

Instantly share code, notes, and snippets.

@rileydutton
Created October 26, 2016 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rileydutton/b988f2e1d05ff625674f89e39ee732b8 to your computer and use it in GitHub Desktop.
Save rileydutton/b988f2e1d05ff625674f89e39ee732b8 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" />
<input type="text" name="attr_createdattribute" />
<script type="text/worker">
log("Hello from sheetworker");
on("change:baseattribute", function() {
log("Base attribute heard change");
setAttrs({
"createdattribute": "12"
});
});
on("change:createdattribute", function() {
log("Created attribute heard change");
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment