singe/testScripts/author/adventure2d.game
2026-09-14 14:20:17 -05:00

140 lines
6.6 KiB
Text

-- Genre one of milestone 3: a point-and-click adventure in a painted room, Sierra and LucasArts
-- in one table. Walk areas that become a navigation mesh, hotspots, a verb line, a text parser
-- as well, an inventory, a dialogue with a choice that changes the world, a cut-scene, two rooms
-- that remember themselves, and a save. The "painting" is a box, since no art is needed.
return {
title = "Author test: adventure",
size = { w = 720, h = 480 },
layers = { { kind = "overlay" },
{ kind = "parser", prompt = "> ",
words = { look = { "look", "examine", "l" }, take = { "take", "get", "pick" }, use = { "use" }, open = { "open" }, talk = { "talk", "speak" },
key = { "key" }, door = { "door", "gate" }, guard = { "guard", "man" } },
ignore = { "the", "a", "an", "at", "to", "with", "on", "up" } } },
vars = { score = 0, allowed = false },
verbs = { "walk", "look", "take", "use", "open", "talk" },
kinds = {
backdrop = { look = { kind = "box", w = 720, h = 480, r = 40, g = 45, b = 60 } },
floor = { look = { kind = "box", w = 720, h = 200, r = 70, g = 60, b = 50, anchor = "feet" } },
hero = { look = { kind = "box", w = 30, h = 70, r = 230, g = 90, b = 170, anchor = "feet" },
behaviours = { { kind = "walker", speed = 160 } } },
door = { look = { kind = "box", w = 60, h = 120, r = 90, g = 60, b = 40, anchor = "feet" },
behaviours = { { kind = "hotspot", name = "door", walkX = 600, walkY = 330 } } },
key = { look = { kind = "box", w = 16, h = 8, r = 255, g = 220, b = 60 },
behaviours = { { kind = "hotspot", name = "key", walkX = 200, walkY = 400 } } },
guard = { look = { kind = "box", w = 34, h = 80, r = 80, g = 120, b = 200, anchor = "feet" },
behaviours = { { kind = "hotspot", name = "guard", walkX = 480, walkY = 360 } } },
pillar = { look = { kind = "box", w = 40, h = 200, r = 60, g = 60, b = 80, anchor = "feet" } },
marker = { look = { kind = "none" } },
readout = { look = { kind = "text", text = "", r = 235, g = 235, b = 245 } }
},
rooms = {
{ name = "hall",
depthSort = true,
scaleBy = { { y = 300, scale = 0.6 }, { y = 460, scale = 1.0 } },
walk = { { 120, 300, 640, 300, 700, 460, 60, 460 } },
entities = {
{ kind = "backdrop", id = "backdrop", x = 360, y = 240, z = 0 },
{ kind = "floor", id = "floor", x = 360, y = 480, z = 0 },
{ kind = "door", id = "door", x = 600, y = 300, z = 0 },
{ kind = "guard", id = "guard", x = 540, y = 340, z = 0 },
{ kind = "pillar", id = "pillar", x = 360, y = 420, z = 0 },
{ kind = "key", id = "key", x = 200, y = 380, z = 0 },
{ kind = "hero", id = "hero", x = 150, y = 440, z = 0 },
{ kind = "readout", id = "readout", x = 12, y = 12, z = 0 }
} },
{ name = "yard",
depthSort = true,
walk = { { 40, 320, 680, 320, 680, 460, 40, 460 } },
entities = {
{ kind = "backdrop", id = "backdrop", x = 360, y = 240, z = 0 },
{ kind = "door", id = "door", x = 100, y = 300, z = 0 },
{ kind = "marker", id = "arrival", x = 160, y = 420, z = 0 },
{ kind = "readout", id = "readout", x = 12, y = 12, z = 0 }
} }
},
dialogues = {
guard = {
start = "hello",
nodes = {
hello = { who = "Guard", text = "Nobody passes.",
choices = { { text = "Why not?", next = "why" },
{ text = "Fine." } } },
why = { who = "Guard", text = "The door is locked, and I have no key.",
choices = { { text = "I have a key.", when = 'has("key")', act = { { "setVar", name = "allowed", value = true }, { "addScore", amount = 1 } }, next = "ok" },
{ text = "I see." } } },
ok = { who = "Guard", text = "Then go ahead." }
}
}
},
rules = {
{ note = "A click on the floor walks there",
on = "pressed", switch = "SWITCH_BUTTON3", interrupt = true,
act = { { "walkToPointer", entity = "hero", player = 1 } } },
{ note = "Look at anything",
on = "verb", verb = "look",
act = { { "say", text = '"It is a " .. event.target .. "."', seconds = 1 } } },
{ note = "Take the key",
on = "verb", verb = "take", target = "key",
act = { { "walkToHotspot", entity = "hero", target = "self" },
{ "give", item = "key" },
{ "addScore", amount = 1 },
{ "destroy", entity = "self" } } },
{ note = "Talk to the guard",
on = "verb", verb = "talk", target = "guard",
act = { { "walkToHotspot", entity = "hero", target = "self" },
{ "face", entity = "hero", target = "self" },
{ "talk", dialogue = "guard" } } },
{ note = "Open the door while the guard objects",
on = "verb", verb = "open", target = "door",
when = { { "test", expr = "not allowed" } },
act = { { "say", text = '"The guard shakes his head."', seconds = 1 } } },
{ note = "Open the door: the cut-scene",
on = "verb", verb = "open", target = "door", room = "hall", controls = false,
when = { { "test", expr = "allowed" } },
act = { { "walkToHotspot", entity = "hero", target = "self" },
{ "say", text = '"The door swings open."', seconds = 1 },
{ "fade", seconds = 0.5, out = true },
{ "goTo", room = "yard", entity = "hero", at = "arrival" },
{ "fade", seconds = 0.5, out = false },
{ "addScore", amount = 1 },
{ "setVar", name = "outside", value = true } } },
{ note = "Use the key on the door",
on = "verb", verb = "use", item = "key", target = "door",
act = { { "say", text = '"It is not that kind of lock."', seconds = 1 } } },
{ note = "Anything else",
on = "verb",
act = { { "say", text = '"That does not work."', seconds = 1 } } },
{ note = "Typed: look at the door",
on = "said", verb = "look", noun = "door",
act = { { "say", text = '"A heavy door."', seconds = 1 } } },
{ note = "Typed: a word the game does not know",
on = "said",
when = { { "test", expr = "event.unknown != nil" } },
act = { { "say", text = '"I do not know the word \\"" .. event.unknown .. "\\"."', seconds = 1 } } },
{ note = "Typed: anything else",
on = "said",
act = { { "say", text = '"You cannot do that here."', seconds = 1 } } },
{ note = "The verb keys",
on = "pressed", key = "L",
act = { { "setVerb", verb = "look" } } },
{ note = "The readout, every frame",
on = "frame",
act = { { "setText", entity = "readout", text = '(sentence or "") .. " score " .. score' } } }
}
}