Please help a newbie out! (referring to a particular instance of a kind in a rule)

Hello everybody. I’ve been occasionally lurking for a while but haven’t created an account 'til just now.

I got into Inform 7 less than a week ago so I’m still pretty clueless about most things. I have been studying (I think anyway) hard though, and think I have a burgeoning feel for the very basic essentials. I’m pretty motivated because I have a game I want to make. Its skeleton is already designed so it’s only a matter of implementation and fine-tuning. I’m attempting to make it as I go, but that naturally presents me with frequently arising problems that take me a pretty long time to solve. So I thought I’d create a thread and see if the community can occasionally save me some headaches.

Now I’ve been banging my head against this one particular problem for hours now. I’m trying to create a core game mechanic. How it works is there are many books lying around, some of which contain riddles that I want the player to have in their inventory after finding them, for quality of life reasons. All my code should be working except for the very last rule.

Here’s the source for the mechanic:

A journal is a kind of container. It is closed and openable. A journal can contain only clues. Understand “notes” as the journal. The player carries a journal called a notebook. Instead of dropping the journal: say “You really should hold on to that.”
A clue is a kind of thing. Clues are scenery. Instead of doing something other than taking or examining a clue: say “That’s not how text works.”
Understand “ripping [a clue]” as taking. Understand “page”, “poem”, “riddle” and “text” as a clue.
Instead of taking a clue:
say “What would the librarian say?!”;
if a clue is inside a journal:
say “And ruin your notebook? Self-sabotage? But why?”
After examining a clue:
if a clue is not inside a journal:
move the clue to notebook;
say “As the ink slowly fades from the page, you feel a vibrating sensation in your chest. As you reflexively grasp at it, you can feel your fingers closing tightly around the square shape of the journal in your breast pocket.”

And the problem in translation I’m facing is:

Problem. You wrote ‘move the clue to notebook’, but ‘clue’ is used in a context where I’d expect to see a (single) specific example of an object, not a description.

I was trying to match this phrase:

move (clue - object) to (notebook - object)

I recognised:

clue = a description of clues

notebook = a journal

I just can’t for the life of me figure out how to specify that I’m talking about that specific object that is being interacted upon. I really don’t want to specify that for every single clue in the game - there are quite a few! I feel I’ve tried everything and exhausted the documentation, but obviously I haven’t.

Help me Obi-wan Kenobi. You’re my only hope.

A million thanks if you can help me out, and sorry for being dumb.

4 Likes

Welcome to the forum, and congrats on getting started on your game!

The issue you’re running into is that, as you’ve intuited, “the clue” is too general for the compiler to understand. Fortunately, there’s an easy way around this, which is to add a label to the rule preamble (that’s that first line introducing a rule, like “before…” or “after…”) and then use that label in the body of the rule to refer to the specific object you mean.

So in this case, you’d need to do something like:

After examining a clue (called the enigma):
	if the enigma is not inside a journal:
		move the enigma to notebook;
		say “As the ink slowly fades from the page, you feel a vibrating sensation in your chest. As you reflexively grasp at it, you can feel your fingers closing tightly around the square shape of the journal in your breast pocket.”

(By the way, you can paste code into forum posts using the “preformatted text” tool – it’s the one that looks like </> in the toolbar – which preserves whitespace and such, which as I’m sure you’ve experienced is really important for Inform!)

Note that “the enigma” is just the name I made up, you can use anything you like there and it will work. NB that you’d want to do this for your instead rule as well “if a clue is inside a journal” will evaluate as true if any clue is inside a journal, but I think from context you just want to check if that’s the case for the particular one the player’s tried to take.

One last bit of unsolicited advice – you have a potentially big bug in this line:

 Instead of doing something other than taking or examining a clue: say “That’s not how text works.”

I think you meant to write “something other than taking or examining to a clue”; omitting the “to” means that all actions, like looking around or going or anything beyond taking or examining a clue, will be blocked.

(I’m also not sure why you’ve made the clues scenery – that might cause some weird behavior later on, FYI).

Hope this is helpful! Definitely post again if you run into more speedbumps – though typically we encourage folks to make new threads for new problems, since separate posts with more descriptive titles help others struggling with the same challenges find the solutions. Anyway these are all pretty standard first-week-of-Inform challenges (if not slightly advanced) so seems like you’re running up the learning curve quite well so far – congrats and welcome again!

3 Likes

Have you tried move the noun to notebook? Or now the noun is part of the notebook? I think what’s happening is “clue” is referring to all of the clues, not just the one in question. Or something.

Please make a new thread for every issue, instead of creating one big “help” thread. I know it seems like spamming, but it’s not. But it would be much more useful for everyone if you have separate threads for each issue.

4 Likes

Thanks for the swift replies, and especially the sidenotes both language and forum related!

I’ll be sure to report back to you if I can’t make any of these solutions work, although I’m sure I can!

And sure, I’ll make separate threads for future problems. Thanks again.

2 Likes

Alright, just a quick update before closing this chapter.

test
Hey, a book!

You can see a tome and a magpie here.

test me
(Testing.)

[1] drop notebook
You really should hold on to that.

[2] x tome
There’s a poem there.

[3] take byron
What would the librarian say?!

[4] x byron
You see nothing special about Byron.

As the ink slowly fades from the page, you feel a vibrating sensation in your chest. As you reflexively grasp at it, you can feel your fingers closing tightly around the square shape of the journal in your breast pocket.

[5] take magpie then put it into journal
Taken.

That might soil the pages.

It’ll need some work later down the line, but I can work with it. Thanks for the input!

If locking the threads that have outlived their usefulness is a thing here, you have my leave.

edit: Forgot to include “/ i / open journal /” in that test but the journal works as intended too.