Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Sep 10, 2025. It is now read-only.

Conversation

@skx
Copy link
Owner

@skx skx commented Jul 26, 2024

Once this pull-request is complete we'll have support for custom / per-item actions.

Currently we have a generic "USE FOO" option, and we have declared synonyms such as "READ" for "USE". This means you can enter:

  • READ TORCH
  • LIGHT BOOK

Those things work due to the synonym, but they're clearly crazy. So what we want to do is store per-item actions specially so that "READ BOOK" works, but the READ verb only works on the book, not other items.

We already have per-object "TAKE", "DROP", "EXAMINE", functions which probably get simplified, but that would be a bonus.

Implementation will be broken down into logical steps, and I will ensure the game is playable at each commit.

Once complete this closes #23.

skx added 7 commits July 26, 2024 05:31
This commit:

* Makes a couple of trivial one-byte size optimizations.
* Adds space in our item-table for a pointer to custom actions.

In the future we'll have a per-object set of verbs, such as "READ"
which only works for "BOOK".  Right now I've just declared space for
it as I work on the implementation.

Confirmed the game still plays correctly with this change, just for
paranoia's sake.
This commit adds a simple table for per-item actions, and moves
the "READ" function into the entry for the book.

We don't yet invoke the handler, but we do successfully look for
a) the object, and b) the custom verbs for it.  If they're not
present we continue - otherwise we show a temporary debugging
message to confirm an action was found.
This commit allows us to run "READ BOOK", and "MOVE RUG", without
also allowing "READ TORCH", or "MOVE BOOK"!

Success.  Though it seems like I need to work on the text a little,
since examining the book now will also read it.

I could say "You can't use the telephone without having read the
book", but that feels a bit pointless.   I'll just change the examination
to provide a hint to _read_ in the future.
In the past we removed " THE " and " ON " from input, to avoid
issues with "TAKE THE RUG" and "TURN ON TORCH".  Now we've updated
so that our routine to fetch the "second" word always takes the
*last* word:

* TAKE THE TORCH -> TORCH
  * Not "THE".

This means we can have an abitrary prefix for custom actions,
and that means we don't need to care about the extra ON/THE.

Also I've implemented OPEN/CLOSE trapdoor and TURN ON/OFF/LIGHT
the torch.  These "just" do a toggle, but that's okay for now.

We only have one custom use function left, which refers to the
generator.  We should probably change that to "start".
Since this was only necessary to start the generator I've added
an explicit "START GENERATOR" handler.  This cuts down on our
code, and also simplifies things.

I've hidden the CLEAR command from the output of help.

The game plays successfull and both exit conditions work.
@skx skx merged commit 3129da9 into master Jul 26, 2024
@skx skx deleted the 23-actions branch July 26, 2024 14:58
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Possible changes to item-table for z80 implementation?

2 participants