Okay, I’m trying to figure out a way to set it up so that, when the player examines themselves, they get a big ol’ infodump explaining their health, how tired they are, and their inventory. Ummm…how do I do that? I don’t want to mess with the ‘examine’ command itself, since I know there’s a more elegant solution. I realize this is pretty much Inform Coding 101, but I’m still pretty confused here. Some help, please?
Assuming you’ve set up the necessary variables to keep track of things like health and fatigue as text variables, why not just use an “instead” rule to redirect examining the player to a “say” statement that embodies the appropriate information. Something like:
[code]Instead of examining the player:
Say “You are feeling [health of the player] and [fatigue of the player].[paragraph break]You are carrying [list of things carried by the player][paragraph break]Oh, and by the way, you’re still as good-looking as ever.”.
Edit : Sorry, I hadn’t noticed that you were talking about Inform 6. My bad.
You can make an object’s description a routine, as in
]; and then write whatever you wish in that routine:
[ LengthyPlayerDescription health fatigue;
print "You health is ",health,", your fatigue is ",fatigue,", and your inventory? "; <<Inv>>;
Any description can be a routine – it doesn’t have to be just text, and you don’t need to do anything in Initialise. I’m a little worried about EmacsUser’s code, in fact, because that sets up health as a local constant. In Initialise, you can call ChangePlayer:
ChangePlayer(dave);[/code] This sets up the dave object as the player. So then: [code]Object dave "Dave" with name 'dave' 'me', health 2, fatigue 0, description [; print "Your health is "; if (self.health > 5) print "excellent"; else if (self.health > 1) print "okay"; else print "a cause for concern"; "."; ],
…and so forth. My I6 is rusty, so this may be defective, but it may suggest a useful approach.
Ah, that’s it. I’d forgotten descriptions could = other routines and tried various other, more complicated was of calling up the routine. Thanks!
Oh, I’d forgotten about ChangePlayer! Well, in my version I have PlayerFatigue and PlayerHealth as global variables, so Emac’s code applies better to what I already have set up, but this is a great alternate setup (unless mine has other, more stealthy problems associated with it).
Right, those lines were meant to be stand-ins for health and fatigue computations. Since I didn’t know how Glorb’s code was organized, I probably should have made that clearer.