Jump to content



Photo
* * * * * 5 votes

Call for testing


  • Please log in to reply
1630 replies to this topic

#1461 leeoneil

leeoneil

    Enthusiast

  • Members
  • PipPipPip
  • 100 posts

  • Flag: France

  • Favorite Pinball: pro pinball fantastic journey

Posted 28 January 2022 - 02:53 PM

 

On every table we can see the amount of time we played (and the number of launch of each table).

Do you know if we can find the TOTAL time played on all the tables ? Is it recorded somewhere by pinbally ?

 

It's not recorded directly, but I suppose you could figure it by adding up all of the individual table times.  You could do that in Javascript:

let totalSeconds = 0;
gameList.getAllGames().forEach(game => totalSeconds += game.playTime);

You could embed that snippet in a button command handler to display the total on demand, for example, or work it into the status line rotation with a custom message and a status line event (see .Javascript scripting > Events > Event Types > StatusLineEvent in the help).

 

Hello everyone.
I'm back with this subject.
So i'm trying to count the total time played on my tables, and i want to see the information on the frontend (on a turning message for example).
MLR help me with these informations, but i'm not good enough to understand everything.

 

As said in PinballY help, i created a new file : main.js and i put it in the script folder.
In this file, i copied/paste the command gave by MJR.

 

let totalSeconds = 0;
gameList.getAllGames().forEach(game => totalSeconds += game.playTime);

 

I don't understand now how can i see the result on the moving message in PinballY.
I tried a "[totalseconds]" in a status line rotation but i don"t understand what i'm doing (and it's not working).

Is there someone here to help me with this ?

 

Thank's !


Edited by leeoneil, 28 January 2022 - 02:55 PM.


#1462 mjr

mjr

    Pinball Wizard

  • Members
  • PipPipPipPipPip
  • 3,346 posts

  • Flag: United States of America

  • Favorite Pinball: Medieval Madness

Posted 28 January 2022 - 08:20 PM

I don't understand now how can i see the result on the moving message in PinballY.

I tried a "[totalseconds]" in a status line rotation but i don"t understand what i'm doing (and it's not working).

 

You're halfway there.  The status message substitution variables [xxx] are all pre-defined, and they don't have anything to do with Javascript, so you can't just refer to your own Javascript variables like that directly.  But what you can do is to supplement the pre-defined substitutions with your own additional substitutions, by intercepting the statusline event on the status line object where you want it to appear.  Something like this (not tested):

mainWindow.statusLines.lower.on("statusline", ev => {
    ev.expandedText = ev.expandedText.replace(/\[totalseconds\]/g, totalSeconds);
});

That'll do the replacements on the lower status line - change it to ".upper" on the first line if you want to handle these on the upper line instead.  If you want to handle both, make a common function for the event handler and install it in both places:

let secondsExpander = ev => {
    ev.expandedText = ev.expandedText.replace(/\[totalseconds\]/g, totalSeconds);
});
mainWindow.statusLines.upper.on("statusline", secondsExpander);
mainWindow.statusLines.lower.on("statusline", secondsExpander);


#1463 leeoneil

leeoneil

    Enthusiast

  • Members
  • PipPipPip
  • 100 posts

  • Flag: France

  • Favorite Pinball: pro pinball fantastic journey

Posted 28 January 2022 - 11:04 PM

Thank you to take some time to answer.

 

With this in the main.js :

mainWindow.statusLines.lower.on("statusline", ev => {
    ev.expandedText = ev.expandedText.replace(/\[totalSeconds\]/g, totalSeconds);
});

let totalSeconds = 0;
gameList.getAllGames().forEach(game = totalSeconds += game.playTime);

PinballY display me "0".

it's a progress, thank you.
Now i don't understand exactly how it's ,supposed to agregate all the time played on all the tables.



#1464 mjr

mjr

    Pinball Wizard

  • Members
  • PipPipPipPipPip
  • 3,346 posts

  • Flag: United States of America

  • Favorite Pinball: Medieval Madness

Posted 29 January 2022 - 12:31 AM

