For devious reasons having to do with an extension I’m updating, it may be useful for me to define what in most programming languages would be called a function, method, or procedure. I7 allows new activities to be defined, but Chapter 18 makes it appear that an activity can be passed only one variable. I need to define something along these lines (pseudo-code):
[code]Spell-learning is an activity on persons and things.
Carry out the spell-learning activity on (P - a person) and (SP - a thing):
[etc…][/code]
What is the preferred syntax for doing this? Do I need to drop into I6?
To have (P - a person) spell-learn (SP - a thing):
let L be the spells-learned of P;
if SP is listed in L:
[etc....]
It compiles fine. And then:
Instead of an actor researching frotz in the book:
if frotz is learned:
say "[The actor] [have] already learned the frotz spell from the book.";
otherwise:
have the actor spell-learn frotz;
say "[The actor] [find] the page in the book describing the frotz spell, and [commit] the spell to memory."
But the compiler objects:
No, changing it to “the person asked” produces the same error. In any event, we know that “the actor” has a meaning when that block of code is reached, because the Instead rule uses “the actor” in its first line.
Changing the function from “(SP - a thing)” to “(SP - a spell)” likewise has no effect. I still get the error.
Can anyone supply a bit of example code in which a two-variable function of this type works correctly when invoked from an Instead rule?
I also tried changing the code to “To cause (P - a person) to spell-learn (SP - a thing)” on the theory that perhaps “have” is an I7 keyword. That didn’t help. Same error as before.
One thing that might help would be to paste the entire error message–usually after you get “That’s not a phrase I recognise” they give you a bunch of attempted construals of the phrase. Seeing exactly what those were might help us figure out what went wrong.
What went wrong was nothing to do with the code. It was to do with … well, I’m making major changes in Spellcasting. Specifically, I’m trying to set it up so that the player can ask someone else to cast a spell. For development purposes, I’ve created a new extension called Proxy Spellcasting. But the example code I loaded from Proxy Spellcasting still said, “Include Spellcasting by Jim Aikin.” Stupid error. So the example code was trying to run the original version of the extension, which didn’t have my new function in it.
In just a moment, I’ll have a far more interesting question…