2nd instant camera like "claims adjustment"

Hello everyone, I am currently working on a project in Inform7. As part of my task, I would like to implement an instant camera. Here I kept to “Claims Adjustment” (9.12. Cameras and Recording Devices). Now I would like to implement another camera that has its own film. I’m stuck here because I can’t assign an independent film to the second camera. Can you help me with this?

here is my previous code:

A photograph is a kind of thing. 10 photographs are in the film roll a. 10 photographs are in the film roll b. 

Appearance relates one thing to various photographs. The verb to be shown by means the appearance relation.

The description of a photograph is usually "It shows [a random thing which is shown by the item described]."

Understand "of [something related by reversed appearance]" as a photograph.	

A camera is a kind of thing.
The old camera is a camera.
The backup camera is a camera.


The player carries an old camera.
The player carries a backup camera.

Understand "photograph [something] with [camera]" as photographing. Understand "photograph [something] with [something preferably held]" as photographing. Photographing is an action applying to one visible thing and one carried thing, requiring light.


The photographing action has an object called the selected film.
Before photographing, play the sound of Photo.


Setting action variables for photographing:
	if the camera is the old camera:
		let N be a random photograph in the film roll a;
		now the selected film is N;
	if the camera is the backup camera:
		let N be a random photograph in the film roll b;
		now the selected film is N.

Check photographing:
	if the second noun is not a camera, say "[one of]You have to use the camera to take a photo of something. [or]
										The camera is the preferred tool to take a picture. [or]
										How about using the camera to take a photo? [at random]" instead.

Check photographing:
	if the noun is a camera, say "Sadly impossible." instead.
	

Check photographing:
	if the selected film is nothing, say "[one of] Unfortunately, you are out of film for the camera, so you can´t take any more pictures. Maybe bring more film rolls next time. [or]
								No more film for the camera. You can´t take anymore pictures. [or] 
								‘Oh no, I ran out of film. I wish I brought more.’ [at random]" instead.


Carry out photographing:
	now the noun is shown by the selected film;
	move the selected film to the player.

Report photographing:
	say "You now have the picture of [a selected film] in your inventory."
	
After printing the name of a photograph (called target):
	say " of [a random thing which is shown by the target]".

After printing the plural name of a photograph (called target):
	let N be the holder of the target;
	say " of [a list of things which are shown by photographs which are held by N]";
	if the number of things which are shown by photographs which are held by N is greater than one, say " (variously)".
2 Likes

The problem is that Inform doesn’t know what ‘the camera’ is here:

Setting action variables for photographing:
	if the camera is the old camera:
		let N be a random photograph in the film roll a;
		now the selected film is N;
	if the camera is the backup camera:
		let N be a random photograph in the film roll b;
		now the selected film is N.

The phrase ‘the camera’ is just being processed as a static variable by inform. You need to make it depend on what the player types in:

Setting action variables for photographing:
	if the second noun is the old camera:
		let N be a random photograph in the film roll a;
		now the selected film is N;
	if the second noun is the backup camera:
		let N be a random photograph in the film roll b;
		now the selected film is N.
3 Likes

Thank you very much. You really helped me a lot! I have to think more about the topic, then it will definitely work next time :slight_smile:

1 Like

You can also simplify the structure if you want more cameras:

Setting action variables for photographing:
    let the roll be a random film roll enclosed by the noun;
    if the roll is not nothing, now the selected film is a random photograph in the roll.

Change “enclosed by” for whatever relation links cameras to film in your system.

Hello guys, thanks again. Maybe you can give me another tip. I intend to include various NPCs (tourists) who should randomly walk through an amusement park. Now I don’t think it’s technically nice if I write “xyz is an npc” every time for each NPC that only differ in their names. Is there a way to create the NPCs automatically? In my thinking, I would like to have a “Tourist” table in which I enter the name and the rest then happens almost automatically. I hope you understand what I mean. I would be very grateful for a good idea :slight_smile:
Greetings from an inform addict :slight_smile:

If it’s just the displayed name as you say, this is a quick and dirty approach:

The tourist is a person in the test chamber.  The tourist is proper-named.  The printed name of the tourist is "[one of]Lucy[or]Ricky[or]Fred[or]Ethel[at random]".  Understand "lucy/ricky/fred/ethel" as the tourist.  

(This does mean that if the player types X LUCY after being told “You can see Ricky here”, they’ll get a response – if that bothers you, you’ll need to get slightly more complex, as with the table idea you mention).

2 Likes

Defining things with tables

1 Like

