[Kind of Solved] A Command Link that runs multiple commands?

I understand the basics of a command link, that it looks like {command:[command run]:[text player sees]}. However, I have only found examples of running a single command per link, and I wish to run more. Specifically, I want a link to both move the player to a room and apply a flag (preferably on the player, but if something else is easier/the only way, it should still work).


A command link simulates the player running a command; not a script command.

If there's something the player can do that results in both moving and having a flag set, then create a command for it.

Or: What you want isn't a command link that runs more than one command. It's a command that has more than one effect.


you can have one or many script actions in anything that can hold scripts (Elements that can hold scripts: Commands, Functions, Object's Script Attributes, Turnscripts, Timers, Delgates, etc)

https://docs.textadventures.co.uk/quest/elements/command.html

an example of doing multiple script actions in a Command (and in the special 'game' Object's special 'start' Script Attribute too, and in my 'testing_object' Object's 'testing_script' Script Attribute, as well, lol):

<game name="NAME_OF_GAME">

  <attr name="start" type="script">

    invoke (testing_object.testing_script)

    msg ("{command:example:this is my example command}")

  </attr>

</game>

<object name="room">

  <inherit name="editor_room" />

</object>

<object name="room99">

  <inherit name="editor_room" />

</object>

<object name="player">

  <inherit name="editor_object" />
  <inherit name="editor_player" />

  <attr name="parent" type="object">room</attr>

  <attr name="alias" type="string">unknown</attr>

  <attr name="strength" type="int">0</attr>

  <attr name="flying" type="boolean">false</attr>

</object>

<object name="testing_object">

  <inherit name="editor_object" />

  <attr name="testing_script" type="script">

    msg ("Player Name: " + player.alias)
    msg ("Current Room Location: " + player.parent.name)
    msg ("Player Strength: " + player.strength)
    msg ("Player Flying: " + player.flying

  </attr>

</object>

<command name="example_command">

  <pattern>example</pattern>

  <script>

    player.alias = "john doe"
    player.parent = room99 // this will move the 'player' to 'room99'
    player.strength = player.strength + 5
    player.flying = true

    invoke (testing_object.testing_script)

  </script>

</command>

Thanks, you two, but I managed to finagle a workaround.

I just have the "go to" command move the player to a "dummy room" that applies the flag and immediately dumps the player into the true target room using "before entering" and "after entering" scripts. Clunky, bad code, probably, but it works!


If the command is "go to", you could also put a script on the exit so that it both sets a flag and moves the player.


Ah, didn't mention this because I didn't think it was relevant, but I'm making one of those enhanced gamebooks, "Pixie-style". I wanted all choices to lead to the same page, but apply different flags, because the result of the choice will hit the player later. The point of the flags is so I wouldn't have to copy-paste four-ish page-lengths worth of choices onto three branches, which I think would not just be clunkier than my "dummy rooms", but a huge headache to edit!


Ah, that makes sense. Yes, for a gamebook or CYOA the "dummy room" is the standard method.

There's a few different ways to do gamebooks in TA mode; some of them might give you more flexibility for something like this, so that the additional room isn't necessary. For example, if you're using exits to represent choices, you can have multiple exits pointing to the same destination but with different scripts on them. Or you could create a new command just for that room, which is called by command link.

In a text adventure, there's an option to allow multiple commands per line: a command like "get book. go north.". There's nothing to stop you using a command like that in a command link.
The best way to do it really depends on the system of your game.


Thanks! By getting me to look back and retool the exits, you don't even know how much you just helped me!

Turns out that, while I was toying around with the dummy room concept, I had used "Page04" to dump directly into "Page05", and changed Page04 to "Jelly" (one of the choices) without realizing what I'd done. At least I only have about a dozen rooms to renumber!

Anyway, so what I've taken away from this is that a Command Link doesn't need to be able to call multiple scripts, as long as the command being performed can, itself, call other scripts (rooms, exits, objects... basically anything)?

(Sorry if that's bad terminology. My coding knowledge is barebones and almost 20 years old.)


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums