-- ACTUAL CODE BEGINS--
"online example" by Kevin Sanderson-Doughty
Include Basic Screen Effects by Emily Short.
Table of Beginning Text
left central right
" " "" ""
" " "It was the best of times" ""
" " "" ""
" " "" ""
Table of Middle Text
left central right
" " "" ""
" " "or was it," ""
" " " in fact..." ""
" " "" ""
Table of End Text
left central right
" " "" ""
" " "" ""
" " "the worst of times?" ""
" " "" ""
Rule for constructing the status line:
if location is Beginning, fill status bar with Table of Beginning
Text;
if location is Middle, fill status bar with Table of Middle Text;
if location is End, fill status bar with Table of End Text;
rule succeeds.
Beginning is a room.
Middle is a room. Middle is south of Beginning.
End is a room. End is south of Middle.
-- ACTUAL CODE ENDS --
While this does accomplish what I'd like to do, I'm hoping there's a
more elegant way of implementing this as there are several more rooms
than three, and I'd like to make things as simple as possible for
anyone else who would like to use the format I come up with.
What I'd like to do is some sort of text substitution within the code
itself for constructing the status lines. The following, I hope, gets
across the idea of what I'd like to do (n.b. I'm using the displayed
text format for text substitution in the following):
-- WISHFUL CODE SNIPPET BEGINS --
Rule for constructing the status line:
fill status bar with Table of [printed name of location] Text;
rule succeeds.
-- WISHFUL CODE SNIPPET ENDS --
My thanks in advance for any and all help with this. And my apologies
if I don't reply to any suggestions quickly. I'm traveling and my
access to the Internet is going to be very scattershot for the next
several days.
How about this?
***
"Online Test" by Matt Wigdahl
Include Basic Screen Effects by Emily Short.
Table of Stuff
left central right
" " "" ""
" " "[if location is Beginning]It was the best of times[otherwise if
location is Middle]or was it,[otherwise]the worst of times?[end
if]" ""
" " "[if location is Middle] in fact...[otherwise][end if]" ""
" " "" ""
Rule for constructing the status line:
fill status bar with Table of Stuff;
rule succeeds.
Beginning is a room.
Middle is a room. Middle is south of Beginning.
End is a room. End is south of Middle.
***
Matt
Also, if the inline substitutions get too involved with the extra
rooms you're adding, you can rearrange things like so:
Table of Stuff
left central right
" " "" ""
" " "[second status line]" ""
" " "[third status line]" ""
" " "" ""
To say second status line:
if location is Beginning:
say "<whatever>";
otherwise if location is Middle:
say "<whatever2>";
... etc.
Hope this helps!
Matt
The "table-name" type can be used to put tables in variables and
properties. So you could do something like this:
<code>
A room has a table-name called the status table.
Beginning is a room. The status table of Beginning is the Table of
Beginning Text.
Rule for constructing the status line:
fill status bar with the status table of the location;
rule succeeds.
</code>
vw
Thanks for the suggestions, Matt. Both are very helpful in my
learning more about how Inform coding works.
I'm probably going to with vaporware's suggestion below, mostly
because it will help keep things grouped in a way my brain can track
more easily. Also, I am going to have another table per room that's
directly related to the text displayed in the status line, and I think
the method vaporware forwards will help me keep track of the
connections between the two tables.
Again, many thanks for the suggestions.
-- Kevin
Thanks, vm, for the suggestion. Looks much tidier than what I was
coming up with. I believe your code will also help with another table
group I was planning in implementing that would be a set of tables
each specific to a particular room and directly related to the text
displayed in the status line. I'll give it all a go and let you know
what happens.
Again, many thanks.
-- Kevin
No problem! I like vaporware's answer also; tables make a really nice
way to keep data organized if it's nice and structured.
Matt
Many, many thanks, vaporware! Your suggestion worked a treat for both
areas I was wrestling with.
-- Kevin