Xina

Regular
Regular
Joined
Feb 23, 2019
Messages
38
Reaction score
7
First Language
English
Primarily Uses
RMMV
I've been using variables and switches to have a weight functionality in my game. It's been working well up until I decided I wanted an evented way for the player to discard an item. Then I run into the problem of how to retrieve the item weight. After searching the internet for plugins and not finding anything that quite matched my needs, I decided to use an item's "price" as the item's weight. Since there will be no shops in the game, this should work except that I can't quite get the code to retrieve the price to work!

The event has the player select an item, which is assigned to variable 8 (Item ID).
The Control Variables function sets variable 28 (Item Price) equal to the script:
$dataItems[$gameVariables.value(8)].Price;

I've tried several variations of this code but nothing returns the correct price. What am I doing wrong?
 

ATT_Turan

Forewarner of the Black Wind
Regular
Joined
Jul 2, 2014
Messages
12,750
Reaction score
11,354
First Language
English
Primarily Uses
RMMV
There's no property Price with a capital "P", it's just "price". If you replace that letter, the assignment should work correctly.
 

Xina

Regular
Regular
Joined
Feb 23, 2019
Messages
38
Reaction score
7
First Language
English
Primarily Uses
RMMV
There's no property Price with a capital "P", it's just "price". If you replace that letter, the assignment should work correctly.
Oh my gosh!! *slaps head* THANK YOU!!! I knew it had to be something tiny and dumb that I was missing. Thank you so much. That was driving me nuts.
 

Poryg

Dark Lord of the Castle of Javascreeps
Regular
Joined
Mar 23, 2017
Messages
4,235
Reaction score
11,378
First Language
Czech
Primarily Uses
RMMV
Pro tip. Next time you can open the dev console with f9 and type $dataItems there. This will display the exact member variable names of an object.
 

Latest Threads

Latest Posts

Latest Profile Posts

So frustrating when you just wanna work on your game but people want to do stuff in RL... :p
Day #9 of Advent is all ready in one spot! Do you prefer doing your shopping way before Xmas, or…do you like the chaos? Are you done shopping and/or crafting for Xmas?
Fast test with Wagon and horse no animation. yes it looks strange horse is Ralph and wagon is follower xDDDD
Should first boss be easy or maybe little medium, I don't want to be overwhelmingly hard
Proper localization into several languages on a commercial rpg project might be one of the best signs that the developer is super invested into making the game something high effort, because it ain't cheap to hire good translators.

Forum statistics

Threads
136,883
Messages
1,271,029
Members
180,660
Latest member
Raveni
Top