Inform7: Can actions be made to default to the player if no noun is provided? - inform7

I have a heal [someone] action that restores an hp value I have given all people in my story.
When I enter the command heal on it's own it defaults to healing anyone else in the same room before it does the player.
Is there a way I can make that action default to the player if no noun is specified?

You can create another action ("healing oneself" in this example), understand the phrase "heal" as that action, and convert the action to the healing action applied to the player in a Check rule:
A person has a number called current hit points.
A person has a number called maximum hit points.
Healing is an action applying to one thing.
Healing oneself is an action applying to nothing.
Understand "heal [someone]" as healing.
Understand "heal" as healing oneself.
To appear is a verb.
To feel is a verb.
Check healing oneself:
convert to the healing action on the player.
Carry out healing:
now the current hit points of the noun is the maximum hit points of the noun.
Report healing:
if the noun is the player:
say "[We] [feel] completely healed!";
otherwise:
say "[The noun] [appear] completely healed!".

Does the player mean healing the player: it is likely.
ยง17.19. Does the player mean...

Related

Inform7 camera with two different film rolls

Hey guys i try to implement a camera:
A photograph is a kind of thing. 36 photographs are in the film roll.
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.
This allows the player to refer to any photograph by its subject: useful if we have a large number of them.
Now we create an action to let the player use the camera and generate these photograph objects:
The player carries a cheap instant 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.
Setting action variables for photographing:
let N be a random photograph in the film roll;
now the selected film is N.
Check photographing:
if the second noun is not the camera, say "You need a camera for that purpose." instead.
Check photographing:
if the noun is the camera, say "Sadly impossible." instead.
Check photographing:
if the selected film is nothing, say "You're out of film." instead.
Carry out photographing:
now the noun is shown by the selected film;
move the selected film to the player.
Report photographing:
say "Your camera instantly spits out [a selected film]."
Like in Example 322:
http://inform7.com/book/RB_9_12.html
In the example there is only one camera with one film roll.
but i want two different cameras and both cameras should have a individual film roll.
So i can take pictures with camera#1 saved to filmroll#1 and i can take pictures with camera#2 which are saved to "filmroll#2".
Can somebody help me?
I think you could do this with aliases. It's been a while since I coded in Inform 7, but I believe the syntax is something like:
The player carries a first camera.
The printed name of first camera is "cheap instant camera".
There is a second camera in the lab.
The printed name of second camera is "cheap instant camera".
You would have two cameras that display as the same thing, but are distinct. And you could do the same thing with the rolls of film. You might still have issues knowing which camera is which, but hopefully this gets you on the right track.

Single term answer to Alexa Skill

Background
I'm writing an Alexa Skill and looking to get pieces of information from the user.
The following conversation for example:
Alexa: What month were you born at?
User: April
Alexa: Good. And what was your favorite movie?
User: April
The problem
Given the following utterances:
GetMonthIntent {month}
GetMovieIntent {movie}
Once a user answers April for the second time, the GetMonthIntent might be triggered.
What I have tried
Asking the user to specify which piece of information is giving by using the following utterances:
GetMonthIntent Month {month}
GetMovieIntent Movie {movie}
The question
What is the right way to make Alexa wait for a single term answer based on the current context?
In the same vein as the other answers here, you should take a look at the newest Node.JS library here, which handles state out of the box:
https://github.com/alexa/alexa-skills-kit-sdk-for-nodejs#making-skill-state-management-simpler
You could define:
State_Launch
State_Month
State_Movie
And then return the proper error response if anything other than the GetMovieIntent or GetMonthIntent (etc.) intents are called in the wrong state.
You would have to do data validation on the server side to make sure the "month" is a valid one, and movies are even harder to validate unless you have a list of expected values. That is, if you care to parse them for use beyond repeating back.
Unfortunately, there is no solution. There is no way to specify the 'context' in which a user reply should be interpreted, so you have to tell the user "what was your favorite movie? Please say 'my favorite movie is' and then the name of the movie".
Here are two ASK feature requests that I think would address your issue:
https://forums.developer.amazon.com/content/idea/41062/creating-something-to-help-with-more-structured-qu.html
https://forums.developer.amazon.com/content/idea/55525/allow-a-response-to-specify-a-set-of-expected-inte.html
Personally I think this is fairly important so I voted for those, but they are not near the top.
I ran into this same problem when I created the "Who's on First? Baseball Skit" skill. I handled this by:
Create a sequence number for each response given by Alexa
Write this number to the "session" in the response.
The session is then passed back to your skill by Alexa in the next request.
Read the sequence number from the request to know what the previous question was.
If a given intent could be the answer to multiple questions (eg. month and movie in your case) then use the sequence number to determine which it is.
This should give you ideas on how to deal with repeated answers. The session is quite easy to use. Other options include writing the userId and status to a database like DynamoDB, but I find that the session works in most cases.

