SimHub icon indicating copy to clipboard operation
SimHub copied to clipboard

SimHub w/ Javascript doesnt recognize image paths

Open ghost opened this issue 6 months ago • 0 comments

I am trying to build a script that would display car logos using one "Image" or "Image from file" component based on car name and current grid position. Here is the script:

const CarName = $prop('GarySwallowDataPlugin.Generic.GridPosition01.CarName').toString().toLowerCase();

if (CarName.includes("ford")) {
    return "library:CAR\ford.jpg"; 
}
else if (CarName.includes("audi")) {
    return "D:\GAMEZ\SimHub\ImageLibrary\CAR\audi.jpg"; 

else {
    return "library:GT World\CAR\default.jpg";
}

In this script I have SimHubs native path format

"library:CAR\ford.jpg"

and also direct path format

"D:\GAMEZ\SimHub\ImageLibrary\CAR\audi.jpg"

However SimHub doesnt recognize neither of the two and does not display the actual car logo (.jpg). However it does display the raw result but without \

D:GAMEZSimHubImageLibraryCARaudi.jpg

but in djson file this result looks like this with two \ \

return "D:\ \GAMEZ\ \SimHub\ \ImageLibrary\ \CAR\ \audi.jpg - had to put space in between \ because github will display only one \

Point being I cannot make a script that would automatically pick a car logo (.jpg) based on the current car name & grid position, I can only manually pick a car logo by manually setting the output path.

Can someone help me out?

Using the latest SimHub with Gary Swallow plugin.

ghost avatar Jun 21 '25 20:06 ghost