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 Profile Posts

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.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,868
Messages
1,017,066
Members
137,576
Latest member
SadaSoda
Top