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
This commit is contained in:
parent
81e986fadf
commit
227a58bb39
|
@ -1,5 +1,5 @@
|
||||||
function main() {
|
function main() {
|
||||||
log.Info("Azulian '%s' initialized!", Self.Doodad().Title);
|
console.log("Azulian '%s' initialized!", Self.Title);
|
||||||
|
|
||||||
var playerSpeed = 4;
|
var playerSpeed = 4;
|
||||||
var gravity = 4;
|
var gravity = 4;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
function main() {
|
function main() {
|
||||||
console.log("%s initialized!", Self.Doodad().Title);
|
console.log("%s initialized!", Self.Title);
|
||||||
|
|
||||||
var timer = 0;
|
var timer = 0;
|
||||||
|
|
||||||
|
@ -26,9 +26,4 @@ function main() {
|
||||||
timer = 0;
|
timer = 0;
|
||||||
}, 200);
|
}, 200);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Events.OnLeave(function(e) {
|
|
||||||
// console.log("%s has stopped touching %s", e, Self.Doodad().Title)
|
|
||||||
// Self.Canvas.SetBackground(RGBA(0, 0, 1, 0));
|
|
||||||
// })
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
function main() {
|
function main() {
|
||||||
console.log("%s initialized!", Self.Doodad().Title);
|
console.log("%s initialized!", Self.Title);
|
||||||
|
|
||||||
var pressed = false;
|
var pressed = false;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
|
|
||||||
function main() {
|
function main() {
|
||||||
var color = Self.Doodad().Tag("color");
|
var color = Self.GetTag("color");
|
||||||
var keyname = "key-" + color + ".doodad";
|
var keyname = "key-" + color + ".doodad";
|
||||||
|
|
||||||
// Layers in the doodad image.
|
// Layers in the doodad image.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
function main() {
|
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("open", 100, [0, 1, 2, 3]);
|
||||||
Self.AddAnimation("close", 100, [3, 2, 1, 0]);
|
Self.AddAnimation("close", 100, [3, 2, 1, 0]);
|
||||||
|
@ -9,7 +9,7 @@ function main() {
|
||||||
Self.SetHitbox(16, 0, 32, 64);
|
Self.SetHitbox(16, 0, 32, 64);
|
||||||
|
|
||||||
Message.Subscribe("power", function(powered) {
|
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 (powered) {
|
||||||
if (animating || opened) {
|
if (animating || opened) {
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
function main() {
|
function main() {
|
||||||
var color = Self.Doodad().Tag("color");
|
var color = Self.GetTag("color");
|
||||||
|
|
||||||
Events.OnCollide(function(e) {
|
Events.OnCollide(function(e) {
|
||||||
if (e.Settled) {
|
if (e.Settled) {
|
||||||
e.Actor.AddItem(Self.Doodad().Filename, 0);
|
e.Actor.AddItem(Self.Filename, 0);
|
||||||
Self.Destroy();
|
Self.Destroy();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
function main() {
|
function main() {
|
||||||
Self.AddAnimation("open", 0, [1]);
|
Self.AddAnimation("open", 0, [1]);
|
||||||
var unlocked = false;
|
var unlocked = false;
|
||||||
var color = Self.Doodad().Tag("color");
|
var color = Self.GetTag("color");
|
||||||
|
|
||||||
Self.SetHitbox(16, 0, 32, 64);
|
Self.SetHitbox(16, 0, 32, 64);
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// Exit Flag.
|
// Exit Flag.
|
||||||
function main() {
|
function main() {
|
||||||
console.log("%s initialized!", Self.Doodad().Title);
|
console.log("%s initialized!", Self.Title);
|
||||||
Self.SetHitbox(22+16, 16, 75-16, 86);
|
Self.SetHitbox(22+16, 16, 75-16, 86);
|
||||||
|
|
||||||
Events.OnCollide(function(e) {
|
Events.OnCollide(function(e) {
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
var state = false;
|
var state = false;
|
||||||
|
|
||||||
function main() {
|
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);
|
Self.SetHitbox(0, 0, 33, 33);
|
||||||
|
|
||||||
// When the button is activated, don't keep toggling state until we're not
|
// When the button is activated, don't keep toggling state until we're not
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
function main() {
|
function main() {
|
||||||
console.log("%s initialized!", Self.Doodad().Title);
|
console.log("%s initialized!", Self.Title);
|
||||||
|
|
||||||
// Switch has two frames:
|
// Switch has two frames:
|
||||||
// 0: Off
|
// 0: Off
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
function main() {
|
function main() {
|
||||||
console.log("%s initialized!", Self.Doodad().Title);
|
console.log("%s initialized!", Self.Title);
|
||||||
|
|
||||||
var timer = 0;
|
var timer = 0;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
function main() {
|
function main() {
|
||||||
// What direction is the trapdoor facing?
|
// What direction is the trapdoor facing?
|
||||||
var direction = Self.Doodad().Tag("direction");
|
var direction = Self.GetTag("direction");
|
||||||
console.log("Trapdoor(%s) initialized", direction);
|
console.log("Trapdoor(%s) initialized", direction);
|
||||||
|
|
||||||
var timer = 0;
|
var timer = 0;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user