Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

I7: Working with multiple objects of the same kind... (toggling between two objects)

7 views
Skip to first unread message

Roger

unread,
Nov 12, 2009, 12:38:49 PM11/12/09
to
Okay, this is another thing that befuddles me (syntactically). I am
trying to have an object that toggles upon use (basically it swaps out
with another object). This is simple enough if you only have one
object of each in the game world. However, how do you do this if you
are working with kinds, and with multiple objects of each kind?

[code]
Using is an action applying to one thing.
Understand "use [something preferably held]" as using.

A whoozit is a kind of thing. A whatsit is a kind of thing.

There are five whoozits. There are five whatsits.

Instead of using a whoozit:
if the player carries a whoozit:
remove a random whoozit carried by the player from play;
move a random whatsit to the player;
say "You lose a whoozit and gain a whatsit."

Instead of using a whatsit:
if the player carries a whatsit:
remove a random whatsit carried by the player from play;
move a random whoozit to the player;
say "You lose a whatsit and gain a whoozit."
[/code]

a) The above KIND of works, except "move a random whoozit/whatsit to
the player" does not exclude the whoozits and whatsits in the player's
inventory. Upon testing, this seems to be the case. I need it to move
a whoozit off-stage and pull a whatsit from off-stage (and vice-
versa).

b) I want the whoozits/whatsits to be grouped together by number when
the player checks inventory (which I am overriding with an instead
rule). Would a "group together" rule of some sort suffice? Right now
it just lists the items. My inventory rule is basically this:

[code]
Instead of taking inventory:
say "You are also carrying: [held_inv]."

To say held_inv:
let Q be the list of things enclosed by the player;
repeat with item running through things:
if item is worn by the player:
if item is listed in Q:
remove item from Q;
if the number of entries of Q is not zero:
say "[Q]";
otherwise:
say "nothing";
[/code]

I think that can be cleaned up a bit anyway, but as such it works,
except it'll list "...whatsit, whatsit, whatsit, whoozit, whoozit..."
instead of "...3 whatsits, 2 whoozits..." which is what I want.

As always, thank you for any insight.

Ron Newcomb

unread,
Nov 12, 2009, 1:33:45 PM11/12/09
to

Perhaps give them a new "counterpart" relation. whoosit-to-whatsit,
One-to-one, reciprocal.
When Play Begins can loop through just the whoosits and set the
relation to an unused whatsit.

Erik Temple

unread,
Nov 12, 2009, 2:11:40 PM11/12/09
to
On Thu, 12 Nov 2009 11:38:49 -0600, Roger <roger.h...@gmail.com> wrote:

> a) The above KIND of works, except "move a random whoozit/whatsit to
> the player" does not exclude the whoozits and whatsits in the player's
> inventory. Upon testing, this seems to be the case. I need it to move
> a whoozit off-stage and pull a whatsit from off-stage (and vice-
> versa).

This should work:

move a random off-stage whatsit to the player;

--Erik

Roger

unread,
Nov 12, 2009, 7:14:02 PM11/12/09
to
On Nov 12, 2:11 pm, "Erik Temple" <ek.tem...@gmail.com> wrote:

> On Thu, 12 Nov 2009 11:38:49 -0600, Roger <roger.helge...@gmail.com> wrote:
> > a) The above KIND of works, except "move a random whoozit/whatsit to
> > the player" does not exclude the whoozits and whatsits in the player's
> > inventory. Upon testing, this seems to be the case. I need it to move
> > a whoozit off-stage and pull a whatsit from off-stage (and vice-
> > versa).
>
> This should work:
>
>         move a random off-stage whatsit to the player;
>
> --Erik

Will try this shortly, thanks.

vaporware

unread,
Nov 12, 2009, 9:26:22 PM11/12/09
to
On Nov 12, 9:38 am, Roger <roger.helge...@gmail.com> wrote:

How about:

<code>
move a random whatsit not carried by the player to the player;
</code>

