Millisecond Forums

Cyberball Chat box Code

https://forums.millisecond.com/Topic16196.aspx

By briancjo - 5/1/2015

Hi Supreme Being Dave,

Any help to code the chat box with programmable chat messages and responses as in the original.

Brian, cyberball noob
By Dave - 5/1/2015

If you want the human player to be able to enter messages, you'd have to set up and run an <openended> trial element at the desired point in time. For the messages by the "virtual" / computer players, use and display a standard <text> element in the existing cyberball <trial> elements.
By Dave - 5/1/2015

I should add that it *may* be possible to implement something that's similar to the "chat" option [1] in the web-based Cyberball in Inquisit, but it *won't* be identical. The prime reason is that Inquisit trials are restricted to a single input modality (e.g. keyboard input OR mouse input, never both at the same time). I.e. it is not possible to have a trial allow for (a) typing some chat message AND (b) clicking on one of the players to pass the ball. Those would have to be handled by separate elements (e.g. an <openended> and a regular <trial> with mouse input).

[1] As far as I understand, the feature is optional and was only added to the most recent iteration of the Cyberball paradigm.
By briancjo - 5/1/2015

so does creating an <openended> trial element also create the chat box. I'm confused as to what the code you suggested would actually look like when the script is running? will there be a box, does it just existed on the bottom on the screen?
By Dave - 5/1/2015

An <openended> element provides a box for text input (i.e. you type into it). Your "chat box", the where the messages of the various players are displayed, would be a standard <text> element.
By Dave - 5/1/2015

Here's a very simple example to illustrate the <openended> / "chat box" part:

<block myblock>
/ trials = [1-4=chat]
</block>

<openended chat>
/ ontrialbegin = [values.chatmessages=concat(values.chatmessages, list.computermessages.nextvalue)]
/ ontrialend = [values.chatmessages=concat(concat(values.chatmessages, openended.chat.response),"~r")]
/ stimulusframes = [1=chatbox]
/ buttonlabel = "Send"
/ position = (50%, 90%)
</openended>

<text chatbox>
/ items = ("<%values.chatmessages%>")
/ position = (50%, 30%)
/ size = (30%, 40%)
/ txbgcolor = black
/ txcolor = white
/ hjustify = left
/ vjustify = top
/ erase = false
</text>

<list computermessages>
/ items = ("> Computer: Hi!~n", "> Computer: How are you?~n", "> Computer: What's your favorite food?~n", "> Computer: Nice!~n")
/ selectionmode = sequence
</list>


<values>
/ chatmessages = ""
</values>