gameList.getAllGames().forEach(game = totalSeconds += game.playTime);

 

It looks like you left out an important bit of punctuation - where it says "game = totalSeconds...", you want it to say "game => totalSeconds...".  The => symbol makes it a "closure", a sort of function, which is what you need here.

 

Now i don't understand exactly how it's ,supposed to agregate all the time played on all the tables.

 

That "forEach" call is what does the aggregation.  It loops over all of the games and adds their play time to the "totalSeconds" variable via the "+=", so after the "forEach", totalSeconds has the sum of all of the play times.  That's why you have to set totalSeconds = 0 right before calling forEach, to start off the sum at 0.

 

The forEach accomplishes this once.  So if you just have this statement in the .js file at the top level like this, it'll compute the current total when you launch PinballY, and you'll see that total fixed throughout the session.

 

You probably don't want that, though.  You probably want it to show a live update every time it changes.  The easy way to do that would be to move the forEach into the statusline event handler, so that you recompute it every time you need to update the status line.

mainWindow.statusLines.lower.on("statusline", ev => {
   let totalSeconds = 0;
   gameList.getAllGames().forEach(game => totalSeconds += game.playTime);
   ev.expandedText = ev.expandedText.replace(/\[totalSeconds\]/g, totalSeconds);
});

That's a little inefficient, because the play time isn't likely to change every time the status line updates.  So it'll work, but it will do a lot more computing work than is really necessary.  Probably not enough to bog down your system, but still.  The most efficient way would probably be to do the updates in a postlaunch event handler, since (I think) the only time the total play time for a given game should ever change during a session is after you've launched and returned from a game session.  So something like this:

let totalPlayTime;
function updateTotalPlayTime() {
   totalPlayTime = 0;
   gameList.getAllGames().forEach(game => totalPlayTime += game.playTime);
}

// figure the initial play time when this script is first loaded, at the start of the PinballY session
updateTotalPlayTime();

// and update the total play time each time we return from a game play session
mainWindow.on("postlaunch", ev => updateTotalPlayTime());

// substitute [totalSeconds] into the lower status line text on each display update
mainWindow.statusLines.lower.on("statusline", ev => {
   ev.expandedText = ev.expandedText.replace(/\[totalSeconds\]/g, totalPlayTime);
});

(All of that is untested, but hopefully will point you in the right direction.)


Edited by mjr, 29 January 2022 - 12:34 AM.


#1465 leeoneil

leeoneil

    Enthusiast

  • Members
  • PipPipPip
  • 100 posts

  • Flag: France

  • Favorite Pinball: pro pinball fantastic journey

Posted 29 January 2022 - 06:38 AM

Thank you for your time and your effort to explain !

I can "understand" vbs script from vpx, but i'm totally lost with javascript.

I'll try all of this as soon as possible ! 

Thank you again for all of this and for your work in general for the whole community.

 

edit :

the first part is workiiiiing ! Yes !

Thank you !

For the moment, i just put the primary function, the total time do not update during a session.

I'll try to display the message in hour (actually it's in second) and after i'll try the real-time update function.

 

Thank you !!!


Edited by leeoneil, 31 January 2022 - 09:48 AM.


#1466 leeoneil

leeoneil

    Enthusiast

  • Members
  • PipPipPip
  • 100 posts

  • Flag: France

  • Favorite Pinball: pro pinball fantastic journey

Posted 04 February 2022 - 08:09 AM

It's working, PinballY give me the total time played in hour/min/seconds !

A friend of mine gave me a little help for the rest of the script.

 

So if you want to have this information, just create a "main.js" file in the script folder of pinballY, and copy/paste these lines

function convertHMS(value) {
    const sec = parseInt(value, 10); // convert value to number if it's string
    let hours   = Math.floor(sec / 3600); // get hours
    let minutes = Math.floor((sec - (hours * 3600)) / 60); // get minutes
    let seconds = sec - (hours * 3600) - (minutes * 60); //  get seconds
    // add 0 if value < 10; Example: 2 => 02
    if (hours   < 10) {hours   = "0"+hours;}
    if (minutes < 10) {minutes = "0"+minutes;}
    if (seconds < 10) {seconds = "0"+seconds;}
    return hours+' hours '+minutes+' min '+seconds+' s'; // Return is HH : MM : SS
}