> b) I want the whoozits/whatsits to be grouped together by number when
> the player checks inventory (which I am overriding with an instead
> rule). Would a "group together" rule of some sort suffice? Right now
> it just lists the items. My inventory rule is basically this:
>
> [code]
> Instead of taking inventory:
>         say "You are also carrying: [held_inv]."
>
> To say held_inv:
>         let Q be the list of things enclosed by the player;
>         repeat with item running through things:
>                 if item is worn by the player:
>                         if item is listed in Q:
>                                 remove item from Q;
>         if the number of entries of Q is not zero:
>                 say "[Q]";
>         otherwise:
>                 say "nothing";
> [/code]
>
> I think that can be cleaned up a bit anyway, but as such it works,
> except it'll list "...whatsit, whatsit, whatsit, whoozit, whoozit..."
> instead of "...3 whatsits, 2 whoozits..." which is what I want.
>
> As always, thank you for any insight.

Try this:

<code>
Definition: a thing is unworn if it is not worn by the player.

Instead of taking inventory:
say "You are also carrying: [list of unworn things enclosed by the
player]."
</code>

Saying "[list of <object description>]" instead of converting to a
list value first enables the automatic grouping by kind.

vw

Roger

unread,
Nov 12, 2009, 10:35:23 PM11/12/09
to

Perfect. Thank you. :)

Roger

unread,
Nov 14, 2009, 3:28:40 PM11/14/09
to
On Nov 12, 9:26 pm, vaporware <jmcg...@gmail.com> wrote:

Okay, I'm combining the solutions from two different threads of mine
for this question. Your suggestion and the solution on how to print a
"kind" given in my "Two questions that probably require dipping into
I6" thread.

[code]Instead of taking inventory:

update stat bonuses;
say fixed letter spacing;
say "WEAPON: [if the player is wearing a weapon][a list of weapons
worn by the player][otherwise]none[end if][line break]";
say "OFF-HAND: [if the player is wearing a off-hand][a list of off-
hands worn by the player][otherwise]none[end if][line break]";
say "HAT: [if the player is wearing a hat][a list of hats worn
by the player ][otherwise]none[end if][line break]";
say "SHIRT: [if the player is wearing a shirt][a list of shirts
worn by the player][otherwise]none[end if][line break]";
say "PANTS: [if the player is wearing a pant][a list of pants
worn by the player][otherwise]none[end if][line break]";
say "ACCESSORY: [if the player is wearing an accessory][a list of
accessories worn by the player][otherwise]none[end if][line break]";
say variable letter spacing;
say "[line break]";
now inv_listing is true;


say "You are also carrying: [list of unworn things enclosed by the

player].";
now inv_listing is false;

After printing the name of a something while inv_listing is true:
say " ([the kind of the item described])";

To say the/-- kind of (item - an object): (- PrintKindOf({item}); -).

Include (-
[ PrintKindOf obj;
if (obj provides IK_0) print (I7_Kind_Name)KindHierarchy-->
((obj.IK_0)
*2);
else print "nothing";
]; -).
[/code]

