Constructing an action from two nouns and an action name

Sorry if this was already asked somewhere. What I’m trying to do is implement combat commands that you can select from a menu instead of typing them in. My train of thought was that you would store the actor and its target in variables, select an action name from a table and then let the game create an action ‘try actor + action name + target’. This doesn’t go well though since try only does work when the noun is already provided in the table entry (e.g. ‘attacking yourself’). Is there any established way to solve that problem?

On an unrelated note, I would also would like to include action point costs for those actions. This should be managebale easy enough, if you extract the action name and look up table entries but I was wondering if there was a possibility to combine costs and action together via an attribute or something.

For your first question, unless I’ve badly misunderstood you can use the extension Editable Stored Actions by Ron Newcomb.

For your second question, you can’t give action names properties; you get this error:

So you’ll need to use the table, I think.

That extension looks like it might do the trick. Thank you very much for pointing it out!

Gotta a little complaint about the code though:

To decide what arithmetic value of kind K is the (name of kind of arithmetic value K) part of (act - a stored action):

This does conflict with some of mine:

Definition: A person (called actor) is dead if number of critically wounded vital body parts which are part of actor > 0.

Inform 7 will try to read the ‘part of’ like the above and interpret ‘actor’ as a stored action. I fixed it by calling the above ‘action part of’ instead to avoid confusion. Not a bug per se, as far as I can tell, but still something to consider.

That’s odd. I think you can also fix that by changing “which are part of actor” in your code to “which are incorporated by actor”; I think “incorporated by” should be the same as “part of.”

(See section 26.5 of the documentation, which talks about how “incorporate” was added as a verb for the whole-part relation in build 5T18 in April 2008.)

Anyway, though, it seems undesirable for Editable Stored Actions to break the “part of” language. I’ll alert Ron, though fixing this in Editable Stored Actions would break the code of projects that use it. It’d be a pretty easy fix to unbreak them though and I’m not sure how many people besides me that would be a problem for.

I’m surprised that that breaks. Hm. Testing…

It doesn’t break every usage of “part of”. You can still say “now X is part of Y”. In fact you can write your definition as

Definition: A person (called actor) is dead if a critically wounded vital body part is part of actor.

Wonder what the difference is.

My take that your example doesn’t break is that you don’t work with names of kind of arithmetic values (number of body parts) but names of kind of things (body parts themselves), so the To phrase from the extension doesn’t fire.

It does like a lot more smoother piece of code though, compared to counting through the individual body parts, like I did :confused:

@matt w
incorporated works too, thanks for pointing that out.