Cyberball 5 Keyboard Control Issue - Urgent Help Needed


Author
Message
periperiperika555
periperiperika555
Associate Member (54 reputation)Associate Member (54 reputation)Associate Member (54 reputation)Associate Member (54 reputation)Associate Member (54 reputation)Associate Member (54 reputation)Associate Member (54 reputation)Associate Member (54 reputation)Associate Member (54 reputation)
Group: Forum Members
Posts: 5, Visits: 11
Hello,

I hope this message finds you well. We are currently working on a research project at our university involving "Cyberball 5," and we are looking to create three Cyberball tasks for this study.

To use fMRI in our research, we need to transition from mouse-click-based controls to keyboard controls entirely. However, we have encountered an issue when setting "validresponse=("4","9")" and "inputdevice=keyboard" in the "trial" section. It seems that when Player 2 throws the ball, it goes in the opposite direction and does not function correctly. (We want to configure it so that pressing the 4 key throws to Player 1, and pressing the 9 key throws to Player 3.)

By the way, when we set the key for throwing to Player 3 as "validresponse=("E","I")," the ball is thrown correctly only to Player 3, and it works as expected. Any key other than "I" does not work correctly.

Currently, the program looks like this:

<trial npctrial>
/ ontrialbegin = [
    values.received_from = values.ball_at;
    values.ball_at = values.throw_to;
    if (values.ball_at == 2) {
        values.player2received += 1;
    };
    expressions.set_offsets;
    
    values.player1state = (values.ball_at == 1) + 1;
    values.player2state = (values.ball_at == 2) + 1;
    values.player3state = (values.ball_at == 3) + 1;
    values.player4state = (values.ball_at == 4) + 1;
    values.player5state = (values.ball_at == 5) + 1;
    values.player6state = (values.ball_at == 6) + 1;
    values.player7state = (values.ball_at == 7) + 1;
    values.player8state = (values.ball_at == 8) + 1;
    values.player9state = (values.ball_at == 9) + 1;
    
    values.throw_to = list.throwschedule.nextvalue;
    values.delay = list.delayschedule.nextvalue;
    if (values.throw_to == 0){
    values.throw_to = list.npcs.nextindex;
    values.delay = round(rand(1, 4)) * 1000;
    };
    while (values.throw_to == values.ball_at){
        values.deprecated +=1;
        values.throw_to = list.throwschedule.nextvalue;
        values.delay = list.delayschedule.nextvalue;
    };
]

/ ontrialend = [
    values.realizedThrowSchedule = concat(values.realizedThrowSchedule, values.throw_to);
    values.throwcount += 1;
    if (values.ball_at == 2) {
        values.player2thrown += 1;
    };
]

/ stimulusframes = [1=clearscreen, player1, player2, player3, player4, player5, player6, player7, player8, player9,
    player1label, player2label, player3label, player4label, player5label, player6label, player7label, player8label, player9label,
    player1avatar, player2avatar, player3avatar, player4avatar, player5avatar, player6avatar, player7avatar, player8avatar, player9avatar,
    stats]

/ inputdevice = keyboard
/ showmousecursor = false
/ validresponse = (0)
/ trialduration = values.delay
/ branch = [
    return trial.throw;
]
</trial>

// handles the human player
<trial player2>
/ ontrialbegin = [
    values.received_from = values.ball_at;
    expressions.set_offsets;
    
    values.player2received += 1;
    
    values.player1state = 1;
    //catch
    values.player2state = 2;
    values.player3state = 1;
    values.player4state = 1;
    values.player5state = 1;
    values.player6state = 1;
    values.player7state = 1;
    values.player8state = 1;
    values.player9state = 1;
    
    values.ball_at = 2;
    values.throw_to = list.throwschedule.nextvalue;
    values.delay = list.delayschedule.nextvalue;
    
]

/ ontrialend = [
    values.throw_to = substring(trial.player2.response, length(trial.player2.response)-1, 1);
    values.realizedThrowSchedule = concat(values.realizedThrowSchedule, values.throw_to);
    values.player2thrown += 1;
    values.throwcount += 1;
]

/ stimulusframes = [1=clearscreen, player1, player2, player3, player4, player5, player6, player7, player8, player9,
    player1label, player2label, player3label, player4label, player5label, player6label, player7label, player8label, player9label,
    player1avatar, player2avatar, player3avatar, player4avatar, player5avatar, player6avatar, player7avatar, player8avatar, player9avatar,
    stats]

/ validresponse = ("4", "9", player4, player5, player6, player7, player8, player9)
/ responsemessage = ("4", player1click, 100)
/ responsemessage = ("9", player3click, 100)
/ responsemessage = (player4, player4click, 100)
/ responsemessage = (player5, player5click, 100)
/ responsemessage = (player6, player6click, 100)
/ responsemessage = (player7, player7click, 100)
/ responsemessage = (player8, player8click, 100)
/ responsemessage = (player9, player9click, 100)
/ inputdevice = keyboard
/ branch = [
 if (trial.player2.response == 5) 
values.throw_to == 1
 return trial.throw;
]
/ branch = [
  if (trial.player2.response == 10) /
    values.throw_to == 3
    return trial.throw;
]
</trial>

