How do I set storage limits for items? (Solved)

0 favourites
  • 3 posts
From the Asset Store
Basic Plugins for Firebase Authentication, Realtime-Database, Firestore, Cloud Storage
  • Hey experts!

    In this game I’m working on, the character gathers items and stores them. However the items have a value called “weight” and I’m trying to prevent the character from exceeding his max storage value.

    Example: if item has weight of 5 and the storage max is 6, the item can go into storage. However when he picks up another item, he can put it in storage but can’t pick any others up unless he empties storage so there is at least 1 space left.

    I have the system check that the item’s weight variable value is less than the total_storage variable (both global variables). What I need is for the system to check if there is enough room between total weight and the item’s weight.

    (Example)

    Total storage variable = 6

    Item storage value = 5

    Current storage value = 4

    Game should prevent the item going into storage. Not sure how to program that and appreciate your help!

    Tagged:

  • I don't rly get it. But what you mean is: if space is less then max space -> add item, only if weight is also less then max weight.

    Add item instance vars(weight 10, space 3)

    If item weight+current weight <= max weight AND current space + item space <= max weight

    Pickup item to bag, else don't

    reedit: current space + item space <= max weight /// should be less or equal to max Space

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I don't rly get it. But what you mean is: if space is less then max space -> add item, only if weight is also less then max weight.

    Add item instance vars(weight 10, space 3)

    If item weight+current weight <= max weight AND current space + item space <= max weight

    Pickup item to bag, else don't

    Sometimes you just need another set of eyes to make things clear. Your reply helped a lot and pointed me in the right direction. Testing now and will update shortly.

    Thanks again!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)