Is there a way to make the player unable to pick-up all objects if a certain condition isn't met?

Working on multiple games, trying to see if there's a way to have a hand system.
Basically, you've got a left hand, and a right hand.
I'm hoping for something, like an attribute I can't find anywhere, that can make it so if both hands are full, you can't pick up anything more until you put what you've got into your bag or pocket or just drop it again.

All I need is something that can restrict picking-up objects.
Please help.


I think the easiest way to do it would be to use the 'limited containers' thing.
If the player has a maxobjects attribute, it specifies the maximum number of objects they can pick up.

If you give the player a maxobjects of 2, then you can only hold 2 objects.
If you set the player's maxobjects to 3, that lets them carry 2 objects plus a backpack… which is probably close to what you want.

If you want to be able to drop the backpack, you could give it "take" and "drop" scripts that adjust the player's maxobjects accordingly. Or even a simple changedparent script.

Or if you're using "advanced options for wearables", you could make the backpack wearable and give it the attribute modifier maxobjects+1. That means that the player can carry 2 objects before they get the "You can't carry any more items." message; but wearing the backpack gives them space for 1 more (effectively meaning that the backpack doesn't take up a slot when it's worn).

Hope that makes sense; I'm answering without Quest open, and can't quite remember where all the options are in the editor or how they're labelled.

Note: If using this method, any scripts you've written that add an object to the inventory will be able to take the player over the limit. So if an NPC is giving something to the player, for example, you would need to check that the player's hands aren't full. It would end up looking something like:

if (ListCount (GetDirectChildren (game.pov)) < game.pov.maxobjects) {
  msg ("John gives you the {object:bell}.")
  AddToInventory (bell)
}
else {
  msg ("John tries to give you the {object:bell} but your hands are full, so he puts it down next to you instead.")
  MoveObjectHere (bell)
}

Log in to post a reply.

Support

Forums