This works, however when the items are grouped ("2 whoozits, and 3
whatsits") in the output, their kind is not printed.

Is there some (probably cumbersome) way to have it print the kinds of
these grouped items?

Mike Tarbert

unread,
Nov 15, 2009, 9:55:53 AM11/15/09
to
Roger wrote:
> [code snipped]

>
> This works, however when the items are grouped ("2 whoozits, and 3
> whatsits") in the output, their kind is not printed.
>
> Is there some (probably cumbersome) way to have it print the kinds of
> these grouped items?

I'm not sure I understand what you mean. You can do this (in conjunction
w/ your above code):

After printing the plural name of a something while inv_listing is true:
say " ([the kind of the item described])".

... but if the items are being grouped because they are duplicates, you
just end up with something like:

You are also carrying: two whoozits (whoozit), and three whatsits (whatsit).

... which I'm guessing is not what you're looking for. If you're using
the grouping together activity to group non-identical objects, you could
just customize that activity. Maybe if you posted an example of the
output you're looking for I could steer you in the right direction.

Skinny Mike

Roger

unread,
Nov 15, 2009, 10:50:58 AM11/15/09
to

No, that's actually exactly what I was looking for. In my actual
example the whoozits and whatsits have kind "miscellaneous". I haven't
done much work with plurals yet. Thanks again!

Roger

unread,
Nov 15, 2009, 12:02:32 PM11/15/09
to
Okay, I'm sorry for all the questions but I'm still confused.

What I have is seven different item types: Weapons, Off-handed items
(like shields), Hats, Shirts, Pants, Accessories, and Miscellany. Any
object in the game that's not one of the first six are miscellaneous.
I know have 99% of the mechanics working except for I suppose the most
complicated: item drops based on an encounter table.

I'm defining these objects using various tables, such as:

[code]
Table of Equippable Hats
hat item-id
iron helm "H1"
fedora "H2"
chicken head "H3"

Some kinds of hats are defined by the Table of Equippable Hats.
There are 100 iron helms. There are 100 fedoras. There are 100 chicken
heads.

Table of Equippable Weapons
weapon item-id
iron sword "W1"
bronze sword "W2"
ray gun "W3"

Some kinds of weapons are defined by the Table of Equippable Weapons.
There are 100 iron swords. There are 100 bronze swords. There are 100
ray guns.

Table of Creatures
creature drop-id
imp "W2"
goblin "H1"
treant "H2"
demon "H1"
[/code]

I know this seems clumsy but I can't really think of a better way. I
may look at that cloning/dynamic objects extension later, though.

Anyway, I thought of a few ways to do this but all seem problematic.
The idea I finally came up with is to append a unique "ID" to each
item and then have each creature have a drop-id. Then I would look
through each table to find that drop-id and when I found it, I would
move a random off-stage object of that kind to the player. So when
fighting ends, it would look at the drop-id of the creature and then
look that ID up in each of the different item-kind tables.

Then it would presumably create an object of that kind and move it to
the player. However, I cannot seem to figure out how to relate a KIND
defined by a table and a real object that exists of that kind in the
game world. I am getting "invalid object" when I try to refer to the
"weapon" or "hat" field in any way.

Any help would be appreciated.

Any ideas?

Mike Tarbert

unread,
Nov 15, 2009, 1:47:49 PM11/15/09
to
Roger wrote:
> Okay, I'm sorry for all the questions but I'm still confused.
>

Don't be. Sorry, that is -- it's ok to be confused.


>
> Table of Creatures
> creature drop-id
> imp "W2"
> goblin "H1"
> treant "H2"
> demon "H1"
> [/code]
>
> I know this seems clumsy but I can't really think of a better way. I
> may look at that cloning/dynamic objects extension later, though.
>
> Anyway, I thought of a few ways to do this but all seem problematic.
> The idea I finally came up with is to append a unique "ID" to each
> item and then have each creature have a drop-id. Then I would look
> through each table to find that drop-id and when I found it, I would
> move a random off-stage object of that kind to the player. So when
> fighting ends, it would look at the drop-id of the creature and then
> look that ID up in each of the different item-kind tables.
>
> Then it would presumably create an object of that kind and move it to
> the player. However, I cannot seem to figure out how to relate a KIND
> defined by a table and a real object that exists of that kind in the
> game world. I am getting "invalid object" when I try to refer to the
> "weapon" or "hat" field in any way.
>

I assume by "create" you mean "find an appropriate off-stage object and
move it to the location." It's been a while since I tried something like
this, but IIRC, tables used for the creation of objects / kinds are
essentially useless after they've served their function (at least for
this kind of thing). There are some different reasons for this, which I
don't really remember, but one of them I think has something to do with
the fact that regular tables can be resorted, etc., and that would
create all kinds of problems when referred back to.

Anyway, you don't really need to refer to the tables again. Remember
that the individual columns are now actual properties of the objects in
question and therefore can be searched. I put together an edited down
version of your code. Does this do what your looking for?

[code]


Table of Equippable Weapons
weapon item-id
iron sword "W1"
bronze sword "W2"

A weapon is a kind of thing.


Some kinds of weapons are defined by the Table of Equippable Weapons.

There are 5 iron swords. There are 5 bronze swords.

