New Actions instead of parser catching

I have an action called DEPOSIT and the item is moved from the player to the vault. (works fine). I also have DEPOSIT MONEY but MONEY is a kind of thing, and not a thing (not sure if that is relevant). In the latter case, the banker asks a follow-up question of how much money is to be deposited. Then the player can enter, say DEPOSIT 200.0, and 200 gold pieces are stored in the vault.

Currently, I have

Depositing is an action applying to one carried thing.
Understand "deposit [something]" as depositing.
Understand "deposit money" as depositing.  [Cash is an instance of money and is carried by the player.]

Rule for printing a parser error when the latest parser error is the can't see any such thing error:
	if player's command includes "deposit money":
		say "Ganon says, 'Sure, How much would you like to deposit?'[line break] ";
	if player's command includes "[real number]":
		obtain cash amount;

The activity to obtain cash amount is where the 200.0 gp is collected.
I know it is bad practice to use parser error catching instead of new actions, but I don’t know how to declare something like
(1) DEPOSIT MONEY because there is no such thing available, and it gets caught up as a parser error “can’t see any such thing.”

(2) I also don’t know how to declare DEPOSIT <real number> to collect the amount of coins going into the vault.

Neither (1) nor (2) are accepted by the compiler. Does anyone know how to declare these new actions?

Cost is a kind of value. 1.0 gp specifies a cost. 1.0gp specifies a cost.

Depositing is an action applying to one cost.
Understand "deposit [cost]" as depositing.
Carry out depositing: say "You deposit [cost understood]."

Vaguely depositing is an action out of world applying to nothing.
Understand "deposit money" as vaguely depositing.
Carry out vaguely depositing: say "Specify the amount of money to deposit, like DEPOSIT 5.4 GP."

Numerically depositing is an action applying to one real number.
Understand "deposit [real number]" as numerically depositing.
Carry out numerically depositing:
	let the actual cost be the real number understood times 1gp;
	try depositing the actual cost.

This catches DEPOSIT 5 GP, DEPOSIT 5GP, DEPOSIT 5, DEPOSIT MONEY.

2 Likes

This looks great but doesn’t it conflict with my action DEPOSIT?

Depositing is an action applying to one carried thing.
Understand "deposit [something]" as depositing.

I’ll give this a try.
Can you also explain “vaguely depositing”?

btw, how long did it take you to figure out these statements, or did someone else pass them down to you? There should be cheat sheet with something like:
When you want to do this: …
When you want to do this: …
etc.

The docs give us the tools, but it’s not that great on how to achieve certain tasks.

Draconis was just helping you figure out depositing gp. It’s easy to slot an action for depositing an item in there by just switching some names around.

The Garden is a room.

Cost is a kind of value. 1.0 gp specifies a cost. 1.0gp specifies a cost.

Depositing is an action applying to one carried thing.
Understand "deposit [something preferably held]" as depositing.
Carry out depositing: say "You deposit [the noun]."

Money depositing is an action applying to one cost.
Understand "deposit [cost]" as money depositing.
Carry out money depositing: say "You deposit [cost understood]."

Vaguely depositing is an action out of world applying to nothing.
Understand "deposit money" as vaguely depositing.
Carry out vaguely depositing: say "Specify the amount of money to deposit, like DEPOSIT 5.4 GP."

Numerically depositing is an action applying to one real number.
Understand "deposit [real number]" as numerically depositing.
Carry out numerically depositing:
	let the actual cost be the real number understood times 1gp;
	try money depositing the actual cost.

Vaguely depositing there seems to largely catch saying “deposit money” as though it were an error. The action then instructs the player on how to deposit gp in the process. Notice how it’s an “action out of world”? It ignores the “before, instead, and after” rulebooks and I believe the every turn rules as well.

You could also consider letting it be a shorthand for depositing all of their gp.

The Garden is a room.

Cost is a kind of value. 1.0 gp specifies a cost. 1.0gp specifies a cost.
A thing has a cost.

Depositing is an action applying to one carried thing.
Understand "deposit [something preferably held]" as depositing.
Carry out depositing: say "You deposit [the noun]."