// implements the throw animation
<trial throw>
/ ontrialbegin = [
    picture.player1.skip = expressions.skip_player1pic;
    picture.player2.skip = expressions.skip_player2pic;
    picture.player3.skip = expressions.skip_player3pic;
    picture.player4.skip = expressions.skip_player4pic;
    picture.player5.skip = expressions.skip_player5pic;
    picture.player6.skip = expressions.skip_player6pic;
    picture.player7.skip = expressions.skip_player7pic;
    picture.player8.skip = expressions.skip_player8pic;
    picture.player9.skip = expressions.skip_player9pic;
    
    values.throwingplayer_x = list.player_x.item(values.ball_at);
    values.throwingplayer_y = list.player_y.item(values.ball_at);
    values.receivingplayer_x = list.player_x.item(values.throw_to);
    values.receivingplayer_y = list.player_y.item(values.throw_to);
    values.ball_x = values.receivingplayer_x;
    expressions.set_throwoffset;
]

/ ontrialend = [
    if (values.throwcount >= parameters.nthrows){
        values.stop = true;
    } else {
        values.stop = false;
    };
    picture.player1.skip = false;
    picture.player2.skip = false;
    picture.player3.skip = false;
    picture.player4.skip = false;
    picture.player5.skip = false;
    picture.player6.skip = false;
    picture.player7.skip = false;
    picture.player8.skip = false;
    picture.player9.skip = false;
]

/ stimulustimes = [0=clearscreen, player1, player2, player3, player4, player5, player6, player7, player8, player9,
    player1label, player2label, player3label, player4label, player5label, player6label, player7label, player8label, player9label,
    player1avatar, player2avatar, player3avatar, player4avatar, player5avatar, player6avatar, player7avatar, player8avatar, player9avatar,
    playerthrow0, stats;
    
    500=clearscreen, player1, player2, player3, player4, player5, player6, player7, player8, player9,
    player1label, player2label, player3label, player4label, player5label, player6label, player7label, player8label, player9label,
    player1avatar, player2avatar, player3avatar, player4avatar, player5avatar, player6avatar, player7avatar, player8avatar, player9avatar,
    playerthrow1, stats;
    
    600=clearscreen, player1, player2, player3, player4, player5, player6, player7, player8, player9,
    player1label, player2label, player3label, player4label, player5label, player6label, player7label, player8label, player9label,
    player1avatar, player2avatar, player3avatar, player4avatar, player5avatar, player6avatar, player7avatar, player8avatar, player9avatar,
    playerthrow2, stats;
    
    700=clearscreen, player1, player2, player3, player4, player5, player6, player7, player8, player9,
    player1label, player2label, player3label, player4label, player5label, player6label, player7label, player8label, player9label,
    player1avatar, player2avatar, player3avatar, player4avatar, player5avatar, player6avatar, player7avatar, player8avatar, player9avatar,
    playerthrow3, stats;
    
    800=clearscreen, player1, player2, player3, player4, player5, player6, player7, player8, player9,
    player1label, player2label, player3label, player4label, player5label, player6label, player7label, player8label, player9label,
    player1avatar, player2avatar, player3avatar, player4avatar, player5avatar, player6avatar, player7avatar, player8avatar, player9avatar,
    playerthrow4, stats;
    
    900=ball_to]
    
/ inputdevice = keyboard
/ showmousecursor = false
/ validresponse = (0)
/ trialduration = 900 + expressions.throwduration
/ branch = [
    if (values.throw_to == 2 && !parameters.spectate){
        return trial.player2;
    } else {
        return trial.npctrial;
    }
]
/ recorddata = false
</trial>

// displays the welcome message / instructions / game cover story
<trial instructions>
/ stimulusframes = [1=clearscreen, banner, logo, instructions, play]
/ validresponse = (lbuttondblclk)
/ recorddata = false
/ inputdevice = mousekey
</trial>

<trial instructions2>
/ stimulusframes = [1=getReady]
/ trialduration = parameters.readyDuration
/ beginresponsetime = parameters.readyDuration
/ recorddata = false
</trial>

// displays the "Connecting to other players..." message and animation
<trial start>
/ ontrialbegin = [
    list.npcs.reset();
    values.throw_to = list.throwschedule.nextvalue;
    values.delay = list.delayschedule.nextvalue;
    values.realizedThrowSchedule = concat(values.realizedThrowSchedule, values.throw_to);
    values.ball_x = list.player_x.item(values.throw_to);
]
/ stimulusframes = [1=clearscreen, connectingmessage, connectinganimation]
/ inputdevice = keyboard
/ validresponse = (0)
/ trialduration = replace(5000,6000,7000)
/ branch = [
    if (values.throw_to == 2 && !parameters.spectate){
        return trial.player2;
    } else {
        return trial.npctrial;
    }
]
/ recorddata = false
</trial>

// end screen with exit button
<trial thankyou>
/ stimulusframes = [1=clearscreen, thankyoumessage, exit]
/ validresponse = (lbuttondblclk)
/ recorddata = false
/ inputdevice = mousekey
</trial>


We are running out of time and are in quite a predicament. Any help you can provide would be greatly appreciated. Thank you in advance.
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Reading This Topic

Explore
Messages
Mentions
Search