[Note: we can't use "table of creatures" since that confuses inform.]

Table of Nasty Creatures
creature drop-id
imp "W2"
goblin "W1"

A creature is a kind of animal. Some kinds of creatures are defined by
the Table of Nasty Creatures.

Lab is a room. 10 imps and 10 goblins are in the lab.

Instead of attacking a creature:
say "You kill [the noun], which drops ";
remove the noun from play;
let test-id be the drop-id of the noun;
let weapon-moved be false;
repeat with test-weapon running through off-stage weapons:
if the item-id of test-weapon is test-id:
move test-weapon to the location;
say "its [test-weapon].";
let weapon-moved be true;
break;
if weapon-moved is false, say "nothing."

test me with "kill imp / g / g / g / g / g / kill goblin / g / g / g / g
/ g / l".
[/code]

HTH,
Skinny Mike

Roger

unread,
Nov 15, 2009, 2:35:45 PM11/15/09
to

Thanks so much, I had just come up with a hacky solution that used
indexed text but yours is much more concise. I really appreciate the
help.

Roger

unread,
Nov 15, 2009, 8:57:28 PM11/15/09
to
Grr. I'm having trouble again.

I'm trying to make a "combining it with" action. One is actually
provided in the recipe book, but it fails for obvious reasons (the
example is constructed for physical objects already instantiated in
the game world). Inform7 doesn't know how to interpret a list of kinds
of things, unless there is some magic syntax I'm missing. Inform 7
seems to get really confused here.

What I ideally need is to be able to refer to "the kind of the noun"
and "the kind of the second noun" and to compare them as values to
table entries.

Is THIS possible?

--

Mike, I'm looking at the code of yours that Victor posted in the other
thread for me. I think I might be able to manipulate that somehow, but
it's not compiling. I think it's failing at the "to decide what number
is the level (n - a number) parent kind of (x - an
object):" block of code. And yes, I am deleting the carriage return
between "(x - an" and "object):"

Maybe it's an indentation issue? This is what he posted:

[code]
To decide if (X - an object) is identical to (Y - an object):
(- Identical({X},{Y}) -).

To decide if (x - an object) is the same kind as (y - an object):
(- ({x}.i7_kind()=={y}.i7_kind()) -).

Section - New Phrases to Determine / Say

To decide what number is the level (n - a number) parent kind of (x -
an
object):
(- kindof ({n},{x}); -).
Include (-
[ kindof n x;
return x.&i7_kind-->n;
]; -).

To decide what number is the kind of (x - an object):
let k be the level 0 parent kind of x;
decide on k.

To decide what number is the parent kind of (x - an object):
let k be the level 1 parent kind of x;
decide on k.

To say kind name of (n - a number):
(- print (I7_Kind_Name) {n}; -)

To say the level (n - a number) parent kind of (x - an object):
(- print (I7_Kind_Name) {x}.&i7_kind-->{n}; -).

To say kind of (x - an object):
say the level 0 parent kind of x.

To say the parent kind of (x - an object):
say the level 1 parent kind of x.
[/code]

Also, assuming I get this compiled, I want to be able to compare these
kinds (in a "combining it with" action) to a table entry which is,
literally, nothing BUT a kind (and not an object). Will this work?

Thanks again.

Mike Tarbert

unread,
Nov 16, 2009, 12:16:55 AM11/16/09
to

Mike Tarbert

unread,
Nov 16, 2009, 12:27:27 AM11/16/09
to
Roger wrote:
> Grr. I'm having trouble again.
>

Obviously, I am too; I hit send by mistake on that last (empty) post.

>
> Mike, I'm looking at the code of yours that Victor posted in the other
> thread for me. I think I might be able to manipulate that somehow, but
> it's not compiling.

Whoops. Virtually all of that code is no good. It worked for 5t18 (two
versions ago), but stopped working when some of the underlying i6 kind
hierarchy syntax was changed in 5u92. I didn't notice when Victor first
posted that he put up the old code. (I had also forgotten how long it
had been since we worked on that.)

At any rate, there's an updated version, but it's not as functional; I
never did figure out how to do the whole crawling up the kinds tree by
parent-level deal with the new version. Here are the new / surviving
routines that will work w/ 5z71:

[code]
To decide if (X - an object) is identical to (Y - an object):
(- Identical({X},{Y}) -).

To decide if (x - an object) is the same kind as (y - an object):

(- ((({x}.IK_0)*2)==(({y}.IK_0)*2)) -).

To say kind of (o - an object):
(- print (I7_Kind_Name) KindHierarchy-->(({o}.IK_0)*2); -).
[/code]

>
> Also, assuming I get this compiled, I want to be able to compare these
> kinds (in a "combining it with" action) to a table entry which is,
> literally, nothing BUT a kind (and not an object). Will this work?
>

Hm, not sure about that. Even if not, I'm sure there's another way, but
I'm not sure exactly what you want to do. Try posting a sample desired
output while I think...

Sorry for the added confusion,
Skinny Mike

Roger

unread,
Nov 16, 2009, 12:39:00 AM11/16/09
to
Mike, I had half a post typed out but I think I may have thought of
another solution. So before either of us go crazy, let me sleep on it
(it's 12:40 AM and I don't have any mental strength left) and I'll see
if I still need to screw around with kinds and such in the morning. I
really appreciate your help.

Roger

unread,
Nov 16, 2009, 10:21:24 AM11/16/09
to

I am an idiot. It's what happens when you're trying to do too many
things at once with the same code you've been looking at for two days
straight with hardly any sleep except to play Torchlight and fuss with
the Dragon Age: Origins editor...sigh.

I had all the fundamentals right there. My "item-id" property for
every item in the game world.

So I adapted Example 409 in the 5Z71 Recipe Book ("What Makes You
Tick") which provides a mechanism for combining objects with a table
and a list of objects called a component list. This doesn't work for
kinds. But it does work for texts!

In the process I also learned about using action variables, so in the
end I'm glad it forced me to come up with this solution.

My solution follows. If anyone can think of anything simpler or
better, though, please let me know:

[code]
"Combo2" by Roger Helgeson Jr.

The Chamber of Otherworldy Creations is a room.

Table of Miscellaneous Crap
gizmo item-id
whoozit "M1"
whatsit "M2"
gewgaw "M3"

A gizmo is a kind of thing. Some kinds of gizmos are defined by the
Table of Miscellaneous Crap.

The player carries 4 whoozits and 3 whatsits.

There are 2 gewgaws.

Understand "combine [something] with [something]" as combining it
with. Combining it with is an action applying to two things.
Understand the command "connect" as "combine".

Understand the command "attach" as something new. Understand "attach
[something] to [something]" as combining it with.

The combining it with action has an object called the resultant-item.

Setting action variables for combining something with something:
let X be a list of texts;
add the item-id of noun to X;
add the item-id of second noun to X;
sort X;
let result-id be a text;
repeat through the Table of Combinations:
let Y be the component list entry;
sort Y;
if X is Y:
now the result-id is the result entry;
repeat with item running through off-stage things:
if item-id of item is result-id:
now resultant-item is item;
stop.

Check combining it with:
if the resultant-item is nothing:
say "You can't combine [the noun] and [the second noun] into
anything useful." instead.

Carry out combining it with:
move resultant-item to player;


remove the noun from play;

remove the second noun from play;

Report combining it with:
say "You fashion the [noun] and the [second noun] into a [resultant-
item]."

Table of Combinations
component list result
{"M1", "M2"} "M3"

Test me with "i / combine whoozit with whatsit / i / combine whatsit
with gewgaw".

[/code]

Chuck

unread,
Nov 16, 2009, 12:50:31 PM11/16/09
to

Interesting code.

Why does this not work?

Understand "combine [something] and [something]" as combining it with.

Any way to use "combine whoozit and whatsit" to make a geegaw?

Chuck

Chuck

unread,
Nov 16, 2009, 1:02:55 PM11/16/09
to
On Nov 16, 9:21 am, Roger <roger.helge...@gmail.com> wrote:

One more q. If I give the player 4 sticks and then after running try
"combine stick with whatzit" I get:

"You can't see any such thing."

not get the expected result:

"You can't combine the stick and the whatzit into anything useful."

Chuck

Mike Tarbert

unread,
Nov 16, 2009, 1:32:11 PM11/16/09
to
Chuck wrote:
> On Nov 16, 9:21 am, Roger <roger.helge...@gmail.com> wrote:
>> [code]
>> "Combo2" by Roger Helgeson Jr.
>>
>> [snip]

>>
>> Understand "combine [something] with [something]" as combining it
>> with. Combining it with is an action applying to two things.
>> Understand the command "connect" as "combine".
>>
>> [snip]

>>
>> [/code]
>
> Interesting code.
>
> Why does this not work?
>
> Understand "combine [something] and [something]" as combining it with.
>

The parser will interpret "foo and bar" as a multiple noun, not as one
noun and one second noun. This behavior allows inform to parse "put foo
and bar into box." Unfortunately in this case, it's not only
undesirable, it is why even with the addition of the new syntax, the
output is still:

[output]

>combine whoozit and whatsit
You can't use multiple objects with that verb.

[/output]

> Any way to use "combine whoozit and whatsit" to make a geegaw?
>

I was thinking about that earlier and I'm sure there is. You could
intercept the command before the parsing stage and do something there,
but I that's probably overly complicated. I think the way to go would be
to create a new (separate) "combining" action which takes multiple nouns
and redirect to the "combining it with" action as appropriate.

Skinny Mike

Mike Tarbert

unread,
Nov 16, 2009, 1:56:25 PM11/16/09
to
Chuck wrote:
> On Nov 16, 9:21 am, Roger <roger.helge...@gmail.com> wrote:
>> [code]
>> "Combo2" by Roger Helgeson Jr.
>>[snip]

>> [/code]
>
> One more q. If I give the player 4 sticks and then after running try
> "combine stick with whatzit" I get:
>
> "You can't see any such thing."
>
> not get the expected result:
>
> "You can't combine the stick and the whatzit into anything useful."
>

Probably because you coded something like:

The player carries four sticks.

... which doesn't tell Inform to create four sticks (since inform
doesn't know what a stick is), but rather creates one thing called "four
sticks." When you then type "combine stick with..." the parser doesn't
know what a "stick" (singular) is and responds appropriately. Try this
to see the difference:

[code]
A stick is a kind of gizmo. The player carries four sticks.
[/code]

Note that your question does reveal a hole in Roger's code; only gizmos
are given an item-id by default. Trying to combine any object without an
item-id results in a runtime error. For example:

[code]
A stick is a kind of thing. The player carries four sticks.
[/code]

... results in:

[output]
>combine stick with stick

*** Run-time problem P10: Since the stick is not allowed the property
"item-id", it is against the rules to try to use it.
[/output]

Roger -- you'll need to update your setting action variables for
combining it with rules to account for this. (You could also just give
everything in the game a default id, which would be easier, but a lttle
wasteful.)

Skinny Mike

Roger

unread,
Nov 16, 2009, 9:09:40 PM11/16/09
to

That is true, but I actually did this on purpose so it would yield an
error at runtime. The number of different items I have in the main
game this code is for is massive so for easier debugging purposes, I'm
mandating a unique item-id for everything I try to create. At the end,
I'll decide whether to go this route or not - but either way I'll
probably fix the action so it accounts for that.

Chuck

unread,
Nov 17, 2009, 3:59:44 PM11/17/09
to

Interesting. I added the code "A stick is a kind of thing. The player
carries four sticks." and when I tried to combine a stick with a stick
I received the correct error message. But when I tried to combine any
held object (Combine a whoozit with the puppet) I get the runtime
error. If you figure out how to solve this, let me know.

I want my character to be able to combine two substances to make a
bandage. Adjustments in your code work fine, but I'd like the correct
error message to appear when trying to combine inappropriate things:

"You can't combine the x and the y into anything useful."

Chuck

Roger

unread,
Nov 17, 2009, 7:17:39 PM11/17/09
to

Hi Chuck,

Sorry I didn't realize you actually wanted to use my code somehow.

I think the simplest way to do this is to add this line at the top of
your code:

[code]
A thing has some text called item-id. The item-id of a thing is
usually "(blank)".
[/code]

However, you've alerted me to another possibility: What about recipes
that contain the same item being used twice? I mean, what if you DO
want "stick + stick" to be a valid recipe? I'm having a little trouble
with this. But I'll keep you posted.

Roger

unread,
Nov 17, 2009, 7:39:17 PM11/17/09
to
On Nov 17, 3:59 pm, Chuck <casm...@ksu.edu> wrote:

I'm positive there's a better way to do this, but...


[code]


The Chamber of Otherworldy Creations is a room.

A thing has some text called item-id. The item-id of a thing is
usually "(blank)".

Table of Miscellaneous Crap


gizmo item-id
whoozit "M1"
whatsit "M2"
gewgaw "M3"

trinket "M4"

A gizmo is a kind of thing. Some kinds of gizmos are defined by the
Table of Miscellaneous Crap.

There are 20 whoozits. There are 20 whatsits. There are 20 gewgaws.
There are 20 trinkets.

The player carries 4 whoozits, 3 whatsits, and 3 gewgaws.

A stick is a kind of thing. The player carries four sticks.

Understand "combine [something] with [something]" as combining it


with. Combining it with is an action applying to two things.
Understand the command "connect" as "combine".

Understand the command "attach" as something new. Understand "attach
[something] to [something]" as combining it with.

The combining it with action has an object called the resultant-item.

Setting action variables for combining something with something:
let X be a list of texts;
add the item-id of noun to X;
add the item-id of second noun to X;
sort X;
let result-id be a text;
repeat through the Table of Combinations:
let Y be the component list entry;
sort Y;
if X is Y:
now the result-id is the result entry;
repeat with item running through off-stage things:
if item-id of item is result-id:
now resultant-item is item;

stop;

Check combining it with:
say noun;
say line break;
say second noun;
say paragraph break;
if the noun is the second noun and the resultant-item is nothing:
say "You can't combine two [noun]s into anything useful." instead;


if the resultant-item is nothing:
say "You can't combine [the noun] and [the second noun] into
anything useful." instead.

Carry out combining it with:
move resultant-item to player;
remove the noun from play;
remove the second noun from play;

Report combining it with:
if the noun is the second noun:
say "You fashion two [noun]s into a [resultant-item].";
otherwise:


say "You fashion the [noun] and the [second noun] into a [resultant-
item]."

