Carry capacity on something not a container?

Follow me here. This isn’t code, just what I want to happen.

A weapon is a kind of thing. A gun is a weapon. A bullet is a kind of thing. A gun can contain bullets, so it must be a container (I don’t think you can give a carrying capacity to anything other than a container?). But not all weapons are guns, so not all weapons are containers.

How do I go about that? And hey, thanks for listening to my boring questions :stuck_out_tongue: I’m having fun learning!

Update: On further digging into the documentation, I feel this can be done through “Parts of things”. Still trying to work it out…

I’m also not sure how holding bullets will work. Say the player can hold 4 things at a time, but you want the game to see several bullets as one thing (because you know, they’re so small). How’s that work? :slight_smile:

“Parts of things” sounds like a good idea. Try this (untested):

[code]A weapon is a kind of thing. A gun is a kind of weapon. A magazine is a kind of container. Every gun incorporates a magazine. [alternatively: a magazine is part of every gun.] The carrying capacity of a magazine is usually 6. A bullet is a kind of thing.

Instead of inserting something into a gun (called boomstick): try inserting the noun into a random magazine incorporated by boomstick. [you may have to fiddle with the rule that prevents you from putting things into noncontainers to make sure this rule fires.]

Check inserting something into a magazine:
if the noun is not a bullet:
say “You can only put bullets into [the random gun incorporating the second noun].”[/code]

Your second question about carrying capacity seems more complicated. I might take care of it by not worrying about the player’s carrying capacity. :smiley:

You don’t necessarily have to model the bullets as separate objects. It might be easier to give a gun a number and vary it to keep track of how many bullets are left.

Similarly, you could create a ‘bullets’ object to be carried by the player, and have it represent all the bullets he carries; then give the bullets objects a number, too, to keep track of how many bullets that object represents.
You could even have the bullets object change its printed name to show how many bullets it stands for: The printed name of the bullets is “[bullet stock in words] bullet[if bullet stock is not 1]s[end if]”. (‘bullet stock’ would be the number that tracks the number of bullets carried - ‘in words’ sees to it that a number is printed in letters rather than figures.)
The code above is untested, but I trust you get the drift.

Thanks! I tried both methods, and settled on a modification of the first, as it has the least complexities down the road (for example, having 12 bullets, but only putting 4 in the gun, etc), and because I came up with an idea for dealing with the player’s inventory that was a bit different.

I’d rather not make yet another thread so I’ll ask this question here, it’s related as it has to do with the way the inventory and how much can be carried is handled.

A thing has a number called Largeness. The largeness of a thing is usually 3. [Tiny, Small, Medium, Large, Huge = 1,2,3,4,5] A container has a number called Sizecap. The sizecap of a container is usually 3. [Tiny, Small, Medium, Large, Huge = 1,2,3,4,5]

This is useful to make sure something big can’t be put into a small container, but I realised I can also use it to replace the player carry capacity with something a bit more dynamic. If, every time the player tries to take something, the game can sum up the largeness values of each of the items currently being held (not including those being worn, or those inside containers, just the things being held in the players hands so to speak), the game can easilly decide if the player can hold more or not.

With the idea being, the player could hold lots of small things, or only one or two large things, or somewhere in between. I don’t know the exact code to make this happen, this is what I’ve got although the compiler doesn’t recognise “sum of the largeness of all carried things” (I was just guessing as I couldn’t find what I wanted in the documentation, so reasonable that it would be wrong :stuck_out_tongue:):

Check taking something (called the to-be-taken): Let Value1 be the sum of the largeness of all carried things; if Value1 is greater than 30: say "You can't carry any more!"; rule fails; otherwise: continue the action

So…how can I make this workable code? Also I know I say thanks, but thanks again, I know I ask a lot of questions :stuck_out_tongue:

You can also write it like this.

The printed name of the bullets is "[bullet stock in words] bullet[s].".

Hope this helps.

Oh gods, I keep asking questions that I’ve been stuck on for ages and then suddenly finding the answer afterwards. At least it will be useful for people asking the same questions!

My father just suggested I try using “total” rather than “sum”. I came up with this, which works:

Check taking something (called the to-be-taken): Let Value1 be the total largeness of all carried things; say "[Value1]"; if Value1 is greater than 50: say "You can't carry any more! Put something down, or in a bag?"; rule fails; otherwise: continue the action

