Conglomerating similar very long functions from similar games: code review-ish question

(Apologies to @aschultz if I thread-jacked. It’s on topic if you view it as what now seems like a viable means to replace the body of the repeat loop in your verb-checker rule with following the rules of a rulebook, which would let you split it up into rules and to express most of those conditionals as rule preambles.)

2 Likes

I’m thinking, for this case, this might be good:

The rb rulebook has a number called row-id.
rb a number (called n) (this is the set row-id rule): now row-id is n.
The set row-id rule is listed first in the rb rules.

[ now other rules can just use `row-id` ]
rb:
let x be the code column for row row-id in the table of spam;

Sure, but for something like this I don’t think there’s much benefit to making the author type that every time. Just store the table name and row number in global variables in the “first” rule, then have a phrase that consults those globals that can be used in every rule.

Imo Inform’s greatest strength is its readability, and when this phrase won’t ever be used with any parameters except “row-id” and “table of spam”, we can boost readability by removing them from the invocation. Like how the Standard Rules define “carried” and “worn” as equivalent to “carried by the player” and “worn by the player” to improve readability in the most common case.

1 Like

No problem with this … sorry for the delay in responding! There’s so much to process, I may not get to it right away, and also I wanted to re-release major fixes for everything on 11/22 because, well, reasons. So more in-depth stuff like has to slide compared to immediate testing and fixes, but I feel understanding this can help me still grow and learn Inform after many years of using it.

It wasn’t until relatively recently that I used rules acting on a direction or number or whatever, so I have so much to learn there.

And I was hoping to give a roll up response to this, but I’m surprised how much time I need to digest this all – and I appreciate everyone who’s stopped by with suggestions and requests. I had a feeling my code did the job but was a bit long. Making it smoother was a holy grail, but after a brief perusal, it seems so much more achievable now.