Table of Combinations
component list result
{"M1", "M2"} "M3"

{"M1", "M1"} "M2"
{"M1", "M3"} "M4"

Test me with "i / combine whoozit with whatsit / combine whatsit with
gewgaw / combine stick with stick / combine stick with gewgaw /
combine whoozit with whoozit".

After reading a command:
let T be indexed text;
let T be the player's command;
let THINGIE be word number 3 in T;
let N be the number of characters in THINGIE;
if character number N in THINGIE is "s":
replace the regular expression "s$" in THINGIE with "";
if word number 1 in T is "combine" and word number 2 in T is "two" or
word number 2 in T is "2":
change T to "combine [THINGIE] with [THINGIE]";
change the text of the player's command to T;

Test me2 with "combine two whoozits / combine two sticks / combine 2
whoozits / combine 2 sticks / combine 2 gewgaws".
Test all with "test me / test me2".
[/code]

Try "test all".

I think the "after reading a command" here is a poor choice. First, I
haven't account for synonyms. Using "attach 2 [noun]s" here won't
allow for the same product as "combine 2 [noun]s".

Then again, that's a nice bit of extra syntax to afford the player,
but it's not exactly necessary. There's probably a better way that
involves screwing around with multiple objects (as Mike hinted at also
in using "and" as a keyword) but...I dunno. If anyone can point me/us
in the right direction, that would be super.

