[I7] Questions about Wearing items.

Hey guys. I’ve not been using Inform for long, maybe about a week, but I’ve had plenty of experience with Actionscript. So I’m having a bit of trouble finding my footing with regards to stepping from strict languages to a language which lets you write what you want some of the time but not others. It’s a little… odd.

But my question is one that if my thoughts are proved correct, looks like a tricky one to solve.
I’ve got it so that every person has a value called strength, which defaults at 15, and an “After wearing…” section that writes who wore a piece of armour and to increase their strength by 20.
I also have an “After giving…” section to make NPCs prioritise wearing something they’ve been given instead of just holding on to it.
Now I’ve noticed that when the player wears the armour their strength goes up by 20. But when my NPC (called Barron Von Tinkletine) wears the armour his stat doesn’t increase.
I figure this is because After giving something (called gift) to someone (called giftreciever): now giftreciever wears the gift; doesn’t emulate the player activating the “Wear X” command for the NPC, but instead forces this new state instantly and therefore not firing the “After wearing…” section.
So the player is putting on the armour, but the Barron is having his armour suddenly appear on him. Am I correct?
And if so/not; how do I go about amending this to work so that whenever a player or NPC put on clothing their stats change?
If you guys know of any part of the documentation to point me to or have any advice I’d appreciate it.
Thanks. =)

I’m no expert, but I believe something like

try giftreceiver putting on the gift; should work.

This also covers any cases in the future where giftreceiver might not be able to put on the gift (they’re already wearing too much, have one of those, etc.), should you choose to implement something like that in future.

Adding ‘silently’ to the beginning should suppress any messages, though I don’t know if an NPC would give one anyway.

Anyone with more knowledge please correct me!

Seems correct to me, beefparty.

Berty, your understanding about the player wearing the armor vs. the Baron having it magically appear is correct. Chapter 12 in the documentation has lots of useful stuff about this; the “try” syntax is in 12.6 and there’s more stuff about NPC action in 12.11 and following sections.

try giftreceiver putting on the gift;

Now if there’s anything that’s going to be the solution it’s going to be something simple like this. =P
I’ve just tried it now, putting it here;

After giving something (called gift) to someone (called giftreciever): say "You give [the gift] to [giftreciever]."; if the gift is a shirt: if the giftreciever is not wearing a shirt: say ""; try giftreciever putting on the gift; [--- This used to be "now giftreciever wears the gift;"] else: now giftreciever carries the gift; say "[giftreciever] holds onto the [gift].";
Now, it’s not throwing an error, but in the Game output window typing;

give plate to barron
Gives the result:

"You give the Chest Plate to Barron Von Tinkletine.

You must supply a noun."

(Chest Plate is just defined as a shirt and only has a description.)

I’ve commented out that line and run everything again and I don’t get the “You must supply a noun.” line, so it’s either gift or giftreciever that is generating that. And I don’t have enough Informian knowledge to deduce which.
But regardless of that entire line being commented out the Chest Plate goes into Barron Von Tinkletine’s inventory, but that’ll probably be from the default “Give X to X” action.

Here’s the source code if you want to look at it. Not much there as it’s just a theory testing ground:

[spoiler][code]“TestingCommands” by Berty

The block giving rule is not listed in the check giving it to rules.

A person has a number called Strength. The Strength of a person is usually 15.

Clothing is a kind of thing. Clothing is wearable.
A shirt are a kind of clothing.

Understand “ask for [something] from [someone]” as askingfor it from. askingfor it from is an action applying to two visible things.

Carry out askingfor something (called askItem) from someone (called askPerson):
if askPerson carries askItem:
say “[askPerson] hands you their [askItem].”;
now the player carries askItem;
else if askPerson wears askItem:
say “[askPerson] takes off their [askItem] and hands it over to you.”;
now the player carries askItem;
else:
say “[askPerson] does not have [askItem] to give to you.”;

After wearing a shirt (called CLOTH):
let WEARER be the holder of CLOTH;
say “[WEARER] puts on the [CLOTH].”;
now the Strength of WEARER is the Strength of WEARER plus 20;

After taking off a shirt (called CLOTH):
let WEARER be the holder of CLOTH;
say “[WEARER] takes off the [CLOTH].”;
now the Strength of WEARER is the Strength of WEARER minus 20;

