Doodad Tool: Add Tag Support for edit-doodad
* The `doodad edit-doodad` command now allows setting custom key/value tags in doodad files, for extra data storage useful to their scripts. * Colored keys and doors now store a `color` tag with the appropriate color so that their scripts don't have to parse their Title to find that information. * Trapdoors now store a `direction` tag to hold the direction the door is facing.
This commit is contained in:
parent
f7c4847934
commit
a4e3dbb8d4
|
@ -45,27 +45,35 @@ doors() {
|
|||
cd doors/
|
||||
|
||||
doodad convert -t "Red Door" red1.png red2.png door-red.doodad
|
||||
doodad edit-doodad -q --tag color=red door-red.doodad
|
||||
doodad install-script locked-door.js door-red.doodad
|
||||
|
||||
doodad convert -t "Blue Door" blue1.png blue2.png door-blue.doodad
|
||||
doodad edit-doodad -q --tag color=blue door-blue.doodad
|
||||
doodad install-script locked-door.js door-blue.doodad
|
||||
|
||||
doodad convert -t "Green Door" green1.png green2.png door-green.doodad
|
||||
doodad edit-doodad -q --tag color=green door-green.doodad
|
||||
doodad install-script locked-door.js door-green.doodad
|
||||
|
||||
doodad convert -t "Yellow Door" yellow1.png yellow2.png door-yellow.doodad
|
||||
doodad edit-doodad -q --tag color=yellow door-yellow.doodad
|
||||
doodad install-script locked-door.js door-yellow.doodad
|
||||
|
||||
doodad convert -t "Red Key" red-key.png key-red.doodad
|
||||
doodad edit-doodad -q --tag color=red key-red.doodad
|
||||
doodad install-script keys.js key-red.doodad
|
||||
|
||||
doodad convert -t "Blue Key" blue-key.png key-blue.doodad
|
||||
doodad edit-doodad -q --tag color=blue key-blue.doodad
|
||||
doodad install-script keys.js key-blue.doodad
|
||||
|
||||
doodad convert -t "Green Key" green-key.png key-green.doodad
|
||||
doodad edit-doodad -q --tag color=green key-green.doodad
|
||||
doodad install-script keys.js key-green.doodad
|
||||
|
||||
doodad convert -t "Yellow Key" yellow-key.png key-yellow.doodad
|
||||
doodad edit-doodad -q --tag color=yellow key-yellow.doodad
|
||||
doodad install-script keys.js key-yellow.doodad
|
||||
|
||||
doodad convert -t "Electric Door" electric{1,2,3,4}.png door-electric.doodad
|
||||
|
@ -88,6 +96,11 @@ trapdoors() {
|
|||
doodad install-script trapdoor.js trapdoor-right.doodad
|
||||
doodad install-script trapdoor.js trapdoor-up.doodad
|
||||
|
||||
doodad edit-doodad -q --tag direction=down trapdoor-down.doodad
|
||||
doodad edit-doodad -q --tag direction=left trapdoor-left.doodad
|
||||
doodad edit-doodad -q --tag direction=right trapdoor-right.doodad
|
||||
doodad edit-doodad -q --tag direction=up trapdoor-up.doodad
|
||||
|
||||
cp trapdoor-*.doodad ../../../assets/doodads/
|
||||
|
||||
cd ..
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
function main() {
|
||||
var color = Self.Doodad.Tag("color");
|
||||
|
||||
Events.OnCollide(function(e) {
|
||||
console.log("%s picked up by %s", Self.Doodad.Title, e.Actor.Title);
|
||||
e.Actor.SetData("key:" + Self.Doodad.Title, "true");
|
||||
e.Actor.SetData("key:" + color, "true");
|
||||
Self.Destroy();
|
||||
})
|
||||
}
|
||||
|
|
|
@ -1,14 +1,7 @@
|
|||
function main() {
|
||||
Self.AddAnimation("open", 0, [1]);
|
||||
var unlocked = false;
|
||||
|
||||
// Map our door names to key names.
|
||||
var KeyMap = {
|
||||
"Blue Door": "Blue Key",
|
||||
"Red Door": "Red Key",
|
||||
"Green Door": "Green Key",
|
||||
"Yellow Door": "Yellow Key"
|
||||
}
|
||||
var color = Self.Doodad.Tag("color");
|
||||
|
||||
Self.SetHitbox(16, 0, 32, 64);
|
||||
|
||||
|
@ -18,7 +11,7 @@ function main() {
|
|||
}
|
||||
|
||||
if (e.InHitbox) {
|
||||
var data = e.Actor.GetData("key:" + KeyMap[Self.Doodad.Title]);
|
||||
var data = e.Actor.GetData("key:" + color);
|
||||
if (data === "") {
|
||||
// Door is locked.
|
||||
return false;
|
||||
|
|
|
@ -1,13 +1,6 @@
|
|||
function main() {
|
||||
// What direction is the trapdoor facing?
|
||||
// - Titles are like "Trapdoor Left" or "Trapdoor Right"
|
||||
// - The default (down) is called just "Trapdoor"
|
||||
var direction = Self.Doodad.Title.split(" ")[1];
|
||||
if (!direction) {
|
||||
direction = "down";
|
||||
}
|
||||
direction = direction.toLowerCase();
|
||||
|
||||
var direction = Self.Doodad.Tag("direction");
|
||||
console.log("Trapdoor(%s) initialized", direction);
|
||||
|
||||
var timer = 0;
|
||||
|
|
Loading…
Reference in New Issue
Block a user