Skip to content

Instantly share code, notes, and snippets.

@Teqqles
Last active June 16, 2021 17:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Teqqles/6145c6e3b0f63947ca54881a094439a2 to your computer and use it in GitHub Desktop.
Save Teqqles/6145c6e3b0f63947ca54881a094439a2 to your computer and use it in GitHub Desktop.
Custom SimHub serial device script for IR controlled flag lights. Written primarily for ACC
// property table
var propsFlagAssociation = [
// property, flag short code
['GameRawData.Graphics.globalWhite', 'W'],
['Flag_White', 'W'],
['Flag_Green', 'G'],
['Flag_Orange', 'O'],
['Flag_Blue', 'B'],
['GameRawData.Graphics.globalYellow', 'Y'],
['Flag_Yellow', 'Y'],
['GameRawData.Graphics.globalRed', 'R'],
];
var currentFlag = 'X'; // default to no flag
function currentFlagUpdater(flagAssociation) {
var flagPropName = flagAssociation[0],
flagCode = flagAssociation[1];
if ($prop(flagPropName) > 0) {
currentFlag = flagCode;
}
}
for(var i=0; i<propsFlagAssociation.length; i++){
currentFlagUpdater(propsFlagAssociation[i]);
}
return '{"flag":"' + currentFlag +'"}' + "\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment