Page 1 of 1

How to retrieve the current core and name launched in a script?

Posted: Mon Sep 18, 2023 2:37 pm
by delarou

I want to tryout some scripting on my MiSTer.
When a game is launched to get the core, name and path and doing a HTTP get for example with these variables.
What is the most robust way to achieve that?
Having a sample script how to do it or some references would be great :)


Re: How to retrieve the current core and name launched in a script?

Posted: Wed Sep 20, 2023 2:15 am
by ItalianGrandma

I think I heard that there may be better ways to retrieve this info now, but this script might be helpful: https://github.com/christopher-roelofs/ ... b/releases


Re: How to retrieve the current core and name launched in a script?

Posted: Wed Sep 20, 2023 5:34 am
by lagerfeldt

I've done that to make my high score website scroll to the game/core currently being played:

https://holgercade.zorkweb.dk/?mode=live

Something like that?


Re: How to retrieve the current core and name launched in a script?

Posted: Wed Sep 20, 2023 1:12 pm
by aberu
delarou wrote: Mon Sep 18, 2023 2:37 pm

I want to tryout some scripting on my MiSTer.
When a game is launched to get the core, name and path and doing a HTTP get for example with these variables.
What is the most robust way to achieve that?
Having a sample script how to do it or some references would be great :)

https://github.com/wizzomafizzo/mrext

Wizzo has a lot of this happening in the Remote script. Check it out.

The core name is in a tmp or temp folder and he references it there in one of the Go files.


Re: How to retrieve the current core and name launched in a script?

Posted: Wed Sep 20, 2023 5:06 pm
by delarou
lagerfeldt wrote: Wed Sep 20, 2023 5:34 am

I've done that to make my high score website scroll to the game/core currently being played:

https://holgercade.zorkweb.dk/?mode=live

Something like that?

Yes, as long you get always the currently game/core being played :)
You have some sample script, guidance, github, ...?


Re: How to retrieve the current core and name launched in a script?

Posted: Wed Sep 20, 2023 5:18 pm
by delarou
ItalianGrandma wrote: Wed Sep 20, 2023 2:15 am

I think I heard that there may be better ways to retrieve this info now, but this script might be helpful: https://github.com/christopher-roelofs/ ... b/releases

Thank you for your response, I will have a look


Re: How to retrieve the current core and name launched in a script?

Posted: Wed Sep 20, 2023 5:20 pm
by delarou
aberu wrote: Wed Sep 20, 2023 1:12 pm
delarou wrote: Mon Sep 18, 2023 2:37 pm

I want to tryout some scripting on my MiSTer.
When a game is launched to get the core, name and path and doing a HTTP get for example with these variables.
What is the most robust way to achieve that?
Having a sample script how to do it or some references would be great :)

https://github.com/wizzomafizzo/mrext

Wizzo has a lot of this happening in the Remote script. Check it out.

The core name is in a tmp or temp folder and he references it there in one of the Go files.

Great, I will have a look at the code.
Thank you


Re: How to retrieve the current core and name launched in a script?

Posted: Fri Sep 22, 2023 4:42 pm
by lagerfeldt
delarou wrote: Wed Sep 20, 2023 5:06 pm
lagerfeldt wrote: Wed Sep 20, 2023 5:34 am

I've done that to make my high score website scroll to the game/core currently being played:

https://holgercade.zorkweb.dk/?mode=live

Something like that?

Yes, as long you get always the currently game/core being played :)
You have some sample script, guidance, github, ...?

Yes, you get the current core/arcade game.

Go to my website and you'll see it in effect (check the URL as well). It updates every 5 seconds, so wait a few seconds.

This is the "live" mode on my website (the green play button). The yellow star button will engage the normal (non-live) mode.

We made this script and named it zorkweb_update.sh, placed it in media/fat/Scripts on the MiSTer:

Code: Select all

#!/bin/bash

while [[ 1 ]]; do
  curl -s -o /dev/null -k -X GET "https://holgercade.zorkweb.dk/currentcore.php?core=`cat /tmp/CORENAME`";
  sleep 5;
done

Then added the following to the existing user-startup.sh in media/fat/Linux on the MiSTer:

Code: Select all

# Zorkweb Holgercade High Score Curl
echo "***" $1 "***"
screen -dmS zorkweb /media/fat/Scripts/zorkweb_update.sh

On the server side we've made the file currentcore.php that does this:

Code: Select all

<?php

// currentcore input script
// debugging

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

// Setup and mode handling

if (isset($_GET['core'])) {
	$currentcore = $_GET['core'];
	print $currentcore;
	file_put_contents('./currentcore.txt', $currentcore);
}

?>

currentcore.txt then contains e.g. "blktiger" curled from the MiSTer.


Re: How to retrieve the current core and name launched in a script?

Posted: Sat Sep 23, 2023 12:28 pm
by delarou
lagerfeldt wrote: Fri Sep 22, 2023 4:42 pm
delarou wrote: Wed Sep 20, 2023 5:06 pm
lagerfeldt wrote: Wed Sep 20, 2023 5:34 am

I've done that to make my high score website scroll to the game/core currently being played:

https://holgercade.zorkweb.dk/?mode=live

Something like that?

Yes, as long you get always the currently game/core being played :)
You have some sample script, guidance, github, ...?

Yes, you get the current core/arcade game.

Go to my website and you'll see it in effect (check the URL as well). It updates every 5 seconds, so wait a few seconds.

This is the "live" mode on my website (the green play button). The yellow star button will engage the normal (non-live) mode.

We made this script and named it zorkweb_update.sh, placed it in media/fat/Scripts on the MiSTer:

Code: Select all

#!/bin/bash

while [[ 1 ]]; do
  curl -s -o /dev/null -k -X GET "https://holgercade.zorkweb.dk/currentcore.php?core=`cat /tmp/CORENAME`";
  sleep 5;
done

Then added the following to the existing user-startup.sh in media/fat/Linux on the MiSTer:

Code: Select all

# Zorkweb Holgercade High Score Curl
echo "***" $1 "***"
screen -dmS zorkweb /media/fat/Scripts/zorkweb_update.sh

On the server side we've made the file currentcore.php that does this:

Code: Select all

<?php

// currentcore input script
// debugging

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

// Setup and mode handling

if (isset($_GET['core'])) {
	$currentcore = $_GET['core'];
	print $currentcore;
	file_put_contents('./currentcore.txt', $currentcore);
}

?>

currentcore.txt then contains e.g. "blktiger" curled from the MiSTer.

Thank you very much :)
I will take a look at it