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

Tools to make modding easier

Discussion in 'Civ5 - Utility Programs' started by Cope, Oct 1, 2010.

  1. Cope

    Cope Chieftain

    Joined:
    Sep 30, 2010
    Messages:
    35
    So I'm new here, but I thought I'd share a couple programs that have already made modding easier for me.

    Windows Grep
    The first is Windows Grep, which is free to use. It mimics the grep command on Linux, which lets you search for a specific string inside any number of files or folders. Very useful for finding TXT_KEY's or anything else really, just point it at the Assets folder, put in your search string and *.lua, *.xml as the file types and off you go.

    PE Explorer
    The second is maybe a bit more esoteric, but it's helped me out with .lua scripting. One thing I can't find anywhere is a list of what functions are available, like City:GetFoodTurnsLeft() for example. So for this I use PE Explorer, which comes with a 30 day trial but I'll leave it up to your imagination to find a version without that. This one probably needs a short tutorial, so here goes:

    Most of the available functions are in "CvGameCoreDLLFinal Release.dll" in the root Civ V directory. Open this in PE Explorer then go to View > Exports. Here is a list of *most* of the available functions, but not all of them. It's a bit hard to read, but clicking on any function will give you a slightly better description of it in the box below the function list. See the screenshot attached.

    For example in the screenshot I've selected ?getBuiltTime@CvPlot...., which translates to:
    Code:
    public: int __thiscall CvPlot::getBuildTime(enum BuildTypes)const 
    Which tells me this function can be called from a Plot object, expects a BuildType to be passed with it, and returns an integer (a whole number). So in a .lua file, I could do:
    Code:
    local testPlot = Map.GetPlot(m_iCurrentX, m_iCurrentY);
    local buildTime = testPlot.GetBuildTime(BuildType.BUILD_FARM);
    
    Which should return the number of turns it will take to build a farm on that particular plot. Finding the BuildType is another instance where Windows Grep is handy, just search for BuildType and it'll find the .xml with a list of all valid build types (in this case CIV5Builds.xml). Note that in .lua the first letter is capitalized too, GetBuildTime.

    As I said before some functions don't show up in the export list, there's a way to find these too but it's a little more complicated. I think I'll leave that for another post if people are interested.

    Notepad++
    Lastly, I'm sure everyone who's modded Civ before will know this one. Notepad++ great for looking through .lua or .xml files to find something you want, before you import it into your mod via ModBuddy.
     

    Attached Files:

  2. ArgentumStudios

    ArgentumStudios Warlord

    Joined:
    Sep 18, 2010
    Messages:
    122
    Location:
    Utah, US
    I have a couple of ruby scripts that take the output of PE Explorer and formats it by class and member. I'll take a little time this weekend and put together a quick API listing to post on the wiki.
     
  3. salaminizer

    salaminizer Colorado Internacional

    Joined:
    Aug 12, 2006
    Messages:
    221
    Location:
    Porto Alegre, Brasil
    WinMerge: allows you easily compare files and copy the changes from one file to another. someone here in CivFanatics recommended it and it's indeed awesome.
     
  4. strategyonly

    strategyonly C2C Supreme Commander

    Joined:
    Mar 13, 2006
    Messages:
    20,604
    Gender:
    Male
    Location:
    MN
    Windows Grep if the best, i have been using it since Zappara informed me about it a year ago, it is the best for Searching through tons of files for something.
     
  5. Szpilman

    Szpilman Void Co. Chairman

    Joined:
    Dec 2, 2006
    Messages:
    746
    Location:
    Cola
    I'll be SO waiting for that :D And eternally grateful.
     
  6. PieceOfMind

    PieceOfMind Drill IV Defender Retired Moderator

    Joined:
    Jan 15, 2006
    Messages:
    9,319
    Location:
    Australia
    Thanks for the advice. I'd never seen Grep before. To this date I had been using the Find in Files function of Notepad++.
     
  7. Shiggs713

    Shiggs713 Immortal

    Joined:
    Mar 11, 2007
    Messages:
    2,361
    Location:
    Indianapolis
    you can find in files with notepad++ as well, and then even edit with it too so kinda makes grep useless unless its find in files function works better somehow.
     
  8. Jabarto

    Jabarto Emperor

    Joined:
    May 15, 2007
    Messages:
    1,025
    Location:
    Colorado, U.S.
    Yeah, I was going to say that EditPad Lite can find and replace multiple lines from numerous files. I've tested it with EU3 modding and it managed to sift through over 1000 files at once.
     
  9. PieceOfMind

    PieceOfMind Drill IV Defender Retired Moderator

    Joined:
    Jan 15, 2006
    Messages:
    9,319
    Location:
    Australia
    Oh yeah, I used to use EditPad, and IMO it was quite a bit faster than np++ (for example at opening large files).
     
  10. LDiCesare

    LDiCesare Deity

    Joined:
    Dec 22, 2005
    Messages:
    2,612
    Location:
    France
    WindowsGrep is an extraordinarily good program.

    But let's start a flamewar:
    I use gvim for editing.
     
  11. Szpilman

    Szpilman Void Co. Chairman

    Joined:
    Dec 2, 2006
    Messages:
    746
    Location:
    Cola
  12. PieceOfMind

    PieceOfMind Drill IV Defender Retired Moderator

    Joined:
    Jan 15, 2006
    Messages:
    9,319
    Location:
    Australia
    Another comment on EditPad, since I just used it again recently.

    Its search and replace functionality seems better than np++'s, because you can use return characters in the search field. (Unless np++ can do that and I haven't seen how?)
     
  13. Afforess

    Afforess The White Wizard

    Joined:
    Jul 31, 2007
    Messages:
    12,239
    Location:
    Austin, Texas
    You can use return characters in np++, so long as you switch to extended mode.
     
  14. PieceOfMind

    PieceOfMind Drill IV Defender Retired Moderator

    Joined:
    Jan 15, 2006
    Messages:
    9,319
    Location:
    Australia
    Using the '\n' right? I can see it working, but if one copy-pastes, one would have to put in the newline characters manually, and pasting into the field chops off everything but the last line from the clipboard item I think. It really doesn't work very well compared to EditPad's method.

    Thanks for the tip though. :)
     

Share This Page