1. We have added the ability to collapse/expand forum categories and widgets on forum home.
    Dismiss Notice
  2. All Civ avatars are brought back and available for selection in the Avatar Gallery! There are 945 avatars total.
    Dismiss Notice
  3. To make the site more secure, we have installed SSL certificates and enabled HTTPS for both the main site and forums.
    Dismiss Notice
  4. Civ6 is released! Order now! (Amazon US | Amazon UK | Amazon CA | Amazon DE | Amazon FR)
    Dismiss Notice
  5. Dismiss Notice
  6. Forum account upgrades are available for ad-free browsing.
    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 Chieftain

    Joined:
    Oct 9, 2010
    Messages:
    82
    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 Chieftain

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

    eastwind Chieftain

    Joined:
    Aug 16, 2009
    Messages:
    23
    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