game.title = "Demo game"; game.author = "Mike Buland"; game.version = 1; game.revision = 0; game.start = <>; global { command: "go" dir { if exists(situation.exits) then { if dir in situation.exits then { goto( situation.exits[dir] ); } } display('''You're not really sure how to do that...'''); } command: "exits" { if exists(situation.exits) then { out = "Obvious exits are: "; bFirst = true; for each dir : dest in situation.exits do { if bFirst then { bFirst = false; } else { out += ", "; } out += dir; } display( out ); } else { display("There are no obvious exits."); } } command: "take" item { if exists(situation.items) then { if item in situation.items then { situation.items -= item; player.inventory += item; display("You take the " + item); return(); } } display("You don't see that anywhere."); } command: "inventory" { out = 'You are carrying: '; for each item in player.inventory do { out += " " + item; } display( out ); } // You should always have a global exit, quit, escape, something for // dev-testing at least. command: "exit" { exit(); } } situation <> { setup { player.inventory = []; goto( <> ); } enter { } } situation <> { setup { situation.exits = { 'south': <>, 'east': <> }; situation.items = ['postcard']; } enter { display('''You are in the dining room, it's very nice and warm. There is a big table and...stuff. Looks like the living room is south, and the kitchen is to the east.'''); } } situation <> { setup { situation.exits = { 'north': <> }; } enter { display('''Living room!'''); } } situation <> { command: "open" "cupboard" { if not situation.bCupboardOpen then { situation.bCupboardOpen = true; if "pan" in situation.cupboardItems then { display("You open the cupboard, it's mostly empty. There is a single frying pan inside."); situation.cupboardItems -= "pan"; situation.items += "pan"; } else { display("You open the cupboard, it's empty."); } } else { display("The cupboard is already open."); } } setup { situation.exits = { 'west': <> }; situation.bCupboardOpen = false; situation.cupboardItems = ['pan']; situation.items = []; } enter { display('''You are standing in the kitchen. There is an electric range, a microwave, cupboards, a fridge, and a window.'''); } }