!Links and Links !By Jayson Smith !This game was written to demonstrate the usage of my links.h library !extension for Inform. For more info about the different classes defined, !please refer to links.h. !This game and the library it is meant to demonstrate may be distributed !freely. Having said that, if you use any of this code, I'd appreciate !at least a "Thank you" in your game. !Note that if you have absolutely no clue what this is all about, either !go and play Andrew Plotkin's excellent game, "Spider and Web", or look at !the piece of paper in this game. !Also, this is a modified version of another game I wrote to demonstrate !this library. However, the original had so many S&W objects, complete !with spoilers, that I felt I couldn't release it publicly. constant story "Links and Links"; constant headline "An Interactive Test program for the links.h Inform Library^ Library and game written by Jayson Smith^ Original idea for library inspired by ~Spider and Web~, by Andrew Plotkin^"; include "parser"; include "verblib"; include "links"; include "grammar"; class room has light; room room1 "The first room" with description "This is the first in a series of rather nondescript rooms. There's an exit to the north.", n_to room2; object box "large box" room1 with name "box" "large" "big", with describe "There's a large box on the floor here.", with description [; print "It's just a large box, made of some plastic material.^"; if (self hasnt open) "It's closed."; print "It's open"; if (children(self)==0) " but empty."; print ", and it contains "; writelistfrom(child(self),fullinv_bit+english_bit+recurse_bit); print ".^"; ], has container openable open; room room2 "The second room" with description "This is the second in a series of rather nondescript rooms. There are exits to the north and south.", n_to room3, s_to room1; room room3 "The third room" with description "Wow. Yet another nondescript room!^ There are exits to the north and south, but to tell you the truth, neither of them look particularly inviting.", s_to room2, n_to room4; room room4 "The forth room" with description "Guess what? Yet another very nondescript room!^ But this time, you've reached the other end. There's only an exit to the south!", s_to room3; actuator button "button" box with name "button" "pushbutton", with description "It's a small button which can be used to activate something.^", with before [; push: self.brief(); rtrue; ], has pluslink; device beeper "beeper" box with name "beeper", with description "It is a small box which beeps when activated.^", has minuslink, with brief [; if (testscope(beeper)) "The beeper beeps a few times then stops."; ], with turnon [; if (testscope(beeper)) "The beeper starts beeping."; else "You hear a beeping from somewhere nearby."; ], with turnoff [; "The beeping stops."; ]; switch toggle "toggle switch" box with name "toggle" "switch" "flipswitch", has pluslink, with description "It is a switch used to activate or deactivate something."; device flashlight "flashlight" box with name "flashlight" "flash" "light" "lamp", with description "It is just a small light source. It looks like it could light a room enough to see by.", with turnon [; print "The flashlight starts to glow.^"; give self light; rtrue; ], with turnoff [; print "The flashlight stops glowing.^"; give self ~light; rtrue; ], with brief "The flashlight glows briefly then goes dark.", has minuslink; remote rcontrol "remote control" box with name "remote" "control" "controller", with description "It's a small square with three buttons, marked ~on~, ~off~ and ~brief~. It doesn't have a link, but works via a remote receiver module.^", with baseunit recmod, with turnon [; self.baseunit.turnon(); ], with turnoff [; self.baseunit.turnoff(); ], with brief [; self.baseunit.brief(); ], has transparent; object onbutton "on button on the remote control" rcontrol with name "on" "onbutton", with description "It is one of three buttons on the remote control unit.", with before [; push: if (rcontrol has on) "Nothing happens."; give rcontrol on; print "The remote control beeps once.^"; rcontrol.turnon(); rtrue; ]; object offbutton "off button on the remote control" rcontrol with name "off" "offbutton", with description "It is one of three buttons on the remote control unit.", with before [; push: if (rcontrol hasnt on) "Nothing happens."; give rcontrol ~on; print "The remote control beeps once.^"; rcontrol.turnoff(); rtrue; ]; object briefbutton "brief button on the remote control" rcontrol with name "brief" "briefbutton", with description "It is one of three buttons on the remote control unit.", with before [; push: if (rcontrol has on) "Nothing happens."; print "The remote control beeps once."; rcontrol.brief(); rtrue; ]; actuator recmod "remote receiver module" box with name "remote" "receiver" "module", with description "It's a small box with no controls. It is obviously a remote control receiver module, meant to be used in conjunction with a remote control.^", has pluslink; device bomb "bomb" box with name "bomb" "small", with description "This bomb is rather small, but it's very powerful!", with brief [; if (testscope(self)) { print "BOOM!^ The bomb explodes so near you that you are killed from all the noise and junk flying all about, not to mention the explosion!^"; deadflag=1; rtrue; }; print "You hear what sounds like a large explosion from somewhere nearby. Oh no! It's your bomb, and it's even more powerful than you'd imagined! The explosion is soon over, but the building can't hold up to it, and soon crumples.^"; deadflag=1; ], with turnoff [; "Once this bomb is turned on, the game ends. So it can't ever be turned off! [bug]"; ], with turnon [; self.brief(); ], has minuslink; [initialise; location=room1; print "Well, finally, here you are, in the building of Links and Links.^ You've waited for all your life to come here, and now you have all these toys to play with! So play with them!^"; print "Note: There is no objective to this game except to have fun! In particular, there is no way to win.^"; ]; object paper "piece of paper" room1 with name "piece" "paper" "sign" "note", with describe "You almost miss a piece of paper on the floor.", with description "Welcome to ~Links and Links~! This is an example game meant to demonstrate my links.h library file. If you have absolutely no idea what this is all about, go play Andrew Plotkin's excellent game, ~Spider and Web~. If you've already played it, what you do here should be obvious. For those of you who have not played S&W, here's a brief summary:^ There are several objects in the box. Those with a plus link are actuators and are meant to be used to activate devices. Devices have a minus link.^ To link two things together, just ~link xxx to yyy~. To unlink, just ~unlink xxx~^ Please substitute real object names for xxx and yyy in the above examples.^ you can find out which objects have plus and minus links by examining them.^ Note that you can't link two objects with plus links, or two objects with minus links, together. In actuality, there's no reason you'd ever want to do this, so it's not a problem.^ Have fun!^";