Of course, I have to go and make sure it’s not including the things the player is wearing as a “carried thing”. I’ve just noticed the code seems to work and come straight back here to say so lol.

Thanks! All these examples ways of handling the presentation of values and language helps a lot :slight_smile:

You may want to consider using the “Bulk Limiter by Eric Eve” Extension. It pretty much does what you want to do plus more. You can get hold of it here.

Hope this helps.

Great! I’ll take a look right now.

That extension works great! Props to Eric Eve.

I’ve modified it a bit to give supporters a bulk capacity too, so that you can fit lots of small things or only a few large things onto things like tables, beds, etc.

I’m trying to figure out how to change it to include the player (or indeed any actor) entering a supporter too. I’ve given the player a bulk value, so I should be able to check the player’s bulk value against the bulk capacity of the supporter, to decide if there’s enough “room”. I’ve examined the code used in the extension, and tried to produce my own addition, but it doesn’t work.

When the player is already on the supporter, the player’s bulk is added to the bulk of the supporter, as it should be. But the player can get onto a supporter regardless of the bulk capacity of the supporter. Anyway, I’ll just paste the actor entering check that doesn’t work and the parts that seem relevant to it, rather than pasting the whole extension in. If it’s not clear what the problem is from it though, I’ll paste it all! lol. I’ve talked myself through it, but can’t find a problem.

[code]
A thing has a number called bulk.
The bulk of a thing is normally 1.

A person has a number called bulk capacity.
The bulk capacity of a person is normally 12.

Check an actor entering when the second noun provides the property bulk capacity (this is the entering bulk test rule):
if the bulk of the actor is greater than the bulk capacity of the second noun,
say “[The actor] [is-are] too big to fit on [the second noun].” instead;
if the bulk of the actor is greater than the free capacity of the second noun,
say “There is not enough room left on [the second noun] for [the actor].” instead;

To decide what number is the free capacity of (targetsupporter - a supporter):
let sum be the total bulk of the things on the targetsupporter;
now sum is the bulk capacity of the targetsupporter minus sum;
decide on the sum.[/code]

Hmm, it’s midnight. Perhaps I should take a rest :stuck_out_tongue:

The entering action has no second noun. It should be the noun. Try this.

[code]“Test”

Include Bulk Limiter by Eric Eve.

A supporter has a number called bulk capacity.
The bulk capacity of a supporter is normally 10.

Check an actor putting on when the second noun provides the property bulk capacity (this is the supporter bulk test rule):
if the bulk of the noun is greater than the bulk capacity of the second noun, say “[The noun] [is-are] too big to fit on [the second noun].” instead;
if the bulk of the noun is greater than the free capacity of the second noun, say “There is not enough room left on [the second noun] for [the noun].” instead.

Check an actor dropping when the holder of the actor provides the property bulk capacity (this is the dropping bulk test rule):
now the second noun is the holder of the actor;
if the bulk of the noun is greater than the bulk capacity of the second noun, say “[The noun] [is-are] too big to fit [if the second noun is a supporter]on[otherwise]in[end if] [the second noun].” instead;
if the bulk of the noun is greater than the free capacity of the second noun, say “There is not enough room left [if the second noun is a supporter]on[otherwise]in[end if] [the second noun] for [the noun].” instead.

Check an actor entering when the noun provides the property bulk capacity (this is the entering bulk test rule):
if the bulk of the actor is greater than the bulk capacity of the noun, say “[The actor] [is-are] too big to fit [if the noun is a supporter]on[otherwise]in[end if] [the noun].” instead;
if the bulk of the actor is greater than the free capacity of the noun, say “There is not enough room left [if the noun is a supporter]on[otherwise]in[end if] [the noun] for [the actor].” instead.

To decide what number is the free capacity of (targetbox - a supporter):
let sum be the total bulk of the things on the targetbox;
now sum is the bulk capacity of the targetbox minus sum;
decide on the sum.

The Testing Room is A Room. The table is an enterable supporter in the testing room. The bulk of the player is 10. The box is in the testing room. The bulk of the box is 10.

Test me with “enter table / exit / put box on table / enter table / take box / enter table / put box on table”.[/code]

Hope this helps.

Oh of course! It works beautifully now :slight_smile: