RMMV drawText from Array outputs as [object Object]

jacobiwan

Warper
Member
Joined
Nov 19, 2020
Messages
3
Reaction score
0
First Language
Jacob
Primarily Uses
RMMV
I am attempting to pull the name of a characters equipped item from an array and outputting it to a menu via drawText:

if ($gameActors.actor(index + 1).equips()[6] == null) {
var rune = "No Rune";
} else {
var rune = $gameActors.actor(index + 1).equips()[6];
};

this.drawText(rune, x, bottom - lineHeight * 2, width);

When no item is equipped in that slot, it outputs "No Rune" as expected, but when an item is equipped to that slot, it doesn't output the name or even the ID of the item, it outputs "[object Object]"
 

Attachments

TSR

The Northern Frog
Veteran
Joined
Nov 14, 2019
Messages
279
Reaction score
244
First Language
French
Primarily Uses
RMMV
Hello, it return the whole item object in the actor equip slot 6.
Try $gameActors.actor(index + 1).equips()[6].name
 

jacobiwan

Warper
Member
Joined
Nov 19, 2020
Messages
3
Reaction score
0
First Language
Jacob
Primarily Uses
RMMV
Hello, it return the whole item object in the actor equip slot 6.
Try $gameActors.actor(index + 1).equips()[6].name
Thank you! It worked, I figured it was because the object had multiple properties. How would I go about finding out the properties an object in the future? Thank you again, and sorry if I'm supposed to open a new thread for expanding questions. I'm new to this forum.
 

TSR

The Northern Frog
Veteran
Joined
Nov 14, 2019
Messages
279
Reaction score
244
First Language
French
Primarily Uses
RMMV
Hello again!
You can turn the object into a string using: JSON.stringify(object)
or you can use the method Object.keys(object) which returns an array containing all the properties name.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

People3_5 and People3_8 added!

so hopefully tomorrow i get to go home from the hospital i've been here for 5 days already and it's driving me mad. I miss my family like crazy but at least I get to use my own toiletries and my own clothes. My mom is coming to visit soon i can't wait to see her cause i miss her the most. :kaojoy:
Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.

Forum statistics

Threads
105,868
Messages
1,017,085
Members
137,584
Latest member
Faustus2501
Top