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

Island Chain & Central Valley

Discussion in 'Civ5 - Map Scripts' started by resorcerer, Apr 3, 2013.

  1. resorcerer

    resorcerer Chieftain

    Joined:
    Apr 3, 2013
    Messages:
    75
    I've been playing with map scripts, so I thought I'd post them here, in all of their glory of ugly lua code.

    Fantasy creates a map out of a fantasy book, with distinct regions not placed according to any simulation of temperature or rainfall.

    (see http://steamcommunity.com/sharedfiles/filedetails/?id=141000100)

    Island Chain does what you'd think. It generates a timeline of volcanos along a randomly generated hotspot path, then simulates their growth and erosion, with occasional eruptions. At the moment it's a bit too variable, I think.
    Spoiler :


    On the other hand, Central Valley is so regular it may as well be a static map. The best land is in the center, surrounded by snowy mountains. But there's not much of it. Way to cheat at one-city challenge?
    Spoiler :
     

    Attached Files:

  2. resorcerer

    resorcerer Chieftain

    Joined:
    Apr 3, 2013
    Messages:
    75
    I've noticed that Civ 5 is picky in opaque ways about validating map scripts. Rather than allow me to execute a script with an error, and therefore provide debugging information, it simply will not show up in the list of map scripts in World Builder. My trick to get around this is to, before starting World Builder, comment out all of the code, and paste code from Fractal.lua into the file. It will then show up in the available scripts, and then I can revert the file back to the way it was, execute it, and it will give me errors that I can fix.

    However, I have to use this trick to get IslandChain.lua to show up, yet when I run it, the output contains no errors. Or warnings, if there are such things. I have no idea why it doesn't show up, then. I have no way to ascertain why it gets rejected. Has anyone encountered this before?
     
  3. Bobert13

    Bobert13 Prince

    Joined:
    Feb 25, 2013
    Messages:
    345
    Use LUA for Windows (or a similar program) for general debugging/syntax checking. Chances are you missed an end or have a typo in one of your variables.

    If LUA for Windows doesn't report an error but gets stuck on the includes, your script should be useable in World Builder/the game. Firetuner's LUA console is great when working with map scripts, but it won't always put out an error message for the cases mentioned above.
     
  4. resorcerer

    resorcerer Chieftain

    Joined:
    Apr 3, 2013
    Messages:
    75
    Right, normally the script isn't listed in World Builder when there's a syntax error. This time, however, there are no syntax errors, and in fact when tricked into recognizing the script, it runs without a problem. Nonetheless, if I don't deceive World Builder, it won't recognize the script. It's useable in the game, but the game doesn't seem to know that it is.
     
  5. Bobert13

    Bobert13 Prince

    Joined:
    Feb 25, 2013
    Messages:
    345
    There's something, somewhere, that the game doesn't like. :D
     
  6. resorcerer

    resorcerer Chieftain

    Joined:
    Apr 3, 2013
    Messages:
    75
    Lol, yes, and I wish it told me what! This is starting to sound theological.
     
  7. resorcerer

    resorcerer Chieftain

    Joined:
    Apr 3, 2013
    Messages:
    75
    How have I sinned?!
     
  8. Bobert13

    Bobert13 Prince

    Joined:
    Feb 25, 2013
    Messages:
    345
    If you haven't tried the debugger in LUA for Windows, it may find what the game is getting stuck on.

    It could even be a line that the isn't getting called. Doesn't compile? check; runs correctly? check; no error message? check.
     
  9. Optional

    Optional Deity

    Joined:
    May 22, 2007
    Messages:
    2,935
    Location:
    It Dockumer Lokaeltsje
    I think it's great that people are playing around with map scripts again. There's been too little activity here.
    For me a lot of code is abacadabra, I've never been great at maths, so I'm getting lost. I like following what people more talented than me are doing.
    Good luck, I hope there's more coming!
     
  10. resorcerer

    resorcerer Chieftain

    Joined:
    Apr 3, 2013
    Messages:
    75
    That's nice to hear. I've been working on a script that creates the kind of map in the first pages of fantasy novels. Distinct regions that are in no way determined by lattitude, simulated rainfall, etc. It needs to create continents that are more blobby, but it does make some interesting terrain, I think.
     

    Attached Files:

  11. resorcerer

    resorcerer Chieftain

    Joined:
    Apr 3, 2013
    Messages:
    75
    fantasy script now has much blobbier continents, and a few map options
     

    Attached Files:

  12. resorcerer

    resorcerer Chieftain

    Joined:
    Apr 3, 2013
    Messages:
    75
    continents seperate properly, and are not so regularly hexagonal in shape even when blobby. features line up with terrain properly. mountain ranges are along region boundaries and coastlines (as well as occasional snowy regions).
     

    Attached Files:

  13. resorcerer

    resorcerer Chieftain

    Joined:
    Apr 3, 2013
    Messages:
    75
    - ice & atolls
    - different world "climates" can be chosen
    - more consistent mountain ranges and control over amount of mountains
    - land masses distribute more evenly across the map (less continent clumping)
    - controllable ocean depth

    any region types or world climates you want? currently the list is as follows:
    regions: plains, desert, grass, rolling hills, swamp, plains forest, grass forest, tundra forest, jungle, snowy mountains, wasteland, tundra, cloud forest, dunes, alpine, ice
    world climates: mix (default), tropical, temperate, cold
     

    Attached Files:

  14. albie_123

    albie_123 Modding In Secret

    Joined:
    Mar 12, 2010
    Messages:
    1,380
    Location:
    Sydney, NSW
    Maybe desert mountain ranges?

    EDIT: Just saw you mentioned dunes, and that's probably what you meant.
     
  15. Temudjin

    Temudjin Chieftain

    Joined:
    Oct 16, 2007
    Messages:
    90
    A bit late for a reply (to post #4) and you probably found the solution yourself, but ...

    At the time the map scripts are initialized Map.GetGridSize() is not known, which generates an error. So we need to call it later, when Map has been created by the game.

    Two easy changes to correct the error:
    Code:
    local oceanLevel = 1
    local hillsLevel = 2
    local mountainLevel = 5
    
    -- end of settings, beginning of calculated variables
    
    ---------- Temudjin START
    -- Initialize global variables within function
    function calcGlobalVars()
    	iW, iH = Map.GetGridSize()
    
    	xMax = iW - 1
    	yMax = iH - 1
    
    	chainIterations = math.floor( math.max(xMax, yMax) * 1.7 )
    	simulationIterations = math.floor( chainIterations * 1.1 )
    	minVolcanoDuration = math.floor( simulationIterations / 16 )
    	maxVolcanoDuration = math.floor( simulationIterations / 1.5 )
    
    	totalVolcanos = 0
    end
    ---------- Temudjin END
    
    
    Code:
    function GeneratePlotTypes()
    	print("Setting Plot Types (Island Chain) ...");
    
    	---------- Temudjin START
            -- Call function to initialize global variables
    	calcGlobalVars()
    	---------- Temudjin END
    
    	local volcanos = calculateVolcanos(chainIterations, volcanoChance, minVolcanoDuration, maxVolcanoDuration)
    	local heights = buildErode(simulationIterations, volcanos)
    
    
    Hope that helps.
     
  16. resorcerer

    resorcerer Chieftain

    Joined:
    Apr 3, 2013
    Messages:
    75
    Sort of. Dunes are hilly desert (half the tiles are hills). Desert mountain ranges will also sometimes occur, as they will with any region, along its borders.

    Thanks, Temudjin. I did eventually figure out that was the problem (apparently, there is a log in My Documents\my games\Sid Meier's Civilization 5\Logs\Lua.log).

    On a related note, my friend devised a way to get map scripts to run in a non-civ lua environment, to check for errors.

    Code:
    if include == nil then
    	package.path = package.path..';C:\\Program Files (x86)\\Steam\\steamapps\\common\\Sid Meier\'s Civilization V\\Assets\\Gameplay\\Lua\\?.lua'
    	include = require
    	Map = {
    		GetGridSize = function()
    			return 40,40
    		end
    	}
    end
    (put before include statements)
     
  17. resorcerer

    resorcerer Chieftain

    Joined:
    Apr 3, 2013
    Messages:
    75
    - mountain ranges more congtiguous
    - continent edges more irregular
    - slightly better chance of some land masses being separated by deep ocean
    - flood plains happen
     

    Attached Files:

  18. resorcerer

    resorcerer Chieftain

    Joined:
    Apr 3, 2013
    Messages:
    75
    I tried putting this into a mod via modbuddy, but the map type never shows up in the list, in either worldbuilder or in game. It recognizes that there is a mod, and I can select it, but that's it. I thought at first the problem was no "Content" of the "MapScript" type, but then I added that and rebuilt it. Still nothing. :confused:

    edit: apparently, the lua file must be set to import into the virtual file system

    edit: in other words, all of the above is old, and any further updates will be of the steam workshop
     

Share This Page