let totalSeconds = 0;
gameList.getAllGames().forEach(game => totalSeconds += game.playTime);


let totalPlayTime;
function updateTotalPlayTime() {
   totalPlayTime = 0;
   gameList.getAllGames().forEach(game => totalPlayTime += game.playTime);
}

// figure the initial play time when this script is first loaded, at the start of the PinballY session
updateTotalPlayTime();

// and update the total play time each time we return from a game play session
mainWindow.on("postlaunch", ev => updateTotalPlayTime());

// substitute [totalSeconds] into the lower status line text on each display update
mainWindow.statusLines.lower.on("statusline", ev => {
   ev.expandedText = ev.expandedText.replace(/\[totalSeconds\]/g, convertHMS(totalPlayTime));
});

After that, in the lower status line option of PinballY, add a line with this :

[totalSeconds] played

 

Actually the result is available only on lower status line (not upper one), but it's updated "in real time".

I'll try the next option as soon as possible.

 

Thank you again MJR !!!!!!!


Edited by leeoneil, 04 February 2022 - 03:18 PM.


#1467 htamas

htamas

    Pinball Wizard

  • VIP
  • 2,238 posts
  • Location:SF Bay Area, California

  • Flag: Hungary

  • Favorite Pinball: cannot pick just one, and they change anyway



Posted 05 February 2022 - 01:32 AM

 

Hello,

Love PinballY. There is one thing that is bugging tho… I must have a setting wrong because my computer is quite powerful (10th gen i9 and RTX 2080ti) but I’m getting choppy navigation when I page through the wheels. See this video:

https://youtube.com/...Y?feature=share

What could it be?

Thanks!


I figured this out. I was using the FlexDMD scripts (provided in the FlexDMD download) to load stuff on my third screen as I navigate thru the front end. Apparently those scripts are not efficient enough. Once I removed them, no more stutter during navigation.

 

 

I have the same exact problem but didn't set up any such scripts that I'd be aware of. What scripts did you remove and where?

The jerky wheel navigation is a little annoying, I'd love to get it smooth like it was in PinballX.



#1468 htamas

htamas

    Pinball Wizard

  • VIP
  • 2,238 posts
  • Location:SF Bay Area, California

  • Flag: Hungary

  • Favorite Pinball: cannot pick just one, and they change anyway



Posted 07 February 2022 - 08:10 PM

OK, it turns out the reason for the jerky navigation is in the main.js script of PinballY. If I disable (rename) that, the wheel movement becomes perfectly smooth. The problem appears to be caused by the part that updates the DMD when skipping to a new table. Disabling the script leaves that screen empty.

I like the automatic DMD info, so now I need to find out what part of the UpdateDMD function is the culprit and try to fix it.

Any idea is certainly appreciated :)


Edited by htamas, 08 February 2022 - 12:13 AM.


#1469 leeoneil

leeoneil

    Enthusiast

  • Members
  • PipPipPip
  • 100 posts

  • Flag: France

  • Favorite Pinball: pro pinball fantastic journey

Posted 08 February 2022 - 08:48 AM

The "main.js" in the script folder is a file that you added, it's not installed by default by pinballY.

 

I'm not sure to understand, but the last version of pinballY  (1.1.0 Beta 5, May 18, 2021) update the dmd every time you change a table.

It show a video if you have one, or an image, and then the highscores.

So i think you don't need a "main.js"  script (except if you want some extra options, like the one MJR post just above).

 

What version do you have ?


Edited by leeoneil, 08 February 2022 - 08:53 AM.


#1470 htamas

htamas

    Pinball Wizard

  • VIP
  • 2,238 posts
  • Location:SF Bay Area, California

  • Flag: Hungary

  • Favorite Pinball: cannot pick just one, and they change anyway



