MV SDJB_InventoryWeight

PluginName: SDJB_InventoryWeight
Author: ShadowDragon

Spoiler: How it works
Code:
Introduction
 ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞
 Adds a weight system to your inventory with the following features:
 → Weight capped.
 → Overweight ability with speed reduction.
 → Weight upgrade by script call.
 → Add Weight Bonus, adding weight to the base weight based on equipped equipment.
 → Ignore Weight, to ignore all weight calculations.
 → Ability to discard and use items.
 → Weight information display.

 All notetags are converted to lowercase for safety.

 Display Discard Window → Enables Discard without Weight.


 Features in Depth
 ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞
 Weight Capped:
    By default, weight is capped but can be toggled via script call:
    $gameSystem.setOverweight(true)  => enable overweight mode
    $gameSystem.setOverweight(false) => disable overweight mode

    When disabled (capped mode), new items are only added if enough
    capacity remains. If not enough space is available, only a partial
    amount is added (based on available weight), and the rest is skipped.

    Items are processed in the order they are gained, so if capacity runs out,
    later items in the same event may not be received. A warning message
    is shown in the console when this happens.


 Overweight:
    When overweight is enabled, player movement speed is dynamically reduced.
    If overweight reaches 0.5 (50%) above the base, Dash is disabled.
    If overweight reaches 1.5 (150%), the player cannot move.

    Overweight mode also automatically enables the discard window,
    which can be used directly and updates when using or discarding items.


 Weight Upgrade:
    You can upgrade the base weight via script call:
    $gameSystem.modInvWeight(5)   => add 5 to the base weight
    $gameSystem.modInvWeight(-5)  => subtract 5 from the base weight
   
    Note: the modified value can go below 0 relative to the base.


 Weight:
    Adding weight to items supports decimals (up to 2 places).
    <Weight: 0.05>  => adds 0.05 weight.
    If the value has 3 decimals (e.g., 1.322), it truncates to 1.32 (no rounding).

    A default weight can be set for all items in the parameters.


 Weight Bonus:
    Weight bonuses can be given to equipment using the tag:
    <Weight Bonus: value>  => changes inventory weight when equipped

    Example:
    <Weight Bonus: 5>   => adds +5 to base weight
    <Weight Bonus: -5>  => subtracts -5 from base weight
 

 Ignore Weight:
    You can create an item that grants a state to ignore all weight.
    Best used for a limited number of steps, allowing players to move
    or sell items without having to discard them immediately.


 Discard Items:
    You can discard items if the parameter is set to true, or if
    overweight mode is active. In either case, the discard option
    becomes available in the item menu.

    This window lets you confirm item use or choose how many to discard,
    depending on the selected command.

    The discard amount can be adjusted with the arrow keys:
    Arrow UP    = +1
    Arrow DOWN  = -1
    Arrow LEFT  = -10
    Arrow RIGHT = +10
    Press Enter or Z to confirm, X or ESC to cancel.

    Items with the tag <No Discard> cannot be discarded.

    Discard can also be used without the weight system if
    “Display Discard Window” is enabled.


 Weight Details:
    Weight details can be shown by holding the SHIFT key.
    This displays the following information:

    Base:  set in parameters
    Mod:   changed via script calls
    Bonus: added or removed from equipped gear
    Total: total carrying capacity
    Used:  current total weight used

    Useful for debugging or balancing purposes.

=== TERMS OF USE ===
Free for Non-Commercial and Commercial use when credit is given.
credit one of the following:
ShadowDragon
ShadowDragonJB


=== WARNING ===
YOU ARE NOT ALLOWED TO:
* MODIFY without permission
* EXTEND without permission
* TAKE CODE without permission
* CLAIM AS YOU MADE IT
* REDISTRIBUTE but link back to the forum or itch.io
* SELL this product as standalone.
* DO NOT REMOVE THE HEADER.

Download on itch.io (as it require my SDJB_Base (main or mini))
I have a small problem. I’m having a compatibility issue with SDJB_InventoryWeight.js. It throws an error on the ?. parts. I don’t know how to program, so I’m just trying to figure it out by reading about it. (I downloaded it for free for a personal project and learning purposes.) "Uncaught SyntaxError: Unexpected token ." RpgmakerMV (sorry for my English)
I have a small problem. I’m having a compatibility issue with SDJB_InventoryWeight.js. It throws an error on the ?. parts. I don’t know how to program, so I’m just trying to figure it out by reading about it. (I downloaded it for free for a personal project and learning purposes.) "Uncaught SyntaxError: Unexpected token ." RpgmakerMV (sorry for my English)
I think I know what is happening, but in order to help you.
do you use my base as well which is on top?

can you provide your NWJS and PIXI version that shows up in your console log.

nwjs > 0.48.4 or better (recommended)
PIXI > 4.8.9 or better (for MV its best to stay below version 5.x.x,

I don't know how far pixi can work with the plugins I made, but if version
is 0.29.x, try to update it to the version I provided or better (depending if you
going to use steam (0.49.2 or a different version that works with it).

here is a [video tutorial] that explain the steps.

I build my plugin based on nwjs 0.48.4 and pixi 4.8.9, so anything above works.
if your crash still persist, show a screenshot of your console log and I help you
further or fix the bug if I can replicate it.
Thank you, it took me a bit of time to understand the problem, but for now it seems to be working perfectly. I have one more question: I read the "* MODIFY without permission" part. If it’s allowed, I would only make a small change instead of slowing the player down, I’d like it to immediately make the player unable to move when the weight limit is exceeded. Am I allowed to do that?
I’d like it to immediately make the player unable to move when the weight limit is exceeded. Am I allowed to do that?
you can modify if you have the knowledge, but while its a nice idea, I can also create
a parameter with this option, to disable it, dynamic speed reduction or stop if overweight.

I will add this feature as I don't know how far players need it for their game, but you
can change it so you don't have to update it once ready (within the upcoming week).

so go ahead, or if you want to wait, I will push an update out.

it's on my TODO list, so change if its the only one, but I would update once implemented
as well, so there is some new param added too, to gain more control.

if you have troubles, let me know.

Good luck with your project.

Original thread: https://forums.rpgmakerweb.com/threads/sdjb_inventoryweight.181011/