Roger

unread,
Nov 17, 2009, 7:48:37 PM11/17/09
to
Nope, there's still a problem. "Combine whoozit with whoozit" does
yield a whatsit, but it only removes ONE whoozit from the player's
inventory.

I'll look into this some more and give you a cleaner example.

Roger

unread,
Nov 17, 2009, 8:10:05 PM11/17/09
to

Fixed. Except I removed everything related to the "combine two/2 [noun]
s" syntax. That would be nice, but like I said, it's not necessary.
Fussing with multiple objects is kind of painful.


Reason for the fix:

If your noun and second noun are the same in an action, they are
EXACTLY the same. That means that if you are dealing with two objects
of the same kind (two whoozits, say), then "noun" and "second noun"
refer to the SAME EXACT instantiated whoozit in the game world.
Therefore, when it tries to remove the second noun, it has already
moved it off-stage. I assume this did not throw up an error because it
is (likely) valid to move something from off-stage to off-stage (just
like it's valid to move something from the player's location to the
player's location).

To get around this, I simply run through the player's inventory to (a)
make sure he HAS two of said object and (b) remove one instance of it
and then another. So I modified the check and carry out rules as
needed.


[code]
The Chamber of Otherworldy Creations is a room.

A thing has some text called item-id. The item-id of a thing is
usually "(blank)".

Table of Miscellaneous Crap
gizmo item-id
whoozit "M1"
whatsit "M2"
gewgaw "M3"
trinket "M4"

A gizmo is a kind of thing. Some kinds of gizmos are defined by the
Table of Miscellaneous Crap.

There are 20 whoozits. There are 20 whatsits. There are 20 gewgaws.
There are 20 trinkets.

The player carries 3 whoozits, 3 whatsits, and 3 gewgaws.

A stick is a kind of thing. The player carries four sticks.

Understand "combine [something] with [something]" as combining it
with. Combining it with is an action applying to two things.
Understand the command "connect" as "combine".

Understand the command "attach" as something new. Understand "attach
[something] to [something]" as combining it with.

The combining it with action has an object called the resultant-item.

Setting action variables for combining something with something:
let X be a list of texts;
add the item-id of noun to X;
add the item-id of second noun to X;
sort X;
let result-id be a text;
repeat through the Table of Combinations:
let Y be the component list entry;
sort Y;
if X is Y:
now the result-id is the result entry;
repeat with item running through off-stage things:
if item-id of item is result-id:
now resultant-item is item;
stop;

Check combining it with:
let COUNT be 0;
if the noun is the second noun:
repeat with item running through things held by the player:
if item-id of noun is item-id of item:
increase COUNT by 1;
if COUNT is less than 2:
say "You don't have two [noun]s!" instead;


if the noun is the second noun and the resultant-item is nothing:
say "You can't combine two [noun]s into anything useful." instead;
if the resultant-item is nothing:
say "You can't combine [the noun] and [the second noun] into
anything useful." instead.

Carry out combining it with:

let COUNT be 0;
move resultant-item to player;
if the noun is the second noun:
repeat with item running through things held by the player:
if COUNT is not 2:
if item-id of noun is item-id of item:
remove item from play;
increase COUNT by 1;
otherwise:
remove noun from play;
remove second noun from play.

Report combining it with:
if the noun is the second noun:
say "You fashion two [noun]s into a [resultant-item].";
otherwise:
say "You fashion the [noun] and the [second noun] into a [resultant-
item]."

