Syntax to programmatically give a command to an Object?


I’ve forgotten a lot of what I once knew about Inform 6, and I’ve found this particularly tricky to search for, so I’m hoping someone here knows.

If I want to have a routine cause the equivalent of the player typing “get lamp”, I could use the statement <Take brass_lamp>.

But, what if I want to cause the equivalent of the player typing “Floyd, get lamp”? I tried <floyd Take brass_lamp> which understandably didn’t work. I also tried setting actor first, which seemed to have inconsistent results:

actor = floyd;
<Take brass_lamp>;

Does anyone know a standard, correct way to do this?

Like with all things, I could factor out the relevant behavior into a method on floyd and call that both in the orders rule and where I want to invoke the command, but I think sometimes it would be cleaner to keep the logic in orders and be able to call it.

Thanks in advance!

I believe it’s <Action noun, actor>. (Yes, this is bizarre. It’s a consequence of I6’s syntax growing organically over the years instead of ever being properly planned out.)


You might have to say <Take brass_lamp nothing, Floyd> though. I can’t remember if it needs all four arguments. EDIT-ADD: Nope, <Take brass_lamp, Floyd> is fine.

Also, this feature is only supported in library 6/12. Earlier library versions ignore the actor argument.

See related discussion at: Generating actions through code where player is not the actor.

Thank you very much, all! I definitely wouldn’t have guessed that, and I was still on the version of Inform 6 that comes packaged with Ubuntu 22.04, which appears to be 6.31. I’ll look at upgrading and trying it out!