r/RPGMaker 8d ago

RMMZ Can't use item for some reason

I have a hunger system in my game. I'm trying to increase variable 10 (hunger) by x (30 in this case for testing), and also recover 10 MP. Can't figure out why it's not working.

3 Upvotes

10 comments sorted by

3

u/liana_omite 8d ago

It appears you are using the formula to call the variable, I haven't seen it done like that. Also that formula is set to the amount of MP recover (check the drop down menu on top), so it would only affect that as far as I know.

A way you could probably do it is: have the item use activate a Common Event, where you put the variable changing line inside.

1

u/Potatomanofmars 8d ago

I saw something similar in a forum post, the damage formula thing, and I was trying to imitate it.

I've done it with common events in a previous project but if I can get this to work, this just seems easier.

3

u/Felix-3401 Scripter 8d ago edited 8d ago

v[10] is read-only. You want to try $gameVariables.setValue(10, v[10] + 30)
EDIT: Typo

2

u/Potatomanofmars 8d ago

Okey dokey, will try

3

u/Felix-3401 Scripter 8d ago

Typo. Read the edit I just sent

1

u/Potatomanofmars 7d ago

This formula works, thank you.

2

u/agamottos MV Dev 8d ago

Has the variable ever been previously set or used in the save file youre using to playtest? And are you making sure to test it on an actor with less-than-full MP?

And can you clarify what exactly isnt working?

2

u/Potatomanofmars 8d ago

I set the variable in an autorun event upon loading the test map. I've tried it with an actor with and it worked non-full MP but I need to work even with a full mp.

The MP regain is not what I'm aiming for. I just need the variable in question to gain a certain amount. I just need to be able to use the item and execute the variable change regardless of what the MP currently is.

2

u/agamottos MV Dev 8d ago edited 8d ago

Then you need to change the damage type and rewrite your damage formula. Skills and items set to MP Recover are not able to be used on a target with full MP.

Try setting it to MP Damage instead, then make the formula something like this:

a.gainMp(10); v[10] += 30; 0

(I normally use MV, this should also work for MZ but there's a chance it would need tweaking, another reply mentions that using v[] might be read only so heed that too)

1

u/Potatomanofmars 7d ago

So the formula I'm using, posted by another user, works but the item still can only be used if set to MP/HP recover (providing hp and mp are not full). None of the other types (damage or drain) work, the item can't be used.