EOS question. Using the SAY action with Objects

All about the past, current and future webteases and the art of webteasing in general.
---
Post Reply
Lamei
Explorer
Explorer
Posts: 99
Joined: Wed Jan 30, 2019 8:23 pm

EOS question. Using the SAY action with Objects

Post by Lamei »

I'm having trouble getting the SAY action to display whole or part of an object. I understand how to use the SAY action with arrays, but no matter what I try, I can't get it to work with objects. For example:

const testA = [ {Name : Player 0, Score : 12, Rank : 1},
{Name : Player 1, Score : 8, Rank : 3},
{Name : Player 2, Score : 9, Rank : 2},
]

My question is how would I use the SAY command to display Player 0s Rank? Can the whole object 'testA' be shown at once?
grelgen
Explorer
Explorer
Posts: 98
Joined: Sat Dec 18, 2021 12:50 am

Re: EOS question. Using the SAY action with Objects

Post by grelgen »

the first thing I see, surround your name data with quotes:
const testA = [
{Name : "Player 0", Score : 12, Rank : 1},
{Name : "Player 1", Score : 8, Rank : 3},
{Name : "Player 2", Score : 9, Rank : 2},
];

test after that, it all might start working

at any time, you can
console.log(testA);
to see the contents
Lamei
Explorer
Explorer
Posts: 99
Joined: Wed Jan 30, 2019 8:23 pm

Re: EOS question. Using the SAY action with Objects

Post by Lamei »

Thanks Grelgen. My mistake, I forgot the quotation marks around the names haha. I fixed that but unfortunatly I can't get it working. I'm probably trying to use the SAY action wrong. If I was using an array I would simply use the SAY action like this:

var Players = ["player1","player2","player3]

(using SAY action eval tag) Players[0] will say player1


But when i'm using the SAY action for an object like this it's not working:

const Player = {name : "Player1", score : 5, rank : 3}

(using SAY action eval tag) Player.rank will not work when I expect it to say 3


Anyway thanks for your time.
Thamrill
Explorer At Heart
Explorer At Heart
Posts: 301
Joined: Thu Jan 03, 2013 4:55 pm
Gender: Male
Sexual Orientation: Straight
I am a: Submissive

Re: EOS question. Using the SAY action with Objects

Post by Thamrill »

I was sure I had answered this question, anyhow, try defining the array as a var rather than a const. That way should work (worked for me).
Also, I tried to pass the array of objects to the say action and it doesn't work, it prints [Object object, Object object, Object object]
Image

Image

Image
Lamei
Explorer
Explorer
Posts: 99
Joined: Wed Jan 30, 2019 8:23 pm

Re: EOS question. Using the SAY action with Objects

Post by Lamei »

Thamrill wrote: Wed Mar 02, 2022 11:12 am I was sure I had answered this question, anyhow, try defining the array as a var rather than a const. That way should work (worked for me).
Also, I tried to pass the array of objects to the say action and it doesn't work, it prints [Object object, Object object, Object object]
Thanks very much Thamrill, it works! I wish I had asked sooner as I admit I spent a couple of hours trying everything and wondering why I couldn't get it to work. Thank you
Post Reply