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

Discussion of developmental aspects of the MiSTer Project.
delarou
Posts: 5
Joined: Tue Jan 31, 2023 6:26 pm

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

Unread post 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 :)

User avatar
ItalianGrandma
Posts: 192
Joined: Sun May 24, 2020 7:09 pm
Has thanked: 40 times
Been thanked: 41 times
Contact:

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

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

User avatar
lagerfeldt
Posts: 158
Joined: Mon Jan 03, 2022 8:32 pm
Location: Denmark
Has thanked: 31 times
Been thanked: 79 times
Contact:

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

Unread post 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?

Patron of MiSTer + theypsilon + Jotego Team + Coin-Op Collection + Pierco + Nullobject

MiSTer RePlay website

Ultimate SID Collection website

User avatar
aberu
Core Developer
Posts: 1162
Joined: Tue Jun 09, 2020 8:34 pm
Location: Longmont, CO
Has thanked: 244 times
Been thanked: 404 times
Contact:

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

Unread post 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.

birdybro~
delarou
Posts: 5
Joined: Tue Jan 31, 2023 6:26 pm

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

Unread post 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, ...?

delarou
Posts: 5
Joined: Tue Jan 31, 2023 6:26 pm

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

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

delarou
Posts: 5
Joined: Tue Jan 31, 2023 6:26 pm

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

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

User avatar
lagerfeldt
Posts: 158
Joined: Mon Jan 03, 2022 8:32 pm
Location: Denmark
Has thanked: 31 times
Been thanked: 79 times
Contact:

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

Unread post 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.

Patron of MiSTer + theypsilon + Jotego Team + Coin-Op Collection + Pierco + Nullobject

MiSTer RePlay website

Ultimate SID Collection website

delarou
Posts: 5
Joined: Tue Jan 31, 2023 6:26 pm

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

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

Post Reply