Unsure how to do or if possible...

TFG
21 Sept 2013, 06:58
Firstly, it should be addressed I am trying to make a text adventure game, but am mimicking a sort of gamebook feel. What I am trying to do, however, is hyperlink certain "options" to let the player make various choices. I tried creating objects and hyperlinking them to do this, but it isn't working out how I want.

What I want is to have something hyperlinked and that run a variety of scripts when clicked upon. For example, if the character is asked if he wants a cup of coffee or not, I want to have the options to "accept" or "decline". Then, if "accepted", it prints a bit about it being given to him and then his tiredness is decreased an X amount. I know this is a shoddy example, but I can't really go into detail since I have no idea how it can be done and what it'd really look like implemented.

Can this be done using commands? I know you can hyperlink commands but I don't really know how to use those yet, what purpose they serve, or what the use of hyperlinking them is.

jaynabonne
21 Sept 2013, 09:31
Hyperlinked commands sound like exactly what you want. They create hyperlinks which, when clicked, will execute a command script. Here is an example (in code):

  <command name="AcceptCommand">
<pattern>accept</pattern>
<script>
msg ("You take the coffee and now feel more alert.")
</script>
</command>
<command name="DeclineCommand">
<pattern>decline</pattern>
<script>
msg ("You sniff at the coffee, but it's not what you're in the mood for at the moment.")
</script>
</command>

This defines two commands, one for "accept" and one for "decline". The pattern defines the text you need to pass in your hyperlinked command. You can then print out a menu like this:

      msg ("{command:accept:Accept the coffee}")
msg ("{command:decline:Decline the coffee}")


"command:" is a text processor command. The first part between the colons is the text executed, as if the player had typed it in. This should match the pattern of a command. (You can even execute built-in Quest commands and verbs this way.) The last part is the text to show.

Note that you can create commands on a per-room basis. So if you're simulating a game book by moving from room to room, then the commands defined in each room will only be active when you're actually in the room.

I also have some code I could pass along which is a single "DoScript" command, which executes named scripts on named objects, with parameters. But that might be a bit more than what you need. Let me know (anyone) if that would be useful.

TFG
21 Sept 2013, 11:09
Wow, this is just what I wanted. Thanks! I really appreciate you explaining it in detail, makes it a lot easier for noobs like myself to understand.