Hey this looks really good. The idea behind it is that I want to gradually expand my amusement park. However, an initially sufficient number of tourists would at some point not have enough effect in a larger amusement park. The plan is that I can also address the tourists at the end and, if necessary, interact with them differently without losing immersion. The Tourists are supposed to have fixed names whenever i see them again and there can be multiple at the same location. As of now, i have multiple lines of code for every tourist, because some say different things etc. Is there a solution, where i can put them in tables and have some answers for some of them in a different table, so that they choose a random answer out of that table? So if i want to add a new tourist, i just have to place a name into the existing table and dont need to write his name everywhere a tourist is supposed to do/say something? Right now i would change several lines of code, if i add a tourist and it is easy to forget add his name somewhere. Now it looks like this and when it gets more complicated, I have way too copy&paste

Every turn during the TouristWalk:
	Let Walkers be {Hans Alber, Peter Pan, King Dong};
	Let Talkers be {Hans Alber, Peter Pan, King Dong};
	repeat with n running through Talkers:
		if the location of n is the location of the player:
			if a random chance of 1 in 2 succeeds and no fish is visible: [can always change the chance of talking]
				say "[n]: '[one of]Ahhh[or]Uhhh[or]Ohhh[or]Impressive[or]Interesting[at random]'[line break]";
	repeat with m running through Walkers:
		if the location of m is a room listed in the Table of BeltRooms, continue the action;
		if a random chance of 1 in 2 succeeds: [can always change the chance of movement] 
			let next be a random room which is adjacent to the location of m;
			move m to next.

If you make the tourists a kind of person and give them further properties, you can “repeat through tourists” and check for the properties, which could eliminate the need to keep lists.

And using the method Zed linked to, you can use a table to define the characters, so that there’s not a lot of typing overhead for each NPC, and you only have to modify a single place. That table can contain text with random substitutions, or you can also reference other tables.

So, here’s an example which does some of the above:

The Museum is a room. The Square is south of the museum. The Shop is west of the Museum.

A tourist is a kind of person.

Talkativeness is a kind of value. The talkativenesses are talkative and taciturn.

Some tourists are defined by the Table of Tourist-People. The description of a tourist is "[The noun] is from your tour group and seems to be interested in [interests]."

When play begins:
	repeat with T running through tourists:
		now T is in starting-place of T.

Every turn:
	repeat with T running through tourists in the location:
		say "[if T is talkative][T] says, 'I'm mainly interested in [interests of T].'[otherwise][T] remains silent, absorbed in the surroundings.[end if]";
		if ambulatory of T is true:
			say "[T] wanders off.";
			move T to a random adjacent room.

Table of Tourist-People
tourist	starting-place	talkativeness	ambulatory	interests
Alice	Museum	talkative		true	"[one of]history[or]literature[at random]"
Bob		Museum	talkative		false	"paintings"
Carol	Square	taciturn		false	"sculptures"
Dave	Square	talkative		true	"architecture"

(In this example, we only loop over tourists in the location of the player, and the others won’t move, but that can of course be modified.)

2 Likes

Hey, i just stumbled across your Table of People.
How can i add pieces of clothing (preferably 2 - Body and Hat) to the Table or to a specific entry?
I have some NPC’s roaming around and i want them to have differen colored uniforms and hats.
Later on i want to add more NPC’s with different, maybe random pieces of clothing.
I dont want to add multiple new lines of code for each new Person i implement.

Right now i can’t get a Table of NPC’s to work when there a pieces of clothing involved…

I even failed to give them a Job like “guard” or “npc” or “tourist”… :smiley: so now they either have a job or not and behave according to it.

I can’t wrap my head around how a Table is supposed to work and how i can relate entries to one another, like Pablo is wearing a uniform and a cap.

[shortend]
Table of npc-People
npc      name     starting-place   job   walker  talker  wearing1  wearing2  Description
Guard  "Pablo"  Main Hub         true  false     true    uniform     cap          "One of the Guards of Underwold. His name is Pablo."

Here’s a way to define the clothes, with one table for the people (for the purpose of a concise example, I left out the other columns from my previous example, but of course, you’d just add the columns) and one table for the items of clothing:

Table of Tourist-People
tourist	bodywear	headwear
Alice	--		--
Bob		suit	hat
Carol	dress	cap
Dave	--		--

Some wearable things are defined by the Table of Clothing.

Table of Clothing
item	description
hat	    "It's an elegant grey Homburg hat."
suit	"The suit is dark and formal."
cap	    "It's a small white beret."
dress	"The blue summer dress seems to be made of linen."

When play begins:
	repeat with T running through tourists:
		now T wears the bodywear of T;
		now T wears the headwear of T;

(Alice and Dave are confirmed nudists.) :slightly_smiling_face:

For jobs, you could just store them as an additional textual column in the people table (for a concise example, I left out the other columns):

Table of NPC-People
npc job
Alice   "guard"
Bob     "npc"
Charlie "tourist"
Dave    --

