Calculating a property?

I’m trying to assign actors a Strength property, from which is automatically calculated their carrying capacity. I have already specified the weight property earlier in the code. However, adjusting the person’s strength does not adjust their carrying capacity.

[code]A person has a number called strength.
The strength of a person is normally 10.

A person has a weight called maximum capacity.
The maximum capacity of a person is normally 50kg.

To decide what weight is the maximum capacity of (the lifter - a person):
let Z be the maximum capacity of the lifter;
let N be the strength of the lifter;
let M be N * N / 8;
decide on Z.[/code]

If you use a to decide phrase, you shouldn’t assign it as a property, because you can’t use both methods at the same time. So remove these lines:

A person has a weight called maximum capacity. The maximum capacity of a person is normally 50kg.
Secondly, there’s something wrong with the algorithm that calculates the maximum capacity. The first line assigns the property value of maximum capacity to Z. The next two lines do calculations with N and M, but in the end you discard the results and return Z unchanged. Should the last line read “decide on M”?

Interesting! I hadn’t noticed that I had made that variable switch. After some tinkering, I got it to work! Woohoo.

Now if I can get it to play nice with Bulky Items by Juhana Leinonen. Right now, it’s performing the “drop everything to make room” action before checking the weight of the bulky thing you’re trying to lift.

You can put your rule before the built-ins with the word “first”:

First before taking a bulky thing: say "I can't be bothered." instead.

Hmmm. I’m playing with the Bulky Items extension, hoping to get it to play nicely with the idea of Strength and carrying capacity. In particular, I hope to say “if the player is strong enough to pick it up with one arm, the item is not bulky; if the player must use two arms to pick it up, it is bulky; if the player cannot pick it up with two arms, it is too heavy. If it’s bulky, follow the bulky rules; if it’s too heavy, follow the too heavy rules.”

At what stage in the “actor taking a thing” do I assign these properties? Is this a “Before” or a “Check” thing?

I tried tinkering with the Bulky Items extension a bit to make it do what I wanted, namely removing the line “A thing can be bulky. A thing is usually not bulky.”

I couldn’t get a definition to work properly, though.

To decide if a thing is bulky when an actor (called the lifter) is taking the noun:
let N be the one-armed capacity of the lifter;
let M be the maximum capacity of the lifter;
if the noun is heavier than N and the noun is lighter than M, decide the noun is bulky.

Would that work? (I’m at work, away from my Inform compiler.)

There, got it.

First before taking a thing (this is the is it bulky rule): let N be the one-armed capacity of the player; let M be the maximum capacity of the player; if the noun is heavier than M, now the noun is too heavy; if the noun is heavier than N and the noun is lighter than M, now the noun is bulky; if the noun is lighter than M, now the noun is not too heavy; if the noun is lighter than N, now the noun is not bulky; continue the action.

I haven’t used these much, but don’t you want “decide yes” instead of “decide the noun is bulky”? That seems like it might let you hook the definition in in a more general way, which could work more generally than using a rule that applies only to taking.

Or perhaps you could do a “To decide” phrase that wraps up the definitions for bulky, too heavy, and whatever the other thing is in one. But I think that might require defining bulkiness as a kind of value with values bulky, too heavy, and manageable, and that’d probably play very poorly with the extension. I’m somewhat out of my depth here, though, so these are just suggestions.

I think the “first before taking” rule works just fine, because a thing can become bulky, or not bulky, depending on who is holding it. Every time it someone attempts to take it, it changes hands, so it should change states. It will remain in that state even after it’s dropped … until the moment someone needs it again.

The “bulky” attribute in the Bulky Items basically tells the player to drop everything to make room for one massive inventory item: a sofa, perhaps, or a boulder. It is separate from the “bulk” attribute in Eric Eve’s Bulk Limiter (which is designed to prevent putting a sofa into a handbag, or a planet into a shoe).

I think we need more games where putting a planet in a shoe is a desirable course of action…

1 Like

Yeah, I guess to do what I was thinking in the general case you’d have to make bulkiness into a relation, and that almost certainly wouldn’t play nice with the extension. I’m not even sure if you could make such a relation, or only in 6Exx, or what.