Tables at Every Turn

Greetings again. Just when I thought I was catching on, I ram into a wall. I can repeat through tables and I can say things based upon a condition, but I can’t seem to do BOTH at the same time. Inform complains about if’s and colon/indentation formatting…even when there isn’t any indentation.

I’m trying to say a different phrase each turn while at a particular location. This first snippet works fine:

Every turn when the player is in the Drawbridge: say "The gap widens yet further."
It’s when I want to use the same concept with a table that everything seems to change. And then what was there before stops working altogether.

[code]Every turn when the player is in the Drawbridge:
repeat through Table of BridgeGaps:
say “[gap text entry][paragraph break]”;
rule succeeds.

Table of BridgeGaps
gap text
“The gap widens further. The bridge is only three-quarters of the way extended now.”
“The bridge extends over only half of the abyss. The pedestal now begins moving with the bridge toward the featureless rear wall. There is no where to go but down.”
“Only one quarter of the bridge extends now into the space above the abyss.”
“A tiny ledge remains of bridge, and now even the pedestal begins sinking into the surface. You search frantically for some kind of purchase but find none.”[/code]
I’ve found a few postings here that almost did the job. One used the idea of a scripted scene during “introductions”, blanked out each line, and then declared the intros over when all the rows were empty. Maybe I should just do that, but I’m really curious as to why THIS doesn’t work. I’m starting to think the two concepts are incompatible.

Thanks!

Just a guess: the complaint about indentation might be because you have indented your table entries. Those should just begin at the beginning of the line; tabs are then used for further columns.

Of course, the code you’ve written here wouldn’t do what you want even if you fix it. The game will now repeat through the Table of BridgeGaps every turn, thus printing all the four entries in succession every turn.

Say “[one of]The gap opens…[or]The bridge extends…[or]Only one…[or]A tiny ledge…[stopping]”.

Relevant documentation is Chapter 5.7. Text with random alternatives.

If you wanted to stay with the table structure…something like the following seems to work when I tried it.

Drawbridge is a room

The current-row is a number that varies. The current-row is 1. 

Every turn when the player is in the Drawbridge:
	choose the row current-row in Table of BridgeGaps;
	say "[gap text entry]";
	if current-row is less than the number of rows in Table of BridgeGaps:
		increase the current-row by 1.
	  
Table of BridgeGaps   
gap text
"The gap widens further.  The bridge is only three-quarters of the way extended now."
"The bridge extends over only half of the abyss.  The pedestal now begins moving with the bridge toward the featureless rear wall.  There is no where to go but down."
"Only one quarter of the bridge extends now into the space above the abyss."
"A tiny ledge remains of bridge, and now even the pedestal begins sinking into the surface.  You search frantically for some kind of purchase but find none."

I’m new to Inform myself so perhaps there are better ways to handle this.

The trace of the error was up at the “Every turn” line rather than involving the table itself. I could never get it to go that far. :slight_smile:

I see what you mean. I not thinking that part through–which would have become apparent had I been successful in beating any of the examples to do my bidding, such as http://inform7.com/learn/man/ex258.html#e258 or [url]https://intfiction.org/t/help-with-scripted-scenes/5101/1].

I’ll take a look. Thanks!

Thanks! I’ll see how it goes.

I’m picking it up, but I feel like there are just some unwritten rules that only experience teaches. I’ve done a good deal of administrative scripting, and some C (as in not ++ or #) and I wonder if some of my instincts aren’t hindering me. :slight_smile: For instance, my love of tabbed indents.

In learning inform myself, coming at it with extensive programming experience, the very most important thing you can learn is that inform is NOT natural language. It is a programming language with it’s own very specific, often obtuse syntax, and you have to be just as exacting as in any other language. Where Inform7 code reads well and looks like natural language, it’s because the author has taken the time to carefully define the adjectives and activities needed to support their code.

Every time you peel another layer off inform your opinion on the language is going to change. It’s going to seem a gross and horrible pile of hacks at one moment, and then a true wonder of software engineering the next.

I’m coming at it from a C# & C++ background myself and while I’m picking up quickly on the language, it’s some of the formatting constraints that are tripping me up myself. I for one keep trying to use semi-colons incorrectly…getting there, but still trips me up at times.

Inform is a very specific dialect of English. There’s a hump to get over. At first it’s all “Oh this is so easy,” then “Oh my god this is so stupid,” then "Okay, I know what that error means, I just have to find [my extra bracket/my forgotten semicolon/my misplaced indent/my instead that should have been a check/my accidental mention of that room in lower case before I actually created it/that verb I forgot to define for actors other than the player/…]

If you have some experience decoding the error messaged produced by C++ templates, you should be okay with Inform’s. The error messages are a lot simpler, but generally about as cryptic. For example, if it tells you it was expecting a condition in a ‘now’ directive, it didn’t understand what you were assigning to.

Thanks to Blecki! (and everyone else). I really was trying to make this more difficult needed.

Every turn when the player is in the Drawbridge: say "[one of]Message 1...[or]Message 2...[or]Message 3...[or]Message 4...[or]Message 5, blah blah you waited too long...[stopping]"; if turn count is 5, end the story finally saying "You tumble into the abyss and fall.".

Yep that is much easier. I use that construct elsewhere, not sure why I didn’t think of that myself! :smiley: