mrnotsoevil / CSLMusicMod

Add custom music and radio stations to Cities: Skylines
GNU Lesser General Public License v2.1
26 stars 9 forks source link

Suggestion: Named conditions #18

Closed originalfoo closed 6 years ago

originalfoo commented 6 years ago

In the docu, you use A, B, C, etc to improve clarity - why not do same in to the config file itself?

For example:

{
    "name" : "SimCity Extra",
    "collections" : ["SimCity Day", "SimCity Night"],
    "filters":{
        day:{ "type" : "time", "from" : 6, "to" : 20 },
        night:{ "type" : "time", "from" : 20, "to" : 6 }
    },
    "contexts" : [
        { "conditions" : [ [ "day" ] ], "collections" : ["SimCity Day"]},
        { "conditions" : [ [ "night" ] ], "collections" : ["SimCity Night"]}
    ]
}

If you find a string in the conditions (instead of an object), treat it as named reference to a value in the filters object. You could have a page listing the most commonly used filters (day, night, raining, etc) or even have those filters bundled as part of the main mod (they can be overridden on station-by-station basis by creating a filter of same name in a config file).

With this approach, filters could potentially be added to individual audio files too (eg. this is my daytime collection, but only play this particular track/advert/chat if it's raining).

Also, I assume the check is done only when choosing next track to play and not constantly while radio is on (ie. it won't impair performance)?

rumangerst commented 6 years ago

Good idea! Built-in filters could work, but I don't have an idea about some useful filters except day/night. The check is performed every ~10s. The CSL radio system does not expose the event when a new song plays. Evil hacks everywhere.

rumangerst commented 6 years ago

Implemented as suggested. Documentation updated.