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