Update to Table-Driven NPC Actions

After last Thursday’s article, Andrew Plotkin pointed out that I could have been using rules instead of activities. From his intfiction.org post:


“It will be simpler and take less overhead if you have a “rule” column and a bunch of one-off rules:

Code:
Table of Caleb Actions
completed	has-cards	Teo-playing	high-stakes	rule		message
true		true		true		true		foo rule	"Nah."

This is the foo rule:
	say "Foo."

And use “follow the rule entry” instead of “carry out the activity entry activity.”

Activities have before/carry-out/after rulebooks, but it looks like you’re not making use of that, so rules are just as good. Saves you typing all the “XXX is an activity” lines too.”


He is of course right, and I’m updating all my code accordingly. If you’re using the technique I described, I suggest doing the same.

Note that everything in the rule column must end with the word “rule”, as it will not compile otherwise.

Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *