Pausing game

128 views
Skip to first unread message

Drew Cranford

unread,
Jul 21, 2023, 2:38:32 PM7/21/23
to nodeGame
Hi Stefano,
At the start of each trial in my game, I need process some info to determine what stimuli to present to the participant. I'm doing this in another lisp process, and using the net package to communicate via tcp. All of this takes time (approximately 3 seconds). I have the communication working (mostly), but I can't figure out how to pause the game before the trial (and timer) starts. What might be a good method to pause the game (or don't start the trial) until I get the response from my lisp server?
Thanks,
Drew

shakty

unread,
Jul 21, 2023, 2:46:47 PM7/21/23
to nodeGame
Hi Drew,

Is pausing really necessary? Could this be handle simply by having some text like "waiting for msg from server..." and then as soon as the msg arrives, updating the screen?

Otherwise you can pause the game with node.game.pause() and node.game.resume() directly on the client, or from the logic you can call:

node.remoteCommand('PAUSE', id);

and

node.remoteCommand('RESUME, id);

where id is a player id or an array of player ids.

Cheers,
Stefano

Drew Cranford

unread,
Jul 21, 2023, 5:09:20 PM7/21/23
to nodeGame
Well, ideally, I don't want the timer to start until the screen is updated with the stimuli, and don't want the player to have the options to click on any options. Currently, when the trial starts, the widget is created to accept responses and the timer starts, then 3 seconds later the screen is updated with the stimuli. I just need to prevent the timer and widget from starting before the stimuli is ready.

I tried node.game.pause() on the client side, but it didn't pause anything. I had put it as the first line in the init function of the stage on the client. Is that not correct?
-Drew

--
You received this message because you are subscribed to a topic in the Google Groups "nodeGame" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/nodegame/sTwePSVBplE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to nodegame+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nodegame/4c532f21-6341-4164-927b-ef0030daa5dfn%40googlegroups.com.

shakty

unread,
Jul 21, 2023, 5:24:07 PM7/21/23
to nodeGame
Hi,

It should go inside the step callback, because the game is not "pausable" inside the init function.

But I would still try another approach.

You could hide the HTML interface inside a div with style="display: none". You would then change the display property when the right stimuli arrives to the client.
To keep the DoneButton disabled you can set the enableOnPlaying: false (see: https://github.com/nodeGame/nodegame/wiki/DoneButton-Widget-v7)
If you have a VisualTimer widget, similarly set startOnPlaying: false (see https://github.com/nodeGame/nodegame/wiki/VisualTimer-Widget-v7)
Finally, to get the exact time for the response, you can define a custom time interval with: 
node.timer.getTimestamp('stimuli_received');
node.game.timeToDecision = node.timer.getTimeSince('stimuli_received');
To send timeToDecision to the server in the done callback:

done: function(values) {
     values.timeToDecision = node.game.timeToDecision;
};



Let me know. Cheers,
Stefano

shakty

unread,
Jul 21, 2023, 5:25:27 PM7/21/23
to nodeGame
Sorry in the timer example it should have been:  node.timer.setTimestamp('stimuli_received'); // instead of getTimestamp

Drew Cranford

unread,
Jul 25, 2023, 1:24:31 PM7/25/23
to nodeGame
Hi Stefano,
I am probably going to use your last suggested approach, but was first experimenting with pausing the game, just to better understand the procedure and consequences, using the following command in the step callback:
node.remoteCommand('pause', ids);

where ids is a list of client ids from:
node.game.pl.id.getAllKeys();

However, I am getting an error:
TypeError: WaitScreen.updateText: text must be string. Found: [object Object]

I cannot figure out why it is not using the default text for pausing a game, or how to assign the text manually.
What am I doing wrong here?
Thanks,
Drew

Stefano B

unread,
Jul 25, 2023, 5:31:42 PM7/25/23
to node...@googlegroups.com
Hi Drew,

That looks like a bug, thanks for spotting that! I will fix it, but in the meantime you could set the msg in logic to avoid that error:

node.remoteCommand('pause',ids, "Please wait while we fetch your data...");

Let me know if it works. Cheers,
Stefano


You received this message because you are subscribed to the Google Groups "nodeGame" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nodegame+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nodegame/58aad264-5d2e-4ae2-923a-d2e2788dcfc6n%40googlegroups.com.

Stefano B

unread,
Jul 25, 2023, 5:52:09 PM7/25/23
to node...@googlegroups.com
The bug is fixed in master and working hard to have nodegame long-awaited v8 without these issues :)
Reply all
Reply to author
Forward
0 new messages