Jump to content

Getting the price value of an item and storing it in a variable! (Got it!)

Recommended Posts




I don't know how to do this. It seems simple, but I've looked and my level of skill with RGSS is not that great so a lot of the code is incomprehensible to me.


But really, all I need is to know how to get the price value of an item, and store that in a variable.


Like, the price of a Potion, by default, is 50. But, what if that gets changed? It would be far less of a PITA to have it stored in a variable by an automated check, versus changing the values manually. I looked in the common script calls, and squat-zo. I've asked in two different servers, now I inquire here.



So, I figured this out, with some contextual aid, but for those of you looking to simplify messages, or however this may be useful to you, here's how to store the price of any item in a variable.


Event Command Set Variable



Replace 00 with the item ID (like Potion is ID 1 by default), and when the variable is set, it will be set with the price as defined in the DB (by default a potion's price is 50).

You can also do this with $data_armors and $data_weapons to get the prices of those.


One example of this being useful is in messages.


"A Potion costs \v[1]\G."

This way, if the DB changes, you don't have to alter potentially hundreds of messages to match the DB change.


Yup, that's really all there is to it.

Edited by PhoenixSoul
Got the solution figured out

Share this post

Link to post
Share on other sites

This is pretty nifty actually, I could see it working well with creating an auctioneer system, or a shop where the buy-able items are displayed on shelves, as opposed to a menu.

Share this post

Link to post
Share on other sites

@Vis_Mage Or, in the case of what brought on the search for an answer, a Merchant class that actually buys items from one vendor and resells them to another (or as a Fence that steals items from one place/person/etcetera and sells them to another vendor).

Share this post

Link to post
Share on other sites

Pinning tips/tuts here would make it harder for users, who look for help on their own things.


I think a subsection for these tips would perform better, so I created one and moved your thread there. If anybody thinks it's a bad idea and/or has better ones, please notify me, thanks.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

Top ArrowTop Arrow Highlighted