Overriding all commands in specific room

I'm trying to do something similar to what's described here:
https://textadventures.co.uk/forum/quest/topic/3650/while-loop-that-loops-until-the-user-types-the-right-thing
where I'm waiting for a particular command, and throwing the same message for anything else the user might type.

However I don't really want to use get input{} cause they don't display the same way commands do (e.g. the users commands continue to be shown but inputs disappear). I tried making a room-specific command with the pattern #text# (and I would check if it matched the particular command I'm looking for) as I just assumed that would override everything else, but it seems that commands like look, inv or x self would still work as usual.

One possible solution I'm considering is just "faking" the command display (by printing the user's input as part of the message each turn) but I would still like to know why doesn't the #text# command in the room override everything like I thought it would and if there's any way I could still make that work, cause it just seems simpler. Tys.


I tried making a room-specific command with the pattern #text# (and I would check if it matched the particular command I'm looking for) as I just assumed that would override everything else, but it seems that commands like look, inv or x self would still work as usual.

This should work. A command in the current room always takes priority. Can you show us the game (or an example game showing this issue)?


Sorry, I just realised I don't even know how to put an attachment on forum posts 😅


Sorry, I just realised I don't even know how to put an attachment on forum posts 😅

Sadly they don't do attachments. But if you upload it to the website you can post the address here. (You can publish a game with the privacy set to "only people I share the link with" or something, so other people can't see it, and then change it to public when the game is ready for release - although once published, you can only hide a game, not delete it, so it's on your "my games" page forever)


Mmmm, here's a dropbox share link:
https://www.dropbox.com/s/jcm7w9sk6x261rw/Game.aslx?dl=0
hope that works.

In particular, x self is surprising here in that it neither displays my "intended" message nor the player's description, but the default.


One alternative woild be giving the command a regular expression pattern like .* rather than #text#; as it doesn't capture the actual command typed, so the parser thinks it's more specific. But this really shouldn't be necessary.


That worked, thanks so much!
Just in case anyone's interested, I had two room specific commands now: one with the other with the pattern .*, and another with the particular command pattern I'm waiting the player to type in.
I don't know if the order I created those commands matters but it was in the order as was described.


Oh wait, actually I have one more question quite unrelated if that's okay!

How can I find the first key of a dictionary? I noticed they seem to be ordered as when I iterate over every key in a dictionary, it always happens in the order that I added the keys in. But what if I want to print the value of the first key only?


Oddly enough, there doesn't seem to be an easy way to access the keys of a dictionary. And in the absence of a break/last command, it's not so easy to retrieve it. I would recommend making a function:

<function name="FirstKey" parameters="dict" type="string">
  foreach (key, dict) {
    return (key)
  }
</function>

Basically, using a foreach loop, and exiting it by using return on the first time through.


God bless you dear sir


such an informative thread, thanks everyone


Log in to post a reply.

Support

Forums