Before examining a person (called EXAMI):
if EXAMI wears something:
say “[if noun is the player]You are [else][noun] is [end if]wearing [a list of things worn by EXAMI].”;
else:
if noun is the player:
say “You are currently only in your night gown. Best to find some proper clothes.”;
else:
say “They appear to be only in their night gown. You avert your eyes.”;
say “[line break]The Strength of this character is [Strength of noun].”

After giving something (called gift) to someone (called giftreciever):
say “You give [the gift] to [giftreciever].”;
if the gift is a shirt:
if the giftreciever is not wearing a shirt:
say “”;
[ try giftreciever putting on the gift;]
else:
now giftreciever carries the gift;
say “[giftreciever] holds onto the [gift].”;

A Chest Plate is a shirt. The description of the Chest Plate is “Big and shiny. A good source of protection.”
Tha Armoury is a room. “A forge on the far wall, and an huge wall of weapons lies to your right.”
The Chest Plate and the player is in it.

Barron Von Tinkletine is a man in The Armoury. The Strength of Barron Von Tinkletine is 100.[/code][/spoiler]

And thanks, I’ll take a look at those sections of the documentation. =)

Whoops, I missed this: It should be

 try giftreciever wearing the gift

as “wearing” is the name for the action invoked by, well, wearing something. Inform is interpreting “try giftreciever putting on the gift” as “try giftreciever putting [something ought to go here] on the gift” – the putting it on action is invoked by PUT THIS ON THAT – and since there isn’t anything between “putting” and “on,” it’s saying “You must supply a noun.”

Also, some spelling things – it’s receiver rather than reciever (I before E except after C), and nightgown is usually one word.

Whoops! You’re right. Sorry about that. :blush:

Ah, of course. That makes sense.

Well, that’s what you get for coding at 1am, miss silly mistakes. =P

But unfortunately that’s still not triggering the “After wearing…” section as the Barron wears the item but there’s no stat increase. So I’m guessing unless there’s an action for truly emulating the Wear command then it’s going to have to involve defining a new command; which I’ve been struggling greatly with. Which means more trying to comprehend the documentation. Which means more headaches for me. Ah well, I’ll slug on with it in the morning.

No worries. =)

This seems to work:

After someone (called WEARER) wearing a shirt (called CLOTH): say "[WEARER] puts on the [CLOTH]."; now the Strength of WEARER is the Strength of WEARER plus 20;

I think the ‘someone’ is key (otherwise the command only applies to the player, maybe?).

Note that when asking for the plate back, the Barron isn’t losing the strength that it gave him, meaning that his strength goes up indefinitely if you keep asking for it back and then returning it to him.

Oh herp derp, I forgot to check your code for this. The problem is that rules like “After wearing:” written like that only apply to the PC. If you want a rule that will apply to PCs and NPCs alike, you have to write “After an actor wearing:”. This is discussed in section 12.14 of the documentation. [Updating on posting: I think Beefparty’s code is a rule that applies only to NPCs as in 12.14, which would work fine if you leave in your old rule.]

There are some more quirks here, though. Right now when you wear a shirt it says “yourself puts on the plate” (or something like that). You could write a rule with a special case so that whenever the actor is a player it prints “You” instead of “yourself,” but it might be easier to write separate rules for the player and for NPCs. Section 12.14 will tell you how to do that. (Or it might not be simpler – at least if you have only one rule, when you change it you only have to change it once.)

Another thing is that if you ask the Barron (which I keep wanting to spell “Baron”) for the Plate when he’s wearing it, he won’t lose his strength bonus [as Beefparty noticed]. That’s because the code magics the plate over to you instead of having him take it off – you’d need to try silently the actor taking off the plate (can’t do the exact code right now).

You might also want to try adding this line:

Persuasion rule for asking someone to try giving: rule succeeds.

This will allow “ask barron for plate” to succeed (as well as “Barron, give me plate”; in fact “ask barron for plate” gets converted into such a request). This in fact automatically has the Barron take off the plate if he’s wearing it. Or you could write

Instead of asking someone for something: try askingfor the second noun from the noun.

and that would go through the code you’ve written.

Yeh, easily fixed by adding:

say "[askPerson] takes off their [askItem] and hands it over to you."; try askPerson taking off the askItem; now the player carries askItem;

Ah now that was intentional. There’s an old-ish pop group called the Barron Knights, and I was messing with the idea of the Barron being the leader of a group of knights. Just a silly little thing.