Posted 08 February 2022 - 08:20 PM

I have the latest available version, downloaded from mjrnet just a few weeks ago.

The main.js script came with the PinballY default setup, I didn't add anything.

If I don't have the main.js script, then the problem with jerky navigation is resolved (and the DMD screen remains blank). However, I like the default info shown on the DMD while selecting tables, so my preference would be trying to find out what causes the lag and fix it while keeping the DMD updates.



#1471 mjr

mjr

    Pinball Wizard

  • Members
  • PipPipPipPipPip
  • 3,346 posts

  • Flag: United States of America

  • Favorite Pinball: Medieval Madness

Posted 08 February 2022 - 11:31 PM

The main.js script came with the PinballY default setup, I didn't add anything.

 

That's curious - it shouldn't be in any of my distributions.


What's in your copy?



#1472 apophis

apophis

    Enthusiast

  • Members
  • PipPipPip
  • 99 posts
  • Location:Mission Viejo, California

  • Flag: United States of America

  • Favorite Pinball: The Getaway

Posted 08 February 2022 - 11:46 PM

I personally added code to main.js from the FlexDMD distribution. That was the issue for me, and once I removed it the wheels animation was smooth.

#1473 htamas

htamas

    Pinball Wizard

  • VIP
  • 2,238 posts
  • Location:SF Bay Area, California

  • Flag: Hungary

  • Favorite Pinball: cannot pick just one, and they change anyway



Posted 09 February 2022 - 12:22 AM

OK, I double-checked and I was wrong.

The main.js script came indeed with the FlexDMD distribution, not with PinballY. Sorry about the confusion :sorry:

 

Still, I'm interested in fixing it if possible... will see what can be done about it. Trouble is, I suck at JS  :unsure:



#1474 mjr

mjr

    Pinball Wizard

  • Members
  • PipPipPipPipPip
  • 3,346 posts

  • Flag: United States of America

  • Favorite Pinball: Medieval Madness

Posted 09 February 2022 - 02:42 AM

If you want to point me to a copy, I can take a look, although I can't promise anything - it might be that what they're doing is inherently complex enough that it needs a perceptible delay to process.  But a lot of performance problems turn out to be due to inefficiencies that can be fixed with some rethinking of the approach.



#1475 htamas

htamas

    Pinball Wizard

  • VIP
  • 2,238 posts
  • Location:SF Bay Area, California

  • Flag: Hungary

  • Favorite Pinball: cannot pick just one, and they change anyway



Posted 09 February 2022 - 03:27 AM

Attached is the main.js script from the FlexDMD distribution.

If you happen to find the time to look at it, that'd be greatly appreciated.

Attached Files


Edited by htamas, 09 February 2022 - 03:28 AM.


#1476 mjr

mjr

    Pinball Wizard

  • Members
  • PipPipPipPipPip
  • 3,346 posts

  • Flag: United States of America

  • Favorite Pinball: Medieval Madness

Posted 09 February 2022 - 07:21 AM

Attached is the main.js script from the FlexDMD distribution.

If you happen to find the time to look at it, that'd be greatly appreciated.

 

I looked it over, and I'm afraid I don't have any ideas for speeding it up.  You might want to talk to the original authors to see if they can help you.  They're making a lot of calls out to the FlexDMD COM object, to do things like load videos and graphics, so my guess is that one (or several) of those is blocking the thread for long enough to cause the glitching you're seeing.  This looks like something where they might be better served with a more asynchronous threaded/messaging architecture, since video loading is inherently time-consuming.  Javascript doesn't do multi-threading, so they'd probably have to do something like add an intermediate external COM object to mediate between Javascript and the underling FlexDMD interface.  Obviously a fairly big project.  But it still might be worth talking to them - maybe they could create a "lite" version with a subset of the functionality that doesn't have such heavy CPU demands, for example.



#1477 leeoneil

leeoneil

    Enthusiast

  • Members
  • PipPipPip
  • 100 posts

  • Flag: France

  • Favorite Pinball: pro pinball fantastic journey

