1. Civ6 is coming out TODAY! Order now! (Amazon US | Amazon UK | Amazon CA | Amazon DE | Amazon FR)
    Dismiss Notice
  2. Main site is finally re-opened! We migrated it to a new CMS and gave it a new layout as well.
    Dismiss Notice
  3. Forum account upgrades are available for ad-free browsing.
    Dismiss Notice
  4. Downloads database has been migrated and re-opened! Check it out and post in Site Feedback if any issue. We have done URL re-write so that old links will continue to work.
    Dismiss Notice
  5. A new Civ6 theme forum style is now available and it's made the default forum style! Check it out and comment here.
    Dismiss Notice
  6. We have successfully migrated the forum from vBulletin to Xenforo! Please take a look around and report any issue you see in Site Feedback.
    Dismiss Notice

Howto reload your lua code within the game

Discussion in 'Civ5 - Modding Tutorials & Reference' started by Onni, Oct 9, 2010.

  1. Onni

    Onni New Member

    Oct 9, 2010
    It's possible to reload your changed lua source code within the game (without exiting).

    1. Start your Civ 5 game with your mod and also start your LiveTuner.
    2. Make changes to your source code in ModBuddy.
    3. Save and build your solution in ModBuddy.
    4. In LiveTuners "Lua Console"-tab choose your mods thread(?). By default it reads "Main State", but choose the one that has your mods name.
    5. Type the following command to the console at the bottom: include("your_mod_name_here").
    6. Your new source code should now be active in the game.
    -This applies only to lua files, not xml. Not sure yet how to do this for the UI-xml files?
    -You have to be careful when you do this. When it re-reads your source it also does again everything you have written. So if you are e.g. registering to events then after this you have registered twice to all of those events.
    -Also xml-instances should be reset before reloading or otherwise you might experience "ghost-elements". ;)

    It's possible to update a single function using LiveTuner.
    1. Start your Civ 5 game with your mod and also start your LiveTuner.
    2. Create a new panel in LiveTuner. While creating it remember to choose your mods thread(?) from the list below the name line.
    3. Choose your mods thread(?) from the drop down. If you don't see it then go back to step 2.
    4. Rightclick the empty canvas and choose "new action control".
    5. In the action part write your updated function.
    6. Press test and if there are no errors press ok.
    7. Now press your newly created action button and your function should be immediately updated.

    Even if it takes some time and thought to do this I think it's worth it. At best after every lua change I just build my solution in ModBuddy, typed the include command in LiveTuner and I could see my mod updating immediately after.
  2. Drog

    Drog New Member

    Oct 13, 2010
    Nice! Now if we can find how to reload xml...
  3. eastwind

    eastwind New Member

    Aug 16, 2009
    If all you are doing is making a new map script then each time you start a new game the map script is rerun, so you don't need to use LiveTuner, you can simply "Exit to Main", save changes to the map script and go through the "Set Up Game" dialog again to test your changes.

    That probably goes without saying (but I decided to say it anyway just in case).

    Another hint for first-time modders getting their feet wet by doing a map script: if your map script fails partway through due to a runtime error, the usual result seems to be that the game loads, but as soon as you hit "Begin Your Journey" you get the big "Defeat" popup.

Share This Page