Variables not working for mini-game

Hello again!

I've made a small casino mini game in one of my towns. By playing the games, the player can win Yellow Casino Chips. These can be upgraded to Green, then Blue, then Red when the player holds 99 (current item MAX) of the lower tier Chip. The chips can be cashed in for a number of prizes from their respective tiers.

I was moving right along, getting the first game to play flawlessly, when I discovered the maximum of 99 items despite throwing money at the game NPC. In order to prevent players from losing money from winning with no reward, I tried to implement a counter of sorts where the game keeps track of the number of Chips you hold with a variable. Basically the relevent Event code looks like this

You Win!

Change Items: Yellow Casino Chip +10

Control Variables: [0003: Yellow Casino Chip] +=10

You Lose 🙁

Nothing happens, Event ends.

At the very top of the event, I have it check the [0003 Yellow Casino Chip] variable to see if it's 99, and if so, prevent the player from playing the mini-game. The NPC seems to ignore this check. To debug, I made a Treasure Chest give 99 Yellow Chips, Add 99 (+=99, same as the Game NPC) to the variable and a Debug NPC to tell me how many I had. That seems to work. The Game NPC then correctly prevents the player from playing the casino game.

The problem seems to come from the counter not building from the Casino NPC. Might it possible that the game only displays 99, but the counter itself exceeds 99 and that maybe why the game isn't catching it... BRB testing...

Final Edit: Yep, that's exactly what was happening. The Variables can exceed the Max Carry Item limit, so when my NPC was rewarding 10 each, the counter skipped right over the 99 check. Once I told it to check >= (greater than or equal to) instead of simply == (exactly equal to), the NPC started blocking the player from playing.

Mods, I read the part where you don't was us 'mini-modding', so uh, consider this help topic closed as I seemed to have solved it myself.

Thanks for your help! 😀
Next time you have a question like this, it'll really help if you can take a screenshot of your event and add to your post. It not only saves you having to write an essay on what's happening or not happening, but as they say, a picture tells a thousand words, and a screenshot of the whole event page (not just the event commands, but the entire window) will usually let someone give you your solution VERY quickly, without a lot of questions, answers and trials that don't solve the problem 🙂


(mini modding: you can't actually close or delete your own topic - we have to do that. You need to report the post and add a comment that you'd like it closed. Mini-modding is where you start telling other people what they should and shouldn't be doing - and you wouldn't be doing that in this thread anyway)


This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/variables-not-working-for-mini-game.15841/