You can't change the internal name of an object (the name used to refer
to it in code). But you can change its printed name. Something like
this, perhaps:
[code]
The drawable-paper is a privately-named thing. The player carries the
drawable-paper. The printed name of the drawable-paper is "[if drawn
upon]drawing of foo[otherwise]piece of paper". Understand "piece",
"paper", and "piece of paper" as the drawable-paper. The drawable-paper
can be drawn upon. The drawable-paper is not drawn upon. Understand
"drawing", "foo", and "drawing of foo" as the drawable-paper when the
drawable-paper is drawn upon.
Drawing on is an action applying to one thing and requiring light.
Understand "draw on [something]" as drawing on.
Check drawing on:
say "That's not something you can draw on."
Instead of drawing on the drawable-paper:
now the drawable-paper is drawn upon;
say "You sketch a foo on the piece of paper."
[end code]
If you want the player to be able to draw ANYTHING on the piece of
paper, you have a more complex problem.
You might want to look at my Notepad extension. It allows the player to
write anything on a piece of paper -- but the words written on the paper
don't change its vocabulary words or printed name.
Hope this helps.
--JA
I'll take a look at the notepad extension...
The drawable-paper has a stored text called doodle. The doodle of
drawable paper is "nothing".
After drawing something (called scribble) on the drawable-paper: [of
course you need to set this up as an action]
now the doodle of the drawable paper is scribble. [?]
The printed name of drawable-paper is "[if doodle is nothing]A blank
sheet of paper.[otherwise]A stunningly lifelike interpretation of
[doodle]."
Every turn when the Vogon Guard holds the drawable-paper, say "The
guard holds the paper to the light, thoughtfully critiquing your
rendition of [doodle]."
---
I'm sure I've done something weird with nouns and text, but in
principle, shouldn't that type of structure work?
I think you can do that. What you may not be able to do is allow "*foo*"
to be used as vocabulary for the paper. Maybe Ron or Jesse will be able
to suggest a way to do this, though.
Take a look at page 2.3 in the Recipe Book. It shows various ways to use
the player's input. None of them is quite what you're looking for, but
they may suggest something.
Here's a revised version of the code I sent yesterday. It's still not
perfect. In particular, if the player draws Helen on the paper, Inform
will report that the paper is "a drawing of a helen". But it's a start.
[code]
The drawable-paper is a privately-named thing. The player carries the
drawable-paper. The drawable-paper has some indexed text called the
drawing. The drawing of the drawable-paper is usually "blank". The
description of the drawable-paper is "[if drawn upon]On the paper you
have drawn a [drawing of the drawable-paper][otherwise]The paper is
blank[end if]."
The printed name of the drawable-paper is "[if drawn upon]drawing of a
[drawing of the drawable-paper][otherwise]piece of paper". Understand
"piece", "paper", and "piece of paper" as the drawable-paper. The
drawable-paper can be drawn upon. The drawable-paper is not drawn upon.
Understand "drawing" as the drawable-paper when the drawable-paper is
drawn upon.
Drawing it on is an action applying to one topic and one thing and
requiring light. Understand "draw [text] on [something]" as drawing it on.
Check drawing it on:
if the second noun is not the drawable-paper:
say "That's not something you can draw on." instead;
otherwise:
continue the action.
Carry out drawing it on:
now the drawable-paper is drawn upon;
change the drawing of the drawable-paper to the topic understood;
say "You draw a [drawing of the drawable-paper] on the paper."
[end code]
Now your NPC can say "Is this your drawing of a [drawing of the
drawable-paper]?"
I put the code for drawing on the paper in the carry out rule because
for some weird reason (possibly a bug???), Inform wouldn't let me write
an instead rule for the drawing it on action. But if the game includes
only one drawable-on object, that's a trivial problem.
--JA
I suspect the most relevant example for this is the Fido example,
which allows the player to name and rename a dog, and use that name to
refer to it. (This is linked from the section on using the player's
input, but is actually under Animals.)
Excellent. I have the paper working now with the regular notebook
function of 'writing'. I may try to add another verb "draw" that is a
portable piece of text that behaves like in the naming and renaming
section.
Is there an easy way to modify the notepad extension so that it
actually lets you write with a pen, so that I can somehow record which
pen was used?
I'll take a look at that tomorrow morning. Looks like you've found a
bug, or at least a minor omission. I believe you do have to be holding
the allowed-pen for the command to work, though.
And here's the thing: A typical IF parser only wants to know about two
nouns. Setting aside, for the moment, the question of including
arbitrary text in a command, parsers are not set up to do this:
> put the eyedrops in barbara's eye with the eyedropper
There are three nouns in that command -- eyedrops, eye, and eyedropper.
And that's too many. At best, a parser will respond to "put the eyedrops
in barbara's eye" by checking whether the player is holding the eyedropper.
So there may not be a way to implement "write *foo* on notepad with
*allowed-pen*. But I'll look into it.
--JA
I enjoyed playing around with Jim's code. One very slight change I
would make is to remove (two times) the letter "a" from:
[code]
.....a [drawing of the drawable-paper]
[end code]
This removes the double "a"s that I'm getting when using an article
with what I draw. I'm assuming that most players would type "draw a
sun" or "draw a boy" so the "a" in the code is not needed. Small thing
to consider.
Chuck
This is not a new problem. Check out this transcript from
Spellbreaker:
>write on cube
You'll have to write on the cube with something.
>write on cube with burin
Write what on the cube?
>packed earth
There was no verb in that sentence!
>write 'packed earth' on cube with burin
There were too many nouns in that sentence.
>write packed on cube with burin
There were too many nouns in that sentence.
>write on cube with burin
Write what on the cube?
>packed
There was no verb in that sentence!
>write 'packed' on cube with burin
There were too many nouns in that sentence.
>write "packed" on cube with burin
There were too many nouns in that sentence.
>write with burin
That sentence isn't one I recognize.
>write on cube
You'll have to write on the cube with something.
You hear a noise from within the cave that sounds like a sneeze.
>write "packed" on cube
The word "packed" is now written on the cube.
There's no graceful solution to this problem, short of going in and
monkeying with the player's input as indexed text to add or remove an
initial 'a' or 'the'. If we revise it as you suggest, like this:
The description of the drawable-paper is "[if drawn upon]On the paper
you have drawn [drawing of the drawable-paper][otherwise]The paper is
blank[end if]."
...then when the player enters DRAW HOUSE ON PAPER, the description of
the paper becomes "On the paper you have drawn house." Equally ugly.
--JA
On an aside- I know it's probably not complicated, but can someone
point to a well-formed code example of an NPC that spouts off random
quips from a table or array or what-have-you?
> I think I may have to keep the drawable paper as a novelty and have
> another object that cares what color crayon you write with, and
> assumes what the player is drawing, so there's no extra object to
> juggle in the sentence. I'll figure something out.
I have a couple more suggestions for you:
(1) Inform allows only two nouns in player input, but in addition it can
also recognize one value (e.g., Drawing is an action applying to two
things and one value). That value could be the color of the crayon, and so
you should be able to set up actions that will recognize inputs like these:
Draw a red rose on the paper.
Draw a rose on the paper in red.
Your check rules will need to check to see that the player has the proper
crayon for coloring in the color she's indicated, but otherwise this
should do what you want.
(2) Another option would be to ask a question after input specifying two
of the three elements:
> Draw on the paper with the red crayon
What do you want to draw?
> Draw a cow on the paper
What do you want to draw with?
> Draw a cow with the red crayon
What do you want to draw with?
One way to code this would be to have a different action for each, each
followed by a question that completes the needed information appropriately
(Michael Callaghan's Questions extension is easy to use and should work
well). All three elements could then be passed to a single rule that
actually carries out the action. (Yes, this is the trickier of my two
suggestions!)
--Erik
Since I can just see a user trying that a hundred different ways until
he hit upon "in red".
Not like that. Inform divides up the parsing process into two distinct
parts:
- Turning player inputs into actions (with Understand statements)
- Performing actions (with before/instead/after or check/carry-out/
report rules)
You already have appropriate actions set up, so you just need
Understand statements that lead into them.
--Z
--
"And Aholibamah bare Jeush, and Jaalam, and Korah: these were the borogoves..."
*
It seems like the way to do this is to have it both accept write/draw
foo on foo in foo, and also to question the user if he just writes
write/draw foo on foo.
> how do I restrict the
> value needed by the paper to colors?
With an Understand statement. I'm not sure what kinds you might be using,
but here is the basic syntax:
Drawing it on is an action applying to two things and one value.
Understand "draw [a thing] on [a thing] in [a color]" as drawing it on.
See Chapter 16 of the manual for more refinements.
On Tue, 06 Oct 2009 11:22:59 -0500, weevil <wiley...@gmail.com> wrote:
> Can I set up an instead rule for something that wouldn't have made
> sense to the parser?
> like:
> Instead of drawing *foo* on the paper with the red crayon:
> try drawing a *foo* on the paper in red.
> Since I can just see a user trying that a hundred different ways until
> he hit upon "in red".
To do this, you can cheat a bit:
<code>
Incorrectly using three substantives is an action applying to two things
and one value. Understand "draw [a thing] on [a thing] with [a color]
crayon" as incorrectly using three substantives.
Instead of incorrectly using three substantives:
say "Try [bold type]Draw [the noun] on [the second noun] in [the color
understood][roman type]."
</code>
What this does is put the word "crayon" into the grammar itself--it is not
understood as a noun but simply as text that must be present in the
player's command for the line to be understood as the incorrectly using
three substantives action. It is not advisable to do this kind of thing
often! I would only recommend using it, as in the example, to produce an
error message, because you don't want to teach your players that three
nouns are allowed across the board.
--Erik
I think this will work, however I am getting an error because now that
I am defining red, white, black, and blue as the values of color, it's
conflicting with my objects; white crayon, red crayon black crayon and
blue crayon.
" I seem to need to give a new meaning to 'red', something which was
created by the earlier sentence 'A white crayon, blue crayon, red
crayon, and black crayon are crayons inside the crayola box' "
is the solution to make all of those crayons privately named? Will
that interfere with the user picking them up and using them?
On Oct 6, 1:32 pm, "Erik Temple" <ek.tem...@gmail.com> wrote:
> On Tue, 06 Oct 2009 12:55:31 -0500, weevil <wileywg...@gmail.com> wrote:
> > how do I restrict the
> > value needed by the paper to colors?
>
> With an Understand statement. I'm not sure what kinds you might be using,
> but here is the basic syntax:
>
> Drawing it on is an action applying to two things and one value.
> Understand "draw [a thing] on [a thing] in [a color]" as drawing it on.
>
> See Chapter 16 of the manual for more refinements.
>
> Wow! This is getting complicated.
Yes--what you want to do is complicated!
> I think this will work, however I am getting an error because now that
> I am defining red, white, black, and blue as the values of color, it's
> conflicting with my objects; white crayon, red crayon black crayon and
> blue crayon.
>
> " I seem to need to give a new meaning to 'red', something which was
> created by the earlier sentence 'A white crayon, blue crayon, red
> crayon, and black crayon are crayons inside the crayola box' "
>
> is the solution to make all of those crayons privately named? Will
> that interfere with the user picking them up and using them?
Try this:
<code>
Test is a room.
Color is a kind of value. The colors are red, white, and blue.
A crayon is a kind of thing. A crayon has a color. Understand the color
property as describing a crayon. The printed name of a crayon is "a
[color] crayon".
A red crayon called crayon is in Test.
A blue crayon called crayon is in Test.
A white crayon called crayon is in Test.
</code>
The key thing here is the line "understand the color property as
describing a crayon". This makes the color of a crayon something the
player can refer to. Note that you still need to give a crayon a name for
Inform to understand it by. I have named all of these simply "crayon"--the
color property serves to distinguish them.
There may be better ways to do this, or refinements to improve aspects of
the behavior, but this ought to work for you.
--Erik
> should I give the crayons all different names again like, 'a red
> crayon called red crayon is in *room*' ?
I'd say give that a try--if it works, you're in business. If it doesn't,
hit undo a few times. ;-)
--Erik
"Problem. You wrote 'Understand "draw [a thing] on [a thing] in [a
color]" as drawing it on' : but 'understand ... as ...' should be
followed by a meaning, which might be an action (e.g., 'understand
"take [something]" as taking'), a thing ('understand "stove" as the
oven') or more generally a value ('understand "huitante" as 80'), or a
named token for use in further grammar ('understand "near [something]"
as "[location phrase]"'). Also, the meaning needs to be precise, so
'understand "x" as a number' is not allowed - it does not say which
number."
Did you change the name of the action? It sounds like Inform doesn't
understand "drawing it on" as an action you've defined.
<code>
Include Notepad by Jim Aikin.
The cage is a room.
Color is a kind of value. The colors are red, blue, black, white,
green, yellow, and purple.
The Crayola box is a container inside the cage.
A crayon is a kind of thing. A crayon has a color. Understand the
color
property as describing a crayon. The printed name of a crayon is "a
[color] crayon". Crayons are edible.
A white crayon called white crayon is in the box.
A red crayon called red crayon is in the box.
A black crayon called black crayon is in the box.
Rule for printing the name of the crayola box while not inserting or
removing:
if the crayola box contains crayons, say "box of crayons";
omit contents in listing.
The drawable-paper is a notepad. The allowed-pens of the drawable-
paper is {white crayon, red crayon, black crayon}. The drawable-paper
is in the cage. The drawable-paper has some indexed text called the
drawing. The drawing of the drawable-paper is usually "blank". The
description of the drawable-paper is "[if drawn upon]On the paper you
have drawn [drawing of the drawable-paper][otherwise]The paper is blank
[end if]."
The printed name of the drawable-paper is "[if drawn upon]drawing of
[drawing of the drawable-paper][otherwise]piece of paper". Understand
"piece", "paper", and "piece of paper" as the drawable-paper. The
drawable-paper can be drawn upon. The drawable-paper is not drawn
upon.
Understand "drawing" as the drawable-paper when the drawable-paper is
drawn upon.
Drawing it on is an action applying to two things and one value and
requiring light.
Understand "draw [a thing] on [a thing] in [a color]" as drawing it
on.
Incorrectly using three substantives is an action applying to two
things
and one value. Understand "draw [a thing] on [a thing] with [a
color]
crayon" as incorrectly using three substantives.
Instead of incorrectly using three substantives:
say "Try [bold type]Draw [the noun] on [the second noun] in [the
color
understood][roman type]."
Check an actor drawing on something (this is the ordinary check
drawing it on rule):
let carrying-pen be a truth state;
let carrying-pen be false;
if the actor is the player:
if the second noun is not a notepad:
say "You can't draw anything on [the second noun]." instead;
otherwise if the second noun is non-edit-allowing:
say "[The second noun] [if the second noun is plural-named]are
[otherwise]is[end if] currently write-protected, and can't be written
on." instead;
if the pen-needed of the second noun is true:
repeat with P running through the allowed-pens of the second noun:
if the player carries P:
now carrying-pen is true;
otherwise:
now carrying-pen is true;
if carrying-pen is false:
say "You have nothing to write with." instead;
otherwise:
if the second noun is not a notepad:
say "[The actor] is unable to write anything on [the second
noun].";
rule succeeds;
otherwise if the second noun is non-edit-allowing:
say "[The second noun] [if the second noun is plural-named]are
[otherwise]is[end if] currently write-protected, and can't be written
on.";
rule succeeds;
if the pen-needed of the second noun is true:
repeat with P running through the allowed-pens of the second noun:
if the actor carries P:
now carrying-pen is true;
otherwise:
now carrying-pen is true;
if carrying-pen is false:
say "[The actor] has nothing to write with.";
rule succeeds.
Check drawing it on:
if the second noun is not the drawable-paper:
say "That's not something you can draw on." instead;
otherwise:
continue the action.
Carry out drawing it on:
now the drawable-paper is drawn upon;
change the drawing of the drawable-paper to the topic understood;
say "You draw a [drawing of the drawable-paper] on the paper."
</code>
Problem. You wrote 'Understand "draw [a thing] on [a thing] in
[Color]" as drawing it on' : but there can be at most two varying
parts to a line of grammar, so 'put [something] in [a container]' is
allowed but 'put [something] in [something] beside [a door]' is not.
> Problem. You wrote 'Understand "draw [a thing] on [a thing] in
> [Color]" as drawing it on' : but there can be at most two varying
> parts to a line of grammar, so 'put [something] in [a container]' is
> allowed but 'put [something] in [something] beside [a door]' is not.
Doh! I hope someone will correct me if I'm wrong, but it looks like you
can't use 2 nouns plus 1 value after all. My apologies if that's the
case!!!
I could swear I've used three varying items in a line of grammar in the
past, however I just tried out 2+1 with a simpler example, though, and got
the same message. So it looks like 2+1 really isn't possible--and as
though I led you astray. I'm sorry!
This does reveal a bug of sorts in the system, because Inform allows
actions to be described in a way that implies that 2+1 is in fact
possible. The sentence:
Drawing it on is an action applying to two things and one value
Should not compile, because an action cannot in fact apply to two things
and one value.
Going on the assumption that there is in fact no way to have Inform parse
2+1, I still see a couple of options:
(1) Ask a question to get the third item, as I mentioned before.
(2) Hard-code the color words into the grammar as I mentioned before for
the crayon, e.g.:
Understand "Draw [a thing] on [a thing] in red" as drawing it in red.
Understand "Draw [a thing] on [a thing] in blue" as drawing it in blue.
Your check rules would have to manually see that the player has the
appropriate crayon.
But maybe you don't want to listen to me any more...
--Erik
On Oct 7, 2:03 pm, "Erik Temple" <ek.tem...@gmail.com> wrote:
<code>
Drawing it on is an action applying to one topic and one thing and
requiring light. Understand "draw [text] on [something]" as drawing it
on.
Understand "draw [text]" as "draw [text] on paper".
</code>
Inform sure doesn't like it, but there must be some way to make inform
assume that if the 'something' is left out, that the player means
'paper'.
Yes, you can define a placeholder action "drawing it on-paper", and
then give it one "instead" rule whose body is "try drawing the text
understood on the paper".
You could also use the "supplying a missing noun" activity:
Understand "draw [text] on [something]" or "draw [text]" as drawing it
on.
Rule for supplying a missing second noun while drawing:
if the player can touch the paper, change the second noun to the
paper;
otherwise say "You don't have anything to draw on."