Yeh I noticed this, but it’s easily fixable with an if statement and was the least of my concerns. =)
And I think I prefer sticking to one function for both the player and NPCs.

Awesome, that’s some nice optimisation.

And thanks guys, this works a treat now. Got it all working. Both the player and the NPC get a buff to their strength when wearing the Chest Plate and have the buff removed when taking it off. Exactly what I wanted. I’ll re-read over the Actions and NPCs documentation, clearly half of it didn’t go in the first time. =P
You guys are awesome.

Do keep us updated with anything interesting you discover or are finding hard to solve.

As I said, I’m fairly new to Inform myself, but it’s interesting seeing people solve similar problems to ones that I’ve had or am having in different ways!

You can also write it like this.

After someone wearing a shirt: say "[The actor] puts on [the noun]."; increase the strength of the actor by 20.

You don’t need to add the extra variables here as they are stored as the actor and the noun for the duration of the action.

Also, Inform allows “increment (number)” and “decrement (number)” when changing a number by one. It also allows “increase (number) by (number)” and “decrease (number) by (number)” for changes that are not one.

While this is correct here, the rule “I before E except after C” actually has more exceptions than it does cases that follow it. These words break the rule.

abseil, abseiled, abseiling, abseils, absenteeism, ageing, ageism, ageist, ageists, agencies, agreeing, airfreight, albeit, ancient, ancienter, ancientest, anciently, ancientness, ancients, anteing, apartheid, appliqueing, aristocracies, atheism, atheist, atheistic, atheists, autocracies, aweigh, bankruptcies, bantamweight, bantamweights, baronetcies, beige, being, beings, bingeing, birdieing, blatancies, blueing, blueish, bobsleigh, bobsleighed, bobsleighing, bobsleighs, boccie, bogieing, boogieing, bouncier, bounciest, bureaucracies, caffeine, candidacies, canoeing, canoeist, canoeists, captaincies, casein, chancier, chanciest, chaplaincies, clueing, codeine, coefficient, coefficients, coheir, coheirs, competencies, concierge, concierges, confederacies, conscience, conscienceless, consciences, conscientious, conscientiously, conscientiousness, conservancies, consistencies, conspiracies, constituencies, consultancies, contemporaneity, contingencies, counterfeit, counterfeited, counterfeiter, counterfeiters, counterfeiting, counterfeits, counterinsurgencies, counterweight, counterweights, cueing, cuneiform, curacies, currencies, deadweight, deadweights, decaffeinate, decaffeinated, decaffeinates, decaffeinating, decencies, decreeing, deficiencies, deficiency, deficient, deice, deiced, deicer, deicers, deices, deicing, deification, deified, deifies, deify, deifying, deign, deigned, deigning, deigns, deism, deist, deistic, deists, deities, deity, delicacies, delinquencies, democracies, dependencies, dicier, diciest, disagreeing, discrepancies, dyeing, edelweiss, efficiency, efficient, efficiently, eider, eiderdown, eiderdowns, eiders, eight, eighteen, eighteens, eighteenth, eighteenths, eighth, eighths, eighties, eightieth, eightieths, eights, eighty, einsteinium, eisteddfod, eisteddfods, either, emceeing, emergencies, equivalencies, excellencies, exigencies, expediencies, eyeing, facsimileing, fallacies, fancied, fancier, fanciers, fancies, fanciest, farseeing, featherweight, featherweights, feign, feigned, feigning, feigns, feint, feinted, feinting, feints, feistier, feistiest, feisty, filigreeing, financier, financiers, flambeing, fleecier, fleeciest, fleeing, flouncier, flounciest, flyweight, flyweights, foreign, foreigner, foreigners, foreignness, foreseeing, forfeit, forfeited, forfeiting, forfeits, forfeiture, forfeitures, freeing, freight, freighted, freighter, freighters, freighting, freights, frequencies, fricasseeing, garnisheeing, geeing, geisha, geishas, gesundheit, glacier, glaciers, glueing, gneiss, guaranteeing, gumshoeing, hacienda, haciendas, heavyweight, heavyweights, heifer, heifers, height, heighten, heightened, heightening, heightens, heights, heinous, heinously, heinousness, heir, heiress, heiresses, heirloom, heirlooms, heirs, heist, heisted, heisting, heists, herein, hereinafter, heterogeneity, hieing, hoeing, hogtieing, homogeneity, horseshoeing, howbeit, hundredweight, hundredweights, icier, iciest, idiocies, ileitis, immediacies, immunodeficiency, immunodeficient, inaccuracies, inadequacies, inconsistencies, incumbencies, indecencies, indelicacies, inefficiencies, inefficiency, inefficient, inefficiently, insolvencies, insufficiency, insufficient, insufficiently, insurgencies, intimacies, intricacies, inveigh, inveighed, inveighing, inveighs, inveigle, inveigled, inveigler, inveiglers, inveigles, inveigling, irrelevancies, jadeite, jouncier, jounciest, juicier, juiciest, kaleidoscope, kaleidoscopes, kaleidoscopic, kaleidoscopically, kneeing, lacier, laciest, legacies, lei, leis, leisure, leisured, leisureliness, leisurely, leisurewear, leitmotif, leitmotifs, leitmotiv, leitmotivs, lightweight, lightweights, lunacies, makeweight, makeweights, malignancies, marbleize, marbleized, marbleizes, marbleizing, meiosis, meiotic, mercies, meritocracies, messeigneurs, middleweight, middleweights, monotheism, monotheist, monotheistic, monotheists, monseigneur, moreish, mullein, necropoleis, neigh, neighbor, neighbored, neighborhood, neighborhoods, neighboring, neighborliness, neighborly, neighbors, neighbour, neighboured, neighbourhood, neighbourhoods, neighbouring, neighbourliness, neighbourly, neighbours, neighed, neighing, neighs, neither, nisei, niseis, nonpareil, nonpareils, nonscientific, nuclei, obeisance, obeisances, obeisant, ogreish, omniscience, omniscient, onomatopoeia, onomatopoeic, outweigh, outweighed, outweighing, outweighs, overconscientious, overseeing, overweight, pacier, paciest, pantheism, pantheist, pantheistic, pantheists, papacies, paperweight, paperweights, peeing, peignoir, peignoirs, pennyweight, pennyweights, pharmacies, pharmacopeia, pharmacopeias, pharmacopoeia, pharmacopoeias, pieing, plebeian, plebeians, plutocracies, policies, poltergeist, poltergeists, polytheism, polytheist, polytheistic, polytheists, pregnancies, prescience, prescient, presciently, presidencies, pricier, priciest, proficiency, proficient, proficiently, proficients, prophecies, protein, proteins, pseudoscience, pseudosciences, pureeing, queueing, racier, raciest, redundancies, redyeing, refereeing, regencies, reign, reigned, reigning, reignite, reignited, reignites, reigniting, reigns, reimbursable, reimburse, reimbursed, reimbursement, reimbursements, reimburses, reimbursing, reimpose, reimposed, reimposes, reimposing, rein, reincarnate, reincarnated, reincarnates, reincarnating, reincarnation, reincarnations, reincorporate, reincorporated, reincorporates, reincorporating, reincorporation, reindeer, reindeers, reined, reinfect, reinfected, reinfecting, reinfection, reinfections, reinfects, reinforce, reinforced, reinforcement, reinforcements, reinforces, reinforcing, reining, reinoculate, reinoculated, reinoculates, reinoculating, reins, reinsert, reinserted, reinserting, reinsertion, reinserts, reinspect, reinspected, reinspecting, reinspects, reinstate, reinstated, reinstatement, reinstates, reinstating, reinsurance, reintegrate, reintegrated, reintegrates, reintegrating, reintegration, reinterpret, reinterpretation, reinterpretations, reinterpreted, reinterpreting, reinterprets, reintroduce, reintroduced, reintroduces, reintroducing, reintroduction, reinvent, reinvented, reinventing, reinvention, reinventions, reinvents, reinvest, reinvested, reinvesting, reinvestment, reinvests, reinvigorate, reinvigorated, reinvigorates, reinvigorating, reissue, reissued, reissues, reissuing, reiterate, reiterated, reiterates, reiterating, reiteration, reiterations, reiterative, residencies, reveille, reweigh, reweighed, reweighing, reweighs, rottweiler, rottweilers, saucier, sauciest, sauteing, science, sciences, scientific, scientifically, scientist, scientists, seeing, segueing, seigneur, seigneurs, seignior, seigniorial, seigniors, seine, seined, seiner, seiners, seines, seining, seismic, seismically, seismograph, seismographer, seismographers, seismographic, seismographs, seismography, seismologic, seismological, seismologist, seismologists, seismology, seize, seized, seizes, seizing, seizure, seizures, sheik, sheikdom, sheikdoms, sheikh, sheikhdom, sheikhdoms, sheikhs, sheiks, sheila, sheilas, shoeing, sightseeing, simultaneity, singeing, skein, skeins, sleigh, sleighed, sleighing, sleighs, sleight, sleights, snowshoeing, societal, societies, society, sortieing, sovereign, sovereigns, sovereignty, spacier, spaciest, specie, species, spicier, spiciest, spontaneity, squeegeeing, stein, steins, stymieing, subspecies, sufficiency, sufficient, sufficiently, surfeit, surfeited, surfeiting, surfeits, surveillance, swingeing, technocracies, teeing, tenancies, tendencies, their, theirs, theism, theist, theistic, theists, theocracies, therein, tieing, tingeing, tiptoeing, toeing, transparencies, treeing, trueing, twingeing, underweight, unfeigned, unscientific, unscientifically, unseeing, unseeingly, unveil, unveiled, unveiling, unveils, vacancies, valencies, veil, veiled, veiling, veils, vein, veined, veining, veins, villein, villeinage, villeins, viscountcies, weeing, weigh, weighbridge, weighbridges, weighed, weighing, weighs, weight, weighted, weightier, weightiest, weightily, weightiness, weighting, weightings, weightless, weightlessly, weightlessness, weightlifter, weightlifters, weightlifting, weights, weighty, weir, weird, weirder, weirdest, weirdie, weirdies, weirdly, weirdness, weirdo, weirdos, weirs, welterweight, welterweights, wherein, whingeing, whoreish, zeitgeist, zeitgeists

