Combining Color with if-command


Author
Message
RicardaVictoria
RicardaVictoria
Respected Member (393 reputation)Respected Member (393 reputation)Respected Member (393 reputation)Respected Member (393 reputation)Respected Member (393 reputation)Respected Member (393 reputation)Respected Member (393 reputation)Respected Member (393 reputation)Respected Member (393 reputation)
Group: Forum Members
Posts: 2, Visits: 11
Hello,

in my Study participants choose an avatar and are consequently assigned to a certain group. There are four differently colored avatars from which they can chose.
Afterwards participants play a virtual ball tossing game. 

I want to pigment the name of the players in the ball tossing game in the same color as the avatar, which participants have chosen before. These colors are different for the participants as I have several different conditions. 

I think I have to combine the color with the if-command from the avatars which looks like this: [if (trial.selectavatarEG.response=="target1") values.youravatar=1]

However I can't find a way to combine the color in one block with an if statement from another block.
Do you have any suggestions?

I would really look forward to get some advice from you!
Best regards
Ricarda Victoria






Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 13K, Visits: 104K
You simply need to set the player name <text> element's textcolor property to the desired value in the in the same if-statement you already have. It does not matter whether those things are used in different blocks or not.

<values>
/ youravatar = 1
</values>

<block someblock>
/ trials = [1=selectavatar; 2=sometrial]
</block>

<trial selectavatar>
/ ontrialend = [if (trial.selectavatar.response == "target1") {values.youravatar = 1; text.name.textcolor = red}
    else if (trial.selectavatar.response == "target2") {values.youravatar = 2; text.name.textcolor = blue}; ]
/ stimulusframes = [1=target1, target2]
/ validresponse = (target1, target2)
/ inputdevice = mouse
</trial>

<text target1>
/ items = ("Red Avatar")
/ position = (40%, 50%)
</text>

<text target2>
/ items = ("Blue Avatar")
/ position = (60%, 50%)
</text>

<trial sometrial>
/ stimulusframes = [1=avatar, name]
/ validresponse = (57)
</trial>

<text avatar>
/ items = avataritems
/ select = values.youravatar
</text>

<item avataritems>
/ 1 = "Red Avatar"
/ 2 = "Blue Avatar"
</item>

<text name>
/ items = ("The player's name")
/ position = (50%, 60%)
</text>

If the colors you need do not have well-defined names (red, green, blue, yellow, etc.), you can set the respective RGB values direclty via the textcolorred, textcolorgreen & textcolorblue properties:

<values>
/ youravatar = 1
</values>

<block someblock>
/ trials = [1=selectavatar; 2=sometrial]
</block>

<trial selectavatar>
/ ontrialend = [if (trial.selectavatar.response == "target1") {values.youravatar = 1; text.name.textcolorred = 200; text.name.textcolorgreen = 50; text.name.textcolorblue = 120;}
    else if (trial.selectavatar.response == "target2") {values.youravatar = 2; text.name.textcolor = blue}; ]
/ stimulusframes = [1=target1, target2]
/ validresponse = (target1, target2)
/ inputdevice = mouse
</trial>

<text target1>
/ items = ("Purple-ish Avatar")
/ position = (40%, 50%)
</text>

<text target2>
/ items = ("Blue Avatar")
/ position = (60%, 50%)
</text>

<trial sometrial>
/ stimulusframes = [1=avatar, name]
/ validresponse = (57)
</trial>

<text avatar>
/ items = avataritems
/ select = values.youravatar
</text>

<item avataritems>
/ 1 = "Purple-ish Avatar"
/ 2 = "Blue Avatar"
</item>

<text name>
/ items = ("The player's name")
/ position = (50%, 60%)
</text>




GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Reading This Topic

Explore
Messages
Mentions
Search