Redefining an action

I thought this might do, but it don’t.


Understand the command "buy" as something new.

Buying is an action applying to one visible thing.

Understand "buy [something]" as buying.

Check buying screwdriver:
	if player does not carry fifty dollars:
		say "[']I can't just give you the screwdriver. You got to pay for it, podnuh.";
	otherwise:
		if player does not carry three dollars:
			say "[']I can't just give you the screwdriver. You got to pay for it, podnuh.";
		otherwise:
			say "Joe hands you the screwdriver, smiles, and says [']Have a nice day, podnuh.[']";
			continue the action.

Problem message:

Problem. You wrote ‘Buying is an action applying to one visible thing’ : but that seems to be an action already existing, so it cannot be redefined now. If you would like to reconfigure an action in the standard set - for instance if you prefer ‘unlocking’ to apply to only one thing, not two - create a new action for what you need (‘keyless unlocking’, perhaps) and then change the grammar to use the new action rather than the old (‘Understand “unlock [something]” as keyless unlocking.’).

There’s already a buying action. Why are you trying to make a new one?

Hmmm, guess I just didn’t understand. Thanks. I’ll work on the code.

Seems to me this oughta work, but it doesn’t.

Check buying screwdriver: if player does not carry fifty dollars: say "[']I can[']t just give you the screwdriver. You got to pay for it, podnuh."; otherwise: say "'Glad doin['] business with you, podnuh,['] Joe says as he hands you the screwdriver and your change."; now player carries screwdriver; now player carries forty-seven dollars; continue the action. otherwise: if player does not carry three dollars: say "[']I can[']t just give you the screwdriver. You got to pay for it, podnuh."; otherwise: say "Joe hands you the screwdriver, smiles, and says [']Have a nice day, podnuh.[']"; continue the action.

Problem message:

Problem. You wrote ‘otherwise’ : but the punctuation here ‘:’ makes me think this should be a definition of a phrase and it doesn’t begin as it should, with either ‘To’ (e.g. ‘To flood the riverplain:’), ‘Definition:’, a name for a rule (e.g. ‘This is the devilishly cunning rule:’), ‘At’ plus a time (e.g. ‘At 11:12 PM:’ or ‘At the time when the clock chimes’) or the name of a rulebook, possibly followed by some description of the action or value to apply to (e.g. ‘Instead of taking something:’ or ‘Every turn:’).

Issue is with indentation of the second “otherwise” statement. It should be indented one step. This makes me wonder if you’re mixing up rule preambles and rule bodies: the “check buying screwdriver” line is not an if statement, and can’t be paired with an “otherwise” statement.

Seems like what you want is to describe the player’s current fortune with some number, rather than as an object the player is carrying (“forty seven dollars”) You could implement this with a variable, but you’d have to come up with a way to communicate the number to the player. (Maybe with an action like “count money” or something.) Another way would be to give the player an object that has money as a numerical property, like a wallet, and make sure you print the property with the object name. For instance:

[code]“Hardware Store”

The Hardware Store is a room. “This is a hardware store.”

Joe is a person in Hardware Store. There is a screwdriver in the hardware store.

The player is carrying a wallet. The wallet has a number called dollars. The dollars are 50. The description of the wallet is “This beat up old wallet has $[dollars] in it.” After printing the name of the wallet, say " (with $[dollars] in it)".

Instead of buying the screwdriver:
if the wallet is not carried by the player or the dollars of the wallet are less than 3:
say “‘I can[’]t just give you the screwdriver. You got to pay for it, podnuh.’”;
otherwise:
now player carries screwdriver;
decrease the dollars of the wallet by 3;
say “‘Glad doin[’] business with you, podnuh,’ Joe says as he hands you the screwdriver and your change.”[/code]

There’s probably a more elegant to make that work than “dollars of the wallet” but it’s functional.

Thanks, Matt_W. I wrote some of that into my code and it compiles. Have yet to see whether the code does what I want it to.