Table of Combinations
component list result
{"M1", "M2"} "M3"
{"M1", "M1"} "M2"
{"M1", "M3"} "M4"

Test me with "i / combine whoozit with whatsit / combine whatsit with
gewgaw / combine stick with stick / combine stick with gewgaw /
combine whoozit with whoozit".

Test me2 with "i / combine whoozit with whoozit / i / combine whoozit
with whoozit".
[/code]

Roger

unread,
Nov 17, 2009, 9:35:24 PM11/17/09
to
Chuck, I should also mention that I have a working "untinkering"
command that rips a combined item into its component parts, as well as
a "make" mechanic that allows a user to bypass the "combine X with Y"
verb with a "make Z" instead, if he has already tried the recipe once.

I also have a "recipe book" mechanic that will read all known recipes
to the player.

If you want any of it, let me know.

Ron Newcomb

unread,
Nov 17, 2009, 9:51:00 PM11/17/09
to
On Nov 17, 4:17 pm, Roger <roger.helge...@gmail.com> wrote:
> I mean, what if you DO
> want "stick + stick" to be a valid recipe? I'm having a little trouble
> with this.

Sounds like a sticky situation.


Ba-dum tshh!

Roger

unread,
Nov 17, 2009, 9:58:19 PM11/17/09
to

A joke from which I shall never recover.

0 new messages