I keep seeing interesting threads about Inform 7 where people pull out these crazy tricks (like toggling the ‘scenery’ property on and off or stopping time).
I thought it might be fun to have a thread where people write down cool tricks they’ve discovered that other people may not know. (Advanced authors will probably already know a lot of these, but this thread is for beginning-to-middle range authors like me to learn from).
One thing I didn’t know when writing Color the Truth last year was that Inform treats NPCs and PCs the same, keeping track of their inventory and location, and you can say ‘Now the player is Alice’ and it will change to location to Alice’s location, the inventory to Alice’s inventory, and the ‘x me’ description to Alice’s description, while leaving the former PC somewhere.
One major trick that I feel everyone knew but me is that you can make any text contain Inform code. For instance, if you have cycling text like this:
Carry out pinching the player:
say "[one of]Ouch![or]That really hurt![or]That left a bruise![or]No way, man, not again![stopping]"
and want a bruise to appear after the third message, you could either set up a counter (messy) or just do this:
Carry out pinching the player:
say "[one of]Ouch![or]That really hurt![or]That left a bruise![addbruise][or]No way, man, not again![stopping]"
The bruise is a thing. "You left a mark!"
To say addbruise:
now the bruise is part of the player;
The [addbruise] is not printed, it just signals to the compiler that you want to do something, which you define by the ‘to say addbruise’ phrase. I thought this was really cool when I saw it, and I’ve used it a lot for things like responses to standard verbs.
What code tricks do you use that people might not know about?