Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Help with variables.

I did a search for this bu didn't find anything that seemed relevant. If there is a topic that can answer my question that i missed then please point it out.

Anyway, I think I'm getting a bit better with RPGmaker VX and I'm pretty confident with switches but variables still allude me. I've been trying
to make a shop loyalty system where everytime you shop at a certain shop it will increase your loyalty level for that shop by a certain amount (lets say 1 for the sake of simplicity.) When the loyalty level reaches a certain number, new items become available. I've had a look and I think variables can achieve what I'm aiming for but like I said, I'm not too skilled in that area. Can this be achieved with varables and if so, how?

If any further clarification is needed please ask.
 
Yes, of course it's possible. You'd just need a Conditional Branch that checks how high the variable is and executes a command. Try something like this:

Code:
Conditional Branch: Variable [Shop Loyalty] < 10
  Show Text: Hey, want to buy some potions?
  Shop Processing: Potion
  Control Variables: [Shop Loyalty] += 1
 : Else
  Show Text: Hey, we got some new items in stock!
  Shop Processing: Potion, Mega Potion

In the example, it first checks if your loyalty is less than 10. If so, the player gets to buy the regular items, and afterward it adds 1 to the variable.

So if you talk to the NPC 10 times, your loyalty level will have increased to 10. Since this doesn't meet the Conditional Branch's conditions, you then go to the "Else" branch. Now the shopkeeper says something different and lets you buy other items.

Just experiment, it shouldn't be too difficult to understand. Good luck with it, nashie1 :thumb:
 
And if you wanted to make it so that it required you to Purchase something for loyalty to go up, you'd have to use variables to check your inventory totals before the shop processing, and afterward do another check on each item that the shop sells to see if any of your totals went up.  If this does not make sense I can PM you the specific ways to do this (eventually, I'm really busy lately).
 
I copied your example exactly Regi (except I subbed in my own items and greeting messages, i presume that wouldn't make any difference) yet it immediately offers me all the items as if I had maximum loyalty. What else would case this as I followed your example to the letter besides what I mentioned earlier. Is there some sort of condition I need to set for the event or is something else gumming up the works?

Also, thanks Gabriot, I was about to ask about making it so you need to actually buy something. I'll see if I can rack my brain round that once I get the basics running properly.
 
Well, make sure the variable you're using wasn't previously used in another event (when playtesting, before you talk to the NPC, check if the variable is 0).

If that's not the case, it might be a glitch in VX with the default scripts. You can look at this topic for a fix.

Also, if you want to make it so the variable goes up only if you buy something, it'll be a little more advanced. You can try using a two new variables to check the Gold amount before and after the shop, something like:
Code:
Control Variables: [Gold Before] = Gold
Shop Processing:
Control Variables: [Gold After] = Gold
Conditional Branch: Variable [Gold After] < Variable [Gold Before]
  Control Variables: [Shop Loyalty] += 1

Good luck with it!
 
This is the first shop you encounter in the game and he only one I've made so I haven't used the variable elsewhere. I just remembered that I'm using Kylock's quite frankly awesome time script to make the shop unusable during the night time. Because the shop doubles as the house of a healer who is integral to that part of the story, I can't simply dissallow entry to the shop so there is an extra event page for the shop keeper that uses a switch condition to effectively turn him off. (This is detailed in the sample event shown in the thread for Kylock's script.) I don't suppose that would affect it? (it's probably not what's causing it but like I said, I really don't know alot about variables, conditional branches or scripts so...) Anyway I'm going to make a post in that thread you suggested seeing as it looks like my best chance of getting the loyalty system to work.

Thanks for putting up with my hopelessness.
 
I don't think that healer switch will affect the shop. Just try the variable fix. If that doesn't work, you might want to post some screenshots or upload a demo for us to see.
 
Hmm, I still don't see what could be the problem. Why don't you try a different method? Instead of using a Conditional Branch, have 3 pages. In the first, put all the commands (text, shop, variable increase) that happens before your loyalty is over 10. On the second page, check the Condition "Variable [Loyalty] is 10 or above" and then put commands for after new items are there. The third is still the same, with a Condition switch that makes the shopkeeper disappear at night.

If all else fails, you can upload a demo for someone to see. I don't have VX, so I can't help you there, but someone else might.
 
The problem still remains. I'll get round to uploading a demo tommorow. I don't know if this would be easier/less problematicbut I would settle for some way to randomly alternate when new items are available or reduced in price to emulate sales because this would mean another idea i've had wouldn't contradict the loyalty system.
(Shoplifting; it's difficult to be a favourite customer when you're constantly stealing from the store.)

Anyway, thanks for all your help so far Regi, with any luck I'll get this sorted out, if not, I guess it's back tothe drawing board.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top