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

Ability to create new gamesave information (already there?/modable by Lua?/dll mod?)

Discussion in 'Civ5 - Creation & Customization' started by Pazyryk, Sep 24, 2010.

  1. Pazyryk

    Pazyryk Deity

    Joined:
    Jun 13, 2008
    Messages:
    3,584
    I've been trying to figure this out in another thread discussion, but I thought I'd put it out here in case anyone knows the answer.

    As a python/XML-only modder in civ4, I often faced this serious limitation that I couldn't create novel game variables (I think that's what you call them) and put information in them that would be saved in the gamesave file (and hence, reloaded later with that game). This is a horrible limitation in many ways: 1) My code had to do absurd things every single turn that might have needed doing only once in a game (like search all tiles to find a particular unique feature). 2) Without modding in new Feats (which required dll modding), you couldn't do much of any interesting chained events or quests.

    So I'm hoping (and still optimistic) that such a thing is now possible without dll modding. The whole new database structure in Civ5 is quite impressive, and it looks like Lua can access almost everything from the outset without the constant need for dll changes to "expose" them (as in Civ4). However, what I need is access to part of that database that can be altered and is saved /reloaded from the gamesave file (rather than fresh from the XML file or cache). I haven't seen any hint of this yet in any discussions. Does anyone know?
     
  2. Dale

    Dale Mohawk Games Developer

    Joined:
    Mar 14, 2002
    Messages:
    7,100
    From my understanding (I'll get confirmation next time I talk to the mod developer) the DB gets saved in the save game. So if you add new stuff view the XML files, they just become new fields in the DB and automatically saved.
     
  3. Pazyryk

    Pazyryk Deity

    Joined:
    Jun 13, 2008
    Messages:
    3,584
    Bump.

    I've been following most of the modding threads and Kael's wonderful guide, but I'm still wondering if this is possible outside of dll modding. From what I understand, the db resides as cache when you exit the game and is not contained in the gamesave file. Therefore, I can't change something dynamically in a game (via Lua) and expect the change to be there on reload (well, not if I have >1 game going or use someone else's gamesave). Is this correct? If so, is there really no way currently to change anything dynamically in the game and have it stick?
     
  4. Dale

    Dale Mohawk Games Developer

    Joined:
    Mar 14, 2002
    Messages:
    7,100
    Ok confirmed from the mod tool programmer:

    The database is not saved in the save game. So if you change the base value of something it will not be reflected after loading. So if you change the base value of a warrior's strength, it will revert on loading the save game. In this instance, use a promotion to make the change.
     
  5. Pazyryk

    Pazyryk Deity

    Joined:
    Jun 13, 2008
    Messages:
    3,584
    And no other method for mod memory in a gamesave file? That's a real drag for modding any kind of complex event chain. (I'll have to resort to some horrible kludge like coding game events as promotions to put on some invisible, inaccessible unit.)

    Anyway, I'll just put this out there as a suggestion for a widely useful dll mod: a single, generic, modifiable table that is stored in and reloaded from the gamesave file. The structure of the table could be defined in XML (and hence expanded by a modder) to indicate variable names and what they contain (strings, integers, etc.). This would allow any modder to create new values to remember (for example, flags for a long chain of events in a quest) without subsequent dll modding.
     
  6. Dale

    Dale Mohawk Games Developer

    Joined:
    Mar 14, 2002
    Messages:
    7,100
    Oh no, you can create new database information in mods, just you can't change the base value after loading. :)

    So if you added a new concept which required new database stuff, it will work. You just can't change the default values of things (what you set in the xml) on the fly.

    It works the same as Civ4.
     
  7. Pazyryk

    Pazyryk Deity

    Joined:
    Jun 13, 2008
    Messages:
    3,584
    Yeah, I'm aware that it was this way in civ4 because I always had to: 1) create the craziest python/xml kludges to work around it, 2) ask another modder to modify dll any time I wanted some new "game feat" or somesuch that needed remembering, or 3) learn C++ to change dll myself (which I haven't done yet). Really, I'm surprised I'm the only one interested in this. Event chains are perfect for simple languages like Python or Lua (not computationally intensive needing C++ and a lot easier to code in python/lua than using civ4's clunky events system).

    Btw, I keep looking at a file called CIV5MemoryInfos.xml in BasicInfos and thinking (perhaps wishfully) that it might be exactly what I described above. It has some generic schema at the top but no data at all. It might not even be used (as are several other xml files). Or it might be populated from another file. Or it could be a place to store something (anything...perhaps AI memory of betrayal and such) created "on the fly" and remembered in gamesave (which is exactly what I want). Or something else? Here is CIV5MemoryInfos.xml in its entirety:

    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <GameData>
    
        <!-- Table definition -->
        <Table name="MemoryInfos">
            <Column name="ID" type="integer" primarykey="true" autoincrement="true" />
            <Column name="Type" type="text" notnull="true" unique="true" />
            <Column name="Description" type="text" />
        </Table>
    
        <!-- Table data -->
    	<MemoryInfos/>
    	
    </GameData>
     
  8. Dale

    Dale Mohawk Games Developer

    Joined:
    Mar 14, 2002
    Messages:
    7,100
    I'll try and find out.
     

Share This Page