1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

Custom Music For Scenarios

Discussion in 'Civ2 - Scenario Creation' started by Prof. Garfield, Sep 25, 2019.

  1. Prof. Garfield

    Prof. Garfield Deity Supporter

    Joined:
    Mar 6, 2004
    Messages:
    2,629
    Location:
    Ontario
    @kawabunga asked a question in the TOTPP thread that got me thinking about music and lua, and I've found a way to get custom music for scenarios using TOTPP and Lua. I'll probably post "properly" about this in a day or two, once I've made a usage example and made sure I don't want to make changes, but I'm too excited to keep this quiet.

    For now, I've made it so that Lua will look at the PICKMUSICTOT line in Game.txt and try to find an mp3 file with that name. There is a little bit of code in the events, but I'm pretty sure it will be cut and paste style stuff. @JPetroski and @tootall_2012 both have great scenarios that could, perhaps, be even better with some custom music.

    There is a catch: I use Lua to overwrite files (specifically the .mp3 files in Test of Time\Music). This is something I've wanted to avoid, such as for, example, using Lua events to do the work of batch files. My justification is that
    1. this might be really, really, good,
    2. The location of the files to be overwritten is known exactly in advance, so there is less room for error
    3. Because of 2, this can be put in the lua folder, so there aren't a lot of duplicates to keep track of that might have errors or be malicious (I don't think malicious code is very likely in our context, but it's best to be a little wary just in case).

    If you think otherwise, please say so

    At the moment, I've attached the module itself (which has installation instructions) and a "scenario" that has the Civ II music that was not released with TOT. The "scenario" is just a folder where I test code out, including some of the modules that I've written.

    Another point of note: it appears that init.lua is run when the menu is accessed and before a game is loaded. I've modified it to reset the music to the defaults, but there might be other uses for lua code run at that time. You can insert a civ.ui.text line in the file to see when it runs.

    EDIT: Removed attachments, since the actual patch has been released.
     
    Last edited: Sep 27, 2019
  2. Prof. Garfield

    Prof. Garfield Deity Supporter

    Joined:
    Mar 6, 2004
    Messages:
    2,629
    Location:
    Ontario
    The Custom Music Patch is released. I've removed the attachments in the above post, since they are not necessary, and one of them was rather large.
     

Share This Page