Money depositing is an action applying to one cost.
Understand "deposit [cost]" as money depositing.
Carry out money depositing: say "You deposit [cost understood]."

Vaguely depositing is an action applying to nothing.
Understand "deposit money" as vaguely depositing.
Carry out vaguely depositing:
	let actual cost be the cost of the player;
	try money depositing the actual cost;

Numerically depositing is an action applying to one real number.
Understand "deposit [real number]" as numerically depositing.
Carry out numerically depositing:
	let the actual cost be the real number understood times 1gp;
	try money depositing the actual cost;

There’s a degree of interpretation to this. There’s no real way to have a stringent cheat sheet because Inform is a program that can accomplish a lot of things when you put your mind to it. It’s all about understanding your tools, knowing best practice, and deciding how to accomplish things from there. It helps to think of what you need to do less like reading a map, and more like trying to build a bridge to cross a chasm. There are plenty of ways to do it. Some better than others, but certainly plenty of ways.

In this case, your issue was you only had a single action that only accepted a (carried) thing. Getting it to understand “deposit money” and “deposit [a cost]“ just meant defining additional actions which would accept those tokens.

The more you use it, the more you’ll find yourself reaching for the right tool without even realizing.

EDIT: As an aside, you can also group actions like this together under labels by declaring them [name of behaviour] behaviour. I’ve created an example showing you what that looks like (though it isn’t actually very useable since the player could theoretically just keep depositing and withdrawing money to raise the banker’s happiness, and I’d usually like the after rule to not redundantly reference the current action, but it’s just a proof of concept!).

Cost is a kind of value. 1.0 gp specifies a cost. 1.0gp specifies a cost.
A thing has a cost.

The Garden is a room.
The banker is a person in the garden. The banker has a cost called happiness.
The gold bar is a thing in the garden. The cost of the gold bar is 10.0gp.

When play begins:
	now the cost of the player is 5.0gp

Depositing is an action applying to one carried thing.
Understand "deposit [something preferably held]" as depositing.
Carry out depositing: say "You deposit [the noun]."

Money depositing is an action applying to one cost.
Understand "deposit [cost]" as money depositing.
Carry out money depositing: say "You deposit [cost understood]."

Vaguely depositing is an action out of world applying to nothing.
Understand "deposit money" as vaguely depositing.
Carry out vaguely depositing:
	let actual cost be the cost of the player;
	try money depositing the actual cost;

Numerically depositing is an action applying to one real number.
Understand "deposit [real number]" as numerically depositing.
Carry out numerically depositing:
	let the actual cost be the real number understood times 1gp;
	try money depositing the actual cost;
	
Depositing is banker-pleasing behaviour. Money depositing is banker-pleasing behaviour.

After banker-pleasing behaviour:
	if the noun is something:
		increase the happiness of the banker by the cost of the noun;
	else if the current action is money depositing:
		increase the happiness of the banker by the cost understood;
	continue the action;

As you can see here, by naming money depositing and depositing as “banker-pleasing behaviour”, I could create an after rule which caused an effect for both of them in one fell swoop!

1 Like

Draconis and Horror:
Thanks so much for this. That is some deep s…stuff.
I had to revise code somewhat (as expected) but it does what I want now.
Here is what I have:

[Standard DEPOSIT something.]
Depositing is an action applying to one carried thing.
Understand "deposit [something preferably held]" as depositing.
Carry out depositing: say "You deposit [the noun]".

[VAGUELY DEPOSIT is another kind of DEPOSIT Action.]
Vaguely depositing is an action out of world applying to nothing.
Understand "deposit money" as vaguely depositing.
Carry out vaguely depositing:
	say "Specify the amount of money to deposit, like DEPOSIT 5.4 GP."
	
[DEPOSIT numerical gold piece value.]
Numerically depositing is an action applying to one real number.
Understand "deposit [real number]" as numerically depositing.
Carry out numerically depositing: 
	let the cost be the real number understood;
	say "You deposit [cost] gp".

I will expand the carry out statements to match my story model, and to actually put gp money into the value, but this should do it.

2 Likes