Island Chain & Central Valley

resorcerer

Chieftain
Joined
Apr 3, 2013
Messages
85
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 :
 

Attachments

  • IslandChain.zip
    2.5 KB · Views: 280
  • CentralValley.zip
    1.3 KB · Views: 317
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?
 
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.
 
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.
 
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.
 
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!
 
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.
 

Attachments

  • Screenshot (558).jpg
    Screenshot (558).jpg
    117.2 KB · Views: 481
  • Screenshot (560).jpg
    Screenshot (560).jpg
    126.4 KB · Views: 491
  • Fantasy.zip
    3.9 KB · Views: 205
fantasy script now has much blobbier continents, and a few map options
 

Attachments

  • Fantasy2.zip
    5.4 KB · Views: 199
  • fantasyscreen-april10-huge.jpg
    fantasyscreen-april10-huge.jpg
    159.2 KB · Views: 1,203
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).
 

Attachments

  • fantasy3-80x50.jpg
    fantasy3-80x50.jpg
    94.6 KB · Views: 377
  • Fantasy3.zip
    7.3 KB · Views: 201
- 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
 

Attachments

  • fantasy4-80x50.jpg
    fantasy4-80x50.jpg
    188 KB · Views: 336
  • Fantasy4.zip
    9.3 KB · Views: 223
Maybe desert mountain ranges?

EDIT: Just saw you mentioned dunes, and that's probably what you meant.
 
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.

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.
 
Maybe desert mountain ranges?

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

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)
 
- mountain ranges more congtiguous
- continent edges more irregular
- slightly better chance of some land masses being separated by deep ocean
- flood plains happen
 

Attachments

  • Fantasy5.zip
    10.1 KB · Views: 222
  • fantasy5-80x50.jpg
    fantasy5-80x50.jpg
    225.5 KB · Views: 350
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
 
Top Bottom