Posted 09 February 2022 - 10:19 AM

To htamas : I don't understand exactly what this script add to PinballY.

 

	Custom DMD screen script that shows informations on the selected game (more or less the same than PinballY) using custom medias (animated company logo, table title screen):
	
	- Shows image/video from the 'dmds/manufacturers' subfolder (hardcoded in the script)
	- Shows image/video from the 'dmds/titles' subfolder if they match the media name of the table
	- Shows highscores
	- Shows statistics
	- Can check for PinballY updates and display if any on the main screen (disabled by default)

With original PinballY, we have alteady everything except the statistics on DMD.

If you add these vidéos for example : https://vpuniverse.c...os-2022-febzip/

You will have on DMD : logo/name of the game, year, logo/name of the companie and higscores.

And everything is smooth.



#1478 htamas

htamas

    Pinball Wizard

  • VIP
  • 2,238 posts
  • Location:SF Bay Area, California

  • Flag: Hungary

  • Favorite Pinball: cannot pick just one, and they change anyway



Posted 14 February 2022 - 04:25 AM

 

Attached is the main.js script from the FlexDMD distribution.

If you happen to find the time to look at it, that'd be greatly appreciated.

 

I looked it over, and I'm afraid I don't have any ideas for speeding it up.  You might want to talk to the original authors to see if they can help you.  They're making a lot of calls out to the FlexDMD COM object, to do things like load videos and graphics, so my guess is that one (or several) of those is blocking the thread for long enough to cause the glitching you're seeing.  This looks like something where they might be better served with a more asynchronous threaded/messaging architecture, since video loading is inherently time-consuming.  Javascript doesn't do multi-threading, so they'd probably have to do something like add an intermediate external COM object to mediate between Javascript and the underling FlexDMD interface.  Obviously a fairly big project.  But it still might be worth talking to them - maybe they could create a "lite" version with a subset of the functionality that doesn't have such heavy CPU demands, for example.

 

Thanks again for taking the time to look into this. I'll try to see if there is a way to improve on the performance. I attempted some rather trial-and-error approach to pinpoint what call causes the navigation glitch but wasn't successful so far.

Actually it surprises me that this issue apparently doesn't bother others than me and apophis, or maybe it's only us who experience the hiccup? Interesting.


I have another question... what's the setting that can suppress the 'Rendering table' popup window when starting a table from PinballY? I didn't see any option that would address this and seeing that popup is rather annoying, so it'd be nice to get rid of it. Somehow PinballX manages not to show it so there has got to be a way...



#1479 mjr

mjr

    Pinball Wizard

  • Members
  • PipPipPipPipPip
  • 3,346 posts

  • Flag: United States of America

  • Favorite Pinball: Medieval Madness

Posted 14 February 2022 - 08:11 AM

 what's the setting that can suppress the 'Rendering table' popup window when starting a table from PinballY? I didn't see any option that would address this and seeing that popup is rather annoying, so it'd be nice to get rid of it. Somehow PinballX manages not to show it so there has got to be a way...

 

Which type of game are we talking about here?  Visual Pinball, something else?  That message isn't anything that's coming from PinballY - it's coming from the game.  So the option will be something you need to set in the game, either in the game's settings or in a command-line parameter, again depending on what game player program you're talking about.



#1480 htamas

htamas

    Pinball Wizard

  • VIP
  • 2,238 posts
  • Location:SF Bay Area, California

  • Flag: Hungary

  • Favorite Pinball: cannot pick just one, and they change anyway



Posted 20 February 2022 - 04:56 AM

Which type of game are we talking about here?  Visual Pinball, something else?  That message isn't anything that's coming from PinballY - it's coming from the game.  So the option will be something you need to set in the game, either in the game's settings or in a command-line parameter, again depending on what game player program you're talking about.

 

Yes, it's Visual Pinball. Of course the popup comes from VPX, but I don't see a way to suppress the 'Preparing table' popup in its options, unless I'm missing something obvious.

I was just wondering if PinballY is capable of hiding that, since PinballX is not showing the same window when starting a game.