List of possible rooms instead of possible directions

I try to list possible directions to which the user might go. But for the tone of the story it would be nicer not to say "you can go north and south" but "you can go to the bathroom and the kitchen".
I found hat code but it only shows the directions.
Definition: a direction (called thataway) is viable if the room
thataway from the location is a room.
After looking:
say "you can go [list of viable directions]."
Any idea?
Absolutely not the nicest way of doing it, but I had a similar problem and I ended up iterating over the list of directions you created and added each of the rooms to a list of rooms, one could then say:
nLooking is a number that varies. nLooking is 0.
After looking:
now nLooking is 1;
let accessibleRooms be a list of rooms;
let pDirections be list of viable directions;
repeat with dirToLookAt running through pDirections:
try silently going dirToLookAt;
if rule succeeded:
add the location of the player to accessibleRooms;
try silently going the opposite of dirToLookAt;
now nLooking is 0;
say "You can go to [accessibleRooms].".
Before going through a locked door when nLooking is 1:
stop the action.
I used nLooking to block the output
(first opening door)
It seems to be locked.
when looking for the rooms one could access.
if rule succeeded checks if the palyer was able to go to the room. If that is the case the room the player walked in is added to the list and the player is moved back to where he came from.
This works only if one does not make a chaotic map where moving in the opposite direction of where one came from does not mean one lands in the same room. One could possibly just place the player back in the room he came from...
Late answer I know but maybe it helps people with the same problem :)

How can I get Amazon echo to respond to "preheat the car" or "what's the car battery status"? (they get hijacked)

I'm trying to create some skills for my Echo (for my own use, I'm not concerned about the invocation names not getting through review). I've set my invocation name as "the car" (I also tried "car"). I wanted to be able to ask what my battery status is and order Alexa to pre-heat the car (a Renault ZOE).
It seems no matter what I put in for my utterances, I always get the same responses:
Anything with "battery" in gets "I don't have a battery"
Anything with "heat" in gets "You have no smarthome devices, blah blah"
It seems like the words "battery" and "heat" result in things never matching my skill (even when I said the invocation name).
Is there anything I can do so that it will route actions along the lines of the above to my skill?
Edit: Today I get different results trying "preheat the car".. I just get a weird tone. It never calls my skill, nor shows anything in the Home section of the app. What does this tone mean?
Video here: https://twitter.com/DanTup/status/804615557605654528
With help from Reddit I managed to get this working reasonably well. the car was a bad invocation name and I wasn't following the documented way for invoking skills (joining words etc. are fairly restrictive).
I'm now using my car as the invocation name and can do the following:
Alexa tell my car to preheat
Alexa ask my car for battery
As of Dec 2017, it's still not possible to have completely custom phrases with Alexa. Google Assistant/Home does support this however, via shortcuts.

Right way to accommodate an HTTP GET that could "skip" to a POST?

Let's say you have a HTTP GET request which could be skipped in some circumstances. For example, imagine you have:
GET /orders/new, which lets you pick what flavor of ice cream you want
POST /orders, which makes a new ice cream order
Normally, GET /orders/new shows you the list of flavors and a Submit button. But if there's only one flavor available today, you'd like to just POST the order to avoid having the user make a useless decision. (We'll imagine this is a universe in which everyone likes all flavors equally and so will always be happy with your dictatorial ice cream choice.)
It doesn't seem correct to do something like "redirect to POST" from a GET request, since that wouldn't be idempotent. So then what's the right way to do this:
if there's more than one flavor: let the user pick the flavor(s) they want for their order
if there's only one flavor: pick the only flavor for their order and immediately make the order
either way, wind up with a newly POSTed order
It's a GET, it should never result in a POST. Period. If you want to avoid the choice, avoid doing the GET entirely somewhere in the flow before the GET /orders/new. Maybe I only want to see the flavors, but not actually proceed with an order.

Resources