Every turn:
	repeat with N running through npcs in the location:
		if the job of N is "guard":
			say "[N] pays close attention to your actions.";
		otherwise if the job of N is "tourist":
			say "[N] is looking at the sights.";
		otherwise if the job of N is "npc":
			say "[N] is just doing random things in the background.";
		otherwise:
			say "[N] is lounging around.".

In general, for cross-referencing entries in tables, check out §16.3. Corresponding entries in the documentation.

1 Like

Nice, i were able to implement part of what you suggested, now i have a Problem with a definition:

Some persons are defined by the table of NPC-people.		

Table of NPC-people
npc	Name	Job	bodywear	headwear	starting-place	walker	talker	Description
Guard	"Artem"	"guard"	uniform	cap	Passenger Dock	false	false	"Placeholder"
Tourist Guide	"Nikolajs"	"guide"	shirt	tie	Passenger Dock	false	false	"Ph"
Eyn Jerso	--	"tourist"	shirt	--	Resting Area	true	true	--

Definition: a NPC is greety if his job is "NPC" or "guide" or "guard".

The definition is wrong and i think i know why → i dont say, that the table is to be checked…
But i dont know how i can do this, can you help me again? :smiley:

You need to use “it” in the definition, even though it’s about a person. (Or you can use “(called ...)” and then refer to that term in the rest of the definition.)

Some examples:

Definition: a tourist is noisy if it is in the Museum and it is talkative.

Definition: a tourist (called the troublemaker) is noisy if the troublemaker is in the Museum and the troublemaker is talkative.

Definition: an NPC is greety if its job is "NPC" or its job is "guide" or its job is "guard".

Definition: an NPC is greety if its job matches the regular expression "NPC|guide|guard".
[or use "exactly matches" if you've got some terms that are substrings of others, like "guard" and "lifeguard" etc.]

See also 6.4. Defining new adjectives.

1 Like

Thx! That did the trick!!!

One last Question hopefully :slight_smile:

I can do this:

Rule for printing the name of a npc (called n):
	say "[name of n] the [job of n]".

I dont know how to make a Rule to let the game know what do understand as what…

so how do i get the Game to understand the Name of T as its Name?
I tried:

When play begins:
	repeat with T running through the npcs:
		Understand "[Name of T]" as T;

Or:
Understand the Name of NPc as its Name.

Definition: A Npc can be called by its Name (which is obviously wrong)

The relevant docs are here:

http://inform7.com/book/WI_17_15.html

You’ll want something like “understand the name property as describing an NPC”, I think.

2 Likes

The property was the right hint! I am still learning how to use tables.
Thank you very much!

2 Likes

As a side note, I would recommend making a kind of value for the job. This ensures that, if you accidentally make someone a “gaurd”, the compiler will complain instead of silently accepting it.

A job is a kind of value. The jobs are guard, guide, and tourist.

Thank you :smiley:

I realy hate to ask for more advice … Nearly everything works fine but i move npc’s around randomly to adjacent rooms but this seems to be happening after the Scope of the player is decided/ the game still prints “You can see X” but he is not there anymore if i try to talk to him…

Every turn during the TouristWalk:
	repeat with n running through npcs:
		if walker of n is true and the pause-counter of n is 0:
			if a random chance of 1 in 2 succeeds: [can always change the chance of movement] 
				let next be a random room which is adjacent to the location of n;
				move n to next;
		if the location of n is the location of the player and talker of n is true:
			if a random chance of 1 in 1 succeeds and no dog is visible: [can always change the chance of talking]
				say "[n]: '[one of]Ahhh[or]Uhhh[or]Ohhh[or]Impressive[or]Interesting[at random]'[line break]".

I upped the chance of talking to 100% to test this, some npc enter the room after the game checks wether ther is someone or not and they will tak without beeing printed as “You can see X”.

I tried around with deciding the scope and whatnot or inbetween the iteration “place n in Scope” but nothing helped even if it compiled correctly…
Do you have any idea how i can tell the game, that the moving is happening “before” every turn? (Or manually place them in scope in the right order) I dont neccesarily need to do this with “Every turn” if the outcome is still the same logic (moving randomly if chance of x succeds).

This looks like it should be working and I don’t think there should be anything complicated going on with things moving in and out of scope. I suspect what’s going on is that you’re having a hard time knowing whether an npc is actually around or not because their movement isn’t being reported - the “move npc to room” statement isn’t generating an in-world action, so there’s no built-in reporting.

I’m writing this on my phone so can’t easily write up an implementation, but you have two options: either you can write your own say statements to let the player know if an npc is moving to or from their location, as in the Mistress of Animals example (note that you’ll need to create a variable to keep track of the room an npc is leaving from, if you want to include that bit of info for the player) - you could also rewrite the rule so that “next” is the direction to an adjacent room and then instead of the “move” command, say “try n going the next”.

Hope this helps!

2 Likes