Hope this helps.

The word list I keep around for solving puzzles has 9691 entries containing “ie”, only 1687 with “ei”. And excluding cases with a preceding “c” doesn’t change the numbers by much – the ratio still holds.

Yeah, really there’s no substitute for learning how to spell the word. But it holds in this case.

(Plurals of words ending in -cy seem like cheating, though. How many examples of words with “cie” are there that aren’t derived from a word with -cy?)

The most reliable way to avoid such bugs would likely be recalculating the strength of each character whenever needed using a “To decide which number is…” rule, something like this:

"THAC0" by Vyznev Xnebara

The story headline is "An interactive demonstration".

Section - Clothing

Clothing is a kind of thing. Clothing is usually wearable.

The ratty T-shirt is clothing. Understand "t/tee/shirt/tee-shirt" as the T-shirt.
The shining helmet is clothing. The armor class is 3.
The amulet of might is clothing. The strength bonus is 5.
The really heavy plate armor is clothing. The armor class is 10. The strength bonus is -3.

Section - Armor class

A person has a number called the base armor class.
The base armor class of a person is usually 0.

Clothing has a number called the armor class.
The armor class of clothing is usually 0.

To decide which number is the effective armor class of (the character - a person):
	let the current armor class be the base armor class of the character;
	repeat with the item running through clothing worn by the character:
		increase the current armor class by the armor class of the item;
	decide on the current armor class.

Section - Strength

A person has a number called the base strength.
The base strength of a person is usually 10.

Clothing has a number called the strength bonus.
The strength bonus of clothing is usually 0.

To decide which number is the strength of (the character - a person):
	let the current strength be the base strength of the character;
	repeat with the item running through clothing worn by the character:
		increase the current strength by the strength bonus of the item;
	decide on the current strength.

Section - Stats reporting

Clothing can be identified or unidentified. Clothing is usually unidentified.

Carry out wearing clothing: now the noun is identified.
Carry out taking off clothing: now the noun is identified.

After printing the name of identified clothing (called the equipment):
	say the stats of the equipment.

To say the stats of (the equipment - clothing):
	say " (AC [armor class of the equipment]";
	let bonus be the strength bonus of the equipment;
	if bonus is not 0, say ", [if bonus > 0]+[end if][bonus] STR";
	say ")".

Report examining yourself:
	say "You are wearing [the list of things worn by the player]. Your armor class is [effective armor class of the player] and your strength is [strength of the player]."

Section - Setting

The Armory is a room. The T-shirt, the helmet, the amulet and the armor are in it.

Test me with "x me / get all / i / wear shirt / wear helmet / wear amulet / wear armor / x me / take off armor / x me / i".