Maximum Carrying Weight Problem


#1

Hey,
In my gsme the player isn’t allowed to carry more then a certain number of Kilograms (say 30). How can I prevent him from taking any items once he reached this limitation?


#2

Simply have variable to which you add Kilograms when player pickup items and subtract when he drops them.
Then if Kilograms = 30 go to Cant pickup item. you need to do it via variable and then constastly check it when player has opinion of picking up an item


#3

And how do I do it exactly? Like this?

label 1
Pick an item.
*choice
      #Heavy Teddy Bear.
       *set kilograms +10
        *if kilograms =>15
         *goto cant_carry
       *page_break
       *goto 2
      #Light Teddy Bear.
       *set kilograms +2
        *if kilograms => 15
         *goto cant_carry
       *page_break
       *goto 2

`


#4

Hi, I had a big-long reply but I accidentally deleted it :confused:

Anyways, I created an inventory system that is weight based here (look for the update at the bottom): [Resource] Please Break/Test/MakeUseOf my "Simpler Inventory System!"

It’s SUPER complex though.

Make sure you subtract the weight you added if it is over your maximum weight amount, or build in a mechanism to check for overencumbrance before adding weight.


#5

I Don’t think i’ll be able to handle this system alone… anyway it’s seems very nice. I think I’d like to check it manually, It’s just that i’m not sure how to use the “If kilograms => 30” ingame. Please explain.


#6

You would swap the signs around for ChoiceScript.

*if kilograms <= 30

will return TRUE if it is 30 or less.
<= is less than or equal to. >= is greater than or equal to.

*if kilograms > 30

will return TRUE if it is more than 30.

It doesn’t really matter which you use; if you want it to be 30, you can use > or < as long as you use 31 or 29 as your value. If you use <= then you can use your actual target number.


#7

This is the way I’d do it (not sure if this is easier or harder for you) I wouldn’t use my first choice as you’d have to be careful to then subtract the number of kg again if you’re doing that otherwise they’ll keep adding up. The following two would be easier to track in my opinion

ie
*choice
#Heavy Teddy Bear.
*set kilograms +10
*if ( kilograms > 30 )
You can’t carry that!
*set kilograms -10

Otherwise you could make it like this
*choice
      #Heavy Teddy Bear. (10kg)
*if (kilograms < 21)
Pick up item
*set kilograms +10
*if (kilograms > 20)
You can't carry that it's too heavy!

Or you could make it a selectable_if choice
ie

*choice
      *selectable_if (kilograms < 21 ) #Heavy Teddy Bear. 
*set kilograms +10