Tighten Doodad JavaScript API, User Documentation

* Tightens up the surface area of API methods available to the
  JavaScript VMs for doodads. Variables and functions are carefully
  passed in one-by-one so the doodad script can only access intended
  functions and not snoop on undocumented APIs.
* Wrote tons of user documentation for Doodad Scripts: documented the
  full surface area of the exposed JavaScript API now that the surface
  area is known and limited.
* Early WIP code for the Campaign JSON
master
Noah 2020-04-21 23:50:45 -07:00
parent 81e986fadf
commit 227a58bb39
12 changed files with 14 additions and 19 deletions

View File

@ -1,5 +1,5 @@
function main() {
log.Info("Azulian '%s' initialized!", Self.Doodad().Title);
console.log("Azulian '%s' initialized!", Self.Title);
var playerSpeed = 4;
var gravity = 4;

View File

@ -1,5 +1,5 @@
function main() {
console.log("%s initialized!", Self.Doodad().Title);
console.log("%s initialized!", Self.Title);
var timer = 0;
@ -26,9 +26,4 @@ function main() {
timer = 0;
}, 200);
});
// Events.OnLeave(function(e) {
// console.log("%s has stopped touching %s", e, Self.Doodad().Title)
// Self.Canvas.SetBackground(RGBA(0, 0, 1, 0));
// })
}

View File

@ -1,5 +1,5 @@
function main() {
console.log("%s initialized!", Self.Doodad().Title);
console.log("%s initialized!", Self.Title);
var pressed = false;

View File

@ -1,6 +1,6 @@
function main() {
var color = Self.Doodad().Tag("color");
var color = Self.GetTag("color");
var keyname = "key-" + color + ".doodad";
// Layers in the doodad image.

View File

@ -1,5 +1,5 @@
function main() {
console.log("%s initialized!", Self.Doodad().Title);
console.log("%s initialized!", Self.Title);
Self.AddAnimation("open", 100, [0, 1, 2, 3]);
Self.AddAnimation("close", 100, [3, 2, 1, 0]);
@ -9,7 +9,7 @@ function main() {
Self.SetHitbox(16, 0, 32, 64);
Message.Subscribe("power", function(powered) {
console.log("%s got power=%+v", Self.Doodad().Title, powered);
console.log("%s got power=%+v", Self.Title, powered);
if (powered) {
if (animating || opened) {

View File

@ -1,9 +1,9 @@
function main() {
var color = Self.Doodad().Tag("color");
var color = Self.GetTag("color");
Events.OnCollide(function(e) {
if (e.Settled) {
e.Actor.AddItem(Self.Doodad().Filename, 0);
e.Actor.AddItem(Self.Filename, 0);
Self.Destroy();
}
})

View File

@ -2,7 +2,7 @@
function main() {
Self.AddAnimation("open", 0, [1]);
var unlocked = false;
var color = Self.Doodad().Tag("color");
var color = Self.GetTag("color");
Self.SetHitbox(16, 0, 32, 64);

View File

@ -1,6 +1,6 @@
// Exit Flag.
function main() {
console.log("%s initialized!", Self.Doodad().Title);
console.log("%s initialized!", Self.Title);
Self.SetHitbox(22+16, 16, 75-16, 86);
Events.OnCollide(function(e) {

View File

@ -4,7 +4,7 @@
var state = false;
function main() {
console.log("%s ID '%s' initialized!", Self.Doodad().Title, Self.ID());
console.log("%s ID '%s' initialized!", Self.Title, Self.ID());
Self.SetHitbox(0, 0, 33, 33);
// When the button is activated, don't keep toggling state until we're not

View File

@ -1,5 +1,5 @@
function main() {
console.log("%s initialized!", Self.Doodad().Title);
console.log("%s initialized!", Self.Title);
// Switch has two frames:
// 0: Off

View File

@ -1,5 +1,5 @@
function main() {
console.log("%s initialized!", Self.Doodad().Title);
console.log("%s initialized!", Self.Title);
var timer = 0;

View File

@ -1,6 +1,6 @@
function main() {
// What direction is the trapdoor facing?
var direction = Self.Doodad().Tag("direction");
var direction = Self.GetTag("direction");
console.log("Trapdoor(%s) initialized", direction);
var timer = 0;