ADRIFT Forum


The place to discuss the ADRIFT Interactive Fiction toolkit

Coding a 'Who' command?

This forum is the place to learn about and discuss ADRIFT 5. Feel free to mention any bugs you find here, but please also add these to the Bugs & Enhancements list.

Please also refer to the ADRIFT 5 Wiki for more information.

Coding a 'Who' command?

Postby Kennedy » Wed Dec 28, 2016 4:58 pm

Basicly it would give the player a list of all the npcs they have encountered, I imagine though that the tricky part would be going through each of the NPCs in the game. Does anybody have any recommendations on how that could be coded? Something like a 'for or 'while' command is what I thought of, but can those be done in ADRIFT?
Kennedy
 
Posts: 147
Joined: Tue Apr 29, 2003 7:12 pm
Location: Oregon
Points: 10

Re: Coding a 'Who' command?

Postby ElliotM » Wed Dec 28, 2016 11:37 pm

This can be done with some of the advanced features. This isn't without flaws but mostly does what I think you are after. I'll upload a demo later once I've ironed out some specific cases.

Create a character Group and name it 'Everyone' without the quotes. The automatic key generated should be Everyone if there isn't anything else with that key. Once the group is created, add all of your characters to it. Leave the Player character out of this group.

Next, create a Selection Property for characters named 'Viewed". We will set this property to selected every time the player sees a character.

Create a green Specific Task and name it 'Mark Characters as Viewed'. In the Specific Task box that appears, set it to "Task should run after Player Movement" or to "Task should run after Look" depending on your preference. Set a restriction for "The Player Character must not be alone" to stop it from running when there are no other characters around.

Now create a new red General Task and name it "# Set Character to Viewed". In the task syntax, enter the following:

# %character% was viewed

Be sure to include the #. In the task actions for this task, have "Set property 'Viewed" to '<Selected>'"

Returning to our Specific Task, in the task actions have it execute our General Task and in the params field write:

%Player%.Location.Characters

With the setup finished, this will allow you to write this into a task and get your up-to-date list of characters viewed by the player:

Everyone.Viewed.List(And,Rows)

or

Everyone.Viewed.List(And)

A note here. Characters are listed by their first noun unless the property box "Is this character known to the Player" is checked, in which case they are listed by their Proper Name instead. This will happen automatically if the character has no nouns.
ElliotM
 
Posts: 1227
Joined: Tue Apr 17, 2007 8:04 pm
Location: The Midwest in the USA
Points: 13

Re: Coding a 'Who' command?

Postby Kennedy » Thu Dec 29, 2016 10:38 am

Can "seen by player" be used somehow? For a general task of "whois %character%" my thought was to allow it to work only if the player has seen that character.
Kennedy
 
Posts: 147
Joined: Tue Apr 29, 2003 7:12 pm
Location: Oregon
Points: 10

Re: Coding a 'Who' command?

Postby ElliotM » Thu Dec 29, 2016 4:01 pm

I thought you were going for a list of characters that the player has seen, but if the player can specify the character by name or unique noun descriptor, that is much easier to do.

Yes, you can use "seen by player" in a restriction in your general task and it should only run if it is true.
ElliotM
 
Posts: 1227
Joined: Tue Apr 17, 2007 8:04 pm
Location: The Midwest in the USA
Points: 13

Re: Coding a 'Who' command?

Postby saabie » Fri Dec 30, 2016 4:40 am

Here is my attempt at this:
WhoHaveIMet.taf
(15.64 KiB) Downloaded 39 times

I used an "Everybody" group as the starting point, the same as EliotM did, with every character ticked except the player.
The mandatory property "All" only exists because passing a group key to an executed task does not work unless you filter it with a selection-only property.
The "who" task executes the "# Check if %character% has been seen and if so add them to met group" task that checks each character in the "Everybody" group to see if the player has seen them, and adds those to the "Met" group.
Note that the restriction must have a completely blank message box!
I did it this way, and set the "who" task to display it's completion message AFTER the actions, so that I could add an alternate description that prints a sensible message when nobody has been seen yet.
Here is a transcript:
> who
You have not met anybody at all yet!
> e
You move east.
B
Belinda is here.  Exits are south and west.
> who
You have met Belinda so far.
> s
You move south.
D
Debra is here.  Exits are north and west.
> who
You have met Belinda and Debra so far.
> who is belinda
Belinda is dressed as a ballerina.
> who is christine
You have not met anybody by that name.
> w
You move west.
C
Christine is here.  Exits are north and east.
> who
You have met Belinda, Debra and Christine so far.
> who is christine
Christine is wearing a large silver cross and carrying a sharp wooden stake and a small bottle of water.
She must be some sort of gardener?
saabie
 
Posts: 884
Joined: Fri Aug 12, 2011 2:07 am
Location: Adelaide, South Australia
Points: 10

Re: Coding a 'Who' command?

Postby ElliotM » Fri Dec 30, 2016 5:33 am

Nicely done, Saabie. I like your use of the has seen character restriction. I had been contemplating updating the group whenever the player moved or looked but this felt really clunky. Doing it the way you did, only just before the actual list is required, saves on overhead and is much more elegant.
ElliotM
 
Posts: 1227
Joined: Tue Apr 17, 2007 8:04 pm
Location: The Midwest in the USA
Points: 13

Re: Coding a 'Who' command?

Postby Kennedy » Mon Jan 02, 2017 9:16 pm

saabie wrote:Here is my attempt at this:
WhoHaveIMet.taf

I used an "Everybody" group as the starting point, the same as EliotM did, with every character ticked except the player.
The mandatory property "All" only exists because passing a group key to an executed task does not work unless you filter it with a selection-only property.
The "who" task executes the "# Check if %character% has been seen and if so add them to met group" task that checks each character in the "Everybody" group to see if the player has seen them, and adds those to the "Met" group.
Note that the restriction must have a completely blank message box!
I did it this way, and set the "who" task to display it's completion message AFTER the actions, so that I could add an alternate description that prints a sensible message when nobody has been seen yet.


Thanks! I'll check it out.
Kennedy
 
Posts: 147
Joined: Tue Apr 29, 2003 7:12 pm
Location: Oregon
Points: 10


Return to ADRIFT 5.0

Who is online

Users browsing this forum: No registered users and 2 guests