I am relatively new to inform 7 but I have started working on a project about two weeks ago although I’ve been curious about it for years. I am trying to work independantly to learn the language (I try to work through my noobish problems myself usually) but in this instance I believe I may need a spot of guidance.
I am trying to impliment a system where the description of an object constantly changes upon consecutive observance. The person listening to the story asks questions, but if they ask the same questions consistantly the other character will get annoyed.
Before examining something:
say "[one of][line break][italic type]'And the [noun]? Tell me more about it.'[or][italic type]'Tell me about the [noun]'.[or][italic type]'What did the [noun] look like?'[or][italic type]'Could you describe to me the [noun]?'[or][italic type]'I'm interrested in this [noun]'.[at random]".
Instead of examining twice:
say "[one of][roman type]Didn't I already tell you about it?[or][roman type]There's nothing more to tell.[or][roman type]I told you all I know.[or][roman type]Fuck you. I just told you everything.[or][roman type]I told you all that I know, seriously![at random]"
This is the problem though.
This code will will give me the text when I use the examine command any two times for any two objects. I do not want this!
I want the character to get annoyed only when the same examination is asked CONSECUTIVELY.
Sorry this is probably a simple fix, but I’ve scoured to manual to no avail.
Map Room is a room. “Here is where you observe the Great Map.”
The great map is scenery in map room. The description is “The map is probably the most confusing diagram you have ever seen.”
a cool gem is here. “A cool gem lies on the floor.” The description is “It looks valuable.”
Before examining great map:
say “[one of][line break][italic type]‘And the [noun]? Tell me more about it.’[or][italic type]‘Tell me about the [noun]’.[or][italic type]‘What did the [noun] look like?’[or][italic type]‘Could you describe to me the [noun]?’[or][italic type]‘I’m interested in this [noun]’.[at random]”.
After examining great map more than once:
say “[one of][roman type]Didn’t I already tell you about it?[or][roman type]There’s nothing more to tell.[or][roman type]I told you all I know.[or][roman type]Fuck you. I just told you everything.[or][roman type]I told you all that I know, seriously![at random]”
Give each object a property “last turn examined”, which is initially -2.
After examining an object, change its last turn examined property to the current turn.
Before examining an object: if the last turn examined of the object is one less than the current turn, print the complaint message instead.
This can be a bit more flexible; you can change step 3 so that if the player has examined the object within (say) the last 5 turns, it will give the complaint. It will have odd results if the game runs over 32 thousand turns (2 million if the game is Glulx).
Yeah I tried doing this at first, but that would involve me writing this for every single object in the game. I would prefer to write some simpler code that would do this for everything
I also tried variations of
Instead of examining an object (or something or one object etc.) for more than one turn:
However this would give “annoyed” answers after I examine ANYTHING twice in a row. Eg. EXAMINE LAMP EXAMINE FIRE the speaker would become annoyed.
I’m thinking that this is probably the best way to go…
Although I’m a little bit worried about the 32 thousand turn limit.
If you’re starting an I7 project today, it defaults to Glulx, which uses 32-bit integers.
In Z-code you could do some massaging to avoid the problem. You could tweak the turn counter to clean up after itself on overflow: when it’s 32767, increment it to 0 and adjust every object’s “last turn examined” flag to -1 if it was 32767.
I wouldn’t worry about a 32k turn limit. 32k is A LOT of turns. For comparison, most long-form IF can be solved walkthrough-style in a few hundred turns, and a realistic playthrough is still well under 10k. 32k is THREE TIMES as long as this. Much modern long-form IF doesn’t fit in the Z-machine format anymore, anyway. Counterfeit Monkey sure as hell doesn’t, and it’s a safe bet Hadean Lands isn’t going to, either. I don’t think there’s really any reason to use Z-machine format anymore.
But in any case, I also think that there should be no problem even if somehow you do overflow the counter, because (at least in your simple case of immediate repetition) you’ll be checking for equality, which is always overflow-safe. If you wish to use the more complicated version in which you mock the player for examining the same thing within a few turns, be sure to use exactly the following construction:
if (the current turn minus the last examined of the noun) is less than mocking-delay: mock the player for his foolishness.
With this construction, if the turn counter has overflowed so that “last examined of the noun” is a huge number and “current turn” is a tiny number, the subtraction will overflow again, and you’ll still end up with the right difference between them. Unless something hasn’t been examined in over 64k turns, which is not likely.
Thank you Zahariel and zarf! I’m reasurred. I think in the end it’s going to be a longish game but I guess I underestimated the length of 32k… I think if I find that the game is indeed overflowing I’ll change it up to that. I think you’re right though, in that the limit won’t be even nearly reached.
I think I’m on the right track with this code here…
[code]Every noun has a number called last turn examined. The last turn examined is initially -2.
After examining a noun:
now the last turn examined of the noun is the turn count.
Before examining an object:
say “[one of][line break][italic type]‘And the [noun]? Tell me more about it.’[or][italic type]‘Tell me about the [noun]’.[or][italic type]‘What did the [noun] look like?’[or][italic type]‘Could you describe to me the [noun]?’[or][italic type]‘I’m interrested in this [noun]’.[at random]”.
Before examining a noun:
if the turn count minus the last turn examined of the noun is 1:
say “[one of][roman type]Didn’t I already tell you about it?[or][roman type]There’s nothing more to tell.[or][roman type]I told you all I know.[or][roman type]I just told you everything.[or][roman type]I told you all that I know, seriously![at random]”.[/code]
and it enters gameplay alright but…
[rant]Not everything has every property. For instance, a room cannot have the property carrying capacity: it would not mean anything. Generally speaking, the properties available to something are specified by its kind. If we say that A room has a number called maximum population. then the property maximum population is available to any room. This applies to either/or properties as well: you might say that a room is not transparent, but Inform takes the firm line that we cannot even ask, because it is meaningless for a room to be either transparent or opaque.
So, anyway, here it seems that you have tried to access a property for something not allowed to have it.[/rant]
I’m a little bit confused needless to say.
You could also just have a global variable holding the last examined object. Set it to nothing “before doing anything except examining”, set it to the noun “after examining something”, and check if the noun matches the last examined object to see if the same thing has been examined twice in a row.