Cut [something] with [something]

So I’m not exactly sure to get the action ‘cutting’ two apply to two things. I’ve tried making a new action that understands ‘cut [something] with [something]’. But I need to make it so that if I don’t have what I’m requesting to cut with in my inventory (let’s say an axe) the game doesn’t use the axe to cut the thing and prints a message in response to that like ‘you don’t have an axe to cut that with.’ Could someone help me with this? Thanks!

1 Like

It sounds like you want this sort of check:

Cutting it with is an action applying to two things.

Understand "cut [thing] with [thing]" as cutting it with.

Check cutting it with when the player does not carry the second noun:
	say "Sorry, you're not holding [the second noun].";
	stop the action.

Report cutting it with:
	say "You cut [the noun] with [the second noun]."

The check rule will block the action if the player isn’t carrying the tool item.

> drop axe
Dropped.
> cut tree with axe
Sorry, you’re not holding the axe.

If the tool item isn’t in scope – that is, if the axe is in another room – the parser will say “You can’t see any such thing.” (This is enforced for all nouns in all actions, unless you make an effort to handle them differently.)

There are other ways to get this effect. You might want to get into them if you’re interested in implicit take (“first taking the axe…”) But this is the simplest plan.

3 Likes

You might also want CUT TREE to implicitly select a tool, which takes some additional code. But not too much.

1 Like

Thank you so much for the quick response! I’m interested in implicitly selecting a tool. If it’s not too much of a bother, could you also post that code as well?

Something along the lines of

Instead of cutting something when the player carries the axe:
    Try cutting the noun with the axe.

is probably all you need, unless you have multiple cutting implements or something more complicated going on.

2 Likes

Thank you! And to add to that, how can you make sure that you can only cut the tree with sharp objects? I made it so that a thing can be a cutter or a noncutter. I don’t want to succeed if I try to cut something with a loaf of bread.

You could say something like–

Check cutting something with something which is a noncutter:
    instead say "[The second noun] really doesn't have much of an edge."

Of course, you don’t want to be able to cut the tree with a kitchen knife, so–

Check cutting the tree with a cutter:
    if the second noun is not the axe:
        instead say "Though [the second noun] is quite sharp, you don't have the stamina to saw at the tree with it all day and night."

I hope that this helps.

1 Like

Thank you, everyone!

One suggestion if I may–You can create a ‘kind’, such as–

A cutter is a kind of thing.  The axe, the kitchen knife and the scissors are cutters.

You can add to this list as you go, such as–

A pocketknife is a cutter.

This way, you don’t have to outright call something a ‘noncutter’–you would simply not call it a ‘cutter’ and the parser will not put it on the list of cutters.

Don’t get me wrong, your solution achieves the same result, I think it’s just good to get into the practice of using ‘kinds’, when you have a number of objects that do similar things. However…

…what you are doing is using ‘properties’ rather than ‘kinds’. Which has its own advantages. ‘Kinds’ cannot overlap (you might have a ‘kind’ called ‘cutter’, and a ‘kind’ called ‘utensil’–while you might be able to eat with a pocketknife, maybe not with an axe–a ‘cutter’ cannot also be a ‘utensil’). But properties can overlap.

A thing can be cutter or noncutter.  A thing is usually noncutter.
A thing can be utensil or nonuntensil.  A thing is usually nonutensil.
...
A pocketknife is a thing.  It is cutter.  It is utensil.
An axe is a thing.  It is cutter.  It is nonutensil.

Whereas this would not work—

A cutter is a kind of thing.
A utensil is a kind of thing.
A pocketknife is a cutter.  A pocketknife is a utensil.

It would throw a problem message, unless you say

A utensil is a kind of cutter.

Which would not be right unless you want to call all utensils (such as a spoon or chopsticks) cutters as well.

Just some tips.

1 Like

Thank you for the info. Will keep that in mind :slight_smile:

1 Like