[MOD 0.14.x] Water maze

Topics and discussion about specific mods
swni
Long Handed Inserter
Long Handed Inserter
Posts: 69
Joined: Sat Mar 05, 2016 1:54 am

[MOD 0.14.x] Water maze

Post by swni » Tue Mar 15, 2016 8:12 am

Type: Mod
Name: Water maze
Description: Changes the distribution of water and land at the start of a new game
License: MIT
Author: swni
Version: 0.0.9
Release: 2016-03-15
Tested-With-Factorio-Version: 0.14.16
Category: Gameplay
Tags: terrain, water, land

See page on mods.factorio.com for information. This information may not be up to date.
Long description
Pictures
Version history
Known issues.
  • This mod behaves poorly if enabled before loading a save where this mod was initially disabled (it stops generating water). In future versions I will print an alert to notify the user of this problem if it occurs. Unfortunately I can't print an alert to let the user know if they forgot to enable the mod before loading a save. Alternatively this problem could be solved by just deleting data.lua but this will create minor artifacts in resource generation (including trees / rocks / biters / etc.). Example artifacts
  • As of v 0.12.30, automatic synchronization of configuration files in multiplayer is now impossible. :( You must synchronize your configuration manually. A workaround is to have the host create a new game with the desired configuration, save and close the game, reset your config file to defaults, open the game, and then invite other players to join.
Attachments
water-maze_0.0.8.zip
(17.49 KiB) Downloaded 181 times
water-maze_0.0.7.zip
(17.46 KiB) Downloaded 36 times
water-maze_0.0.6.zip
(14.73 KiB) Downloaded 43 times
water-maze_0.0.5.zip
(12.23 KiB) Downloaded 167 times
water-maze_0.0.4.zip
(12.24 KiB) Downloaded 63 times
water-maze_0.0.3.zip
(12.06 KiB) Downloaded 41 times
water-maze_0.0.2.zip
(12.04 KiB) Downloaded 67 times
water-maze_0.0.1.zip
(11.73 KiB) Downloaded 61 times
Last edited by swni on Fri Oct 28, 2016 7:09 am, edited 13 times in total.

User avatar
theRustyKnife
Fast Inserter
Fast Inserter
Posts: 212
Joined: Thu Feb 26, 2015 9:26 pm

Re: [MOD 0.12.x] Water maze

Post by theRustyKnife » Thu Mar 17, 2016 5:43 am

Cool idea, I'm tempted to do the islands for my next playthrough.
I have a little question tho... Are the paths the two tiles that rails can be built on? It would be unfortunate if they aren't.
TRK
Check out my mods!

swni
Long Handed Inserter
Long Handed Inserter
Posts: 69
Joined: Sat Mar 05, 2016 1:54 am

Re: [MOD 0.12.x] Water maze

Post by swni » Fri Mar 18, 2016 5:04 am

As of v0.0.4, yes the islands pattern with a path width of 2 (which is now configurable) should align with rails. You can use the translate filter to change whether or not it is aligned in case this is not desired (or in case I messed up and it isn't aligned).

Marvin
Burner Inserter
Burner Inserter
Posts: 8
Joined: Fri Feb 26, 2016 1:49 pm

Re: [MOD 0.12.x] Water maze

Post by Marvin » Sat Mar 19, 2016 8:01 pm

HI. love the idea of this mod and had to try out the island pattern. It made for an interesting playthrough. After first trying with relatively small islands I decided to make a new world with increased size so that each island could have a 4 way rail intersection and a station. Ended up using pattern = islands(64, 64, 6), with all resources on very high settings. The idea was to have islands specialized in making different types of items, with trains carrying specific types of resources where they were needed. I added the fluid barrel mod to be able to transport fluids by train. It took quite some time to build, mostly because building trainstations that could handle a lot of different materials but still have a decent throughput was very challenging, also having empty barrels come back properly plus making sure each station could remove coal to load the locomotives (so that i could have a refuling train going to all stations instead of having all trains have to go to a refuling station). Here is the end result:
http://i.imgur.com/3NHbIvk.jpg
Bottom right is the last area I built and the only one featuring any logistics. The 4 way intersections with a single train stop was my early design, but I ended up needing a separate drop off and pick up station for most islands to be able to have a decent throughput.

Thanks for a great mod!

swni
Long Handed Inserter
Long Handed Inserter
Posts: 69
Joined: Sat Mar 05, 2016 1:54 am

Re: [MOD 0.12.x] Water maze

Post by swni » Sun Mar 20, 2016 4:29 am

That's a very impressive base you have, glad you enjoyed it!

mraider94
Burner Inserter
Burner Inserter
Posts: 5
Joined: Sun Mar 20, 2016 6:03 am

Re: [MOD 0.12.x] Water maze

Post by mraider94 » Sun Mar 20, 2016 6:22 am

Trying to figure out what to change to get the comb.

swni
Long Handed Inserter
Long Handed Inserter
Posts: 69
Joined: Sat Mar 05, 2016 1:54 am

Re: [MOD 0.12.x] Water maze

Post by swni » Sun Mar 20, 2016 9:22 am

mraider94 wrote:Trying to figure out what to change to get the comb.
After unzipping the zip file, inside the water-maze_0.0.4 directory you should find a file called control.lua. At the top of the file are a lot of comments describing the configuration options available and how to enable them. (I guess if you are using Notepad/Wordpad/etc. it might not be obvious what text is comment and what text is code.) On line 29, the code "pattern = maze2()" defines which pattern is used for the terrain generator. Change that to "pattern = comb()" to get the comb pattern. On line 31, the code "pattern = chunkify(pattern, 32)" determines the thickness of the pattern; change the number 32 to control how thick the branches of the comb is. (The backbone of the comb is three times as thick as the branches are.) Let me know if you have any difficulties.

Yinan
Fast Inserter
Fast Inserter
Posts: 125
Joined: Sun Feb 14, 2016 2:40 pm

Re: [MOD 0.12.x] Water maze

Post by Yinan » Sun Mar 20, 2016 1:00 pm

Two things:

First, you forgot to change the version number in the info.json from 0.0.3 to 0.0.4 which results in an error (at least for me after unzipping the zip into the mods folder).

Secondly, do you actually need it to be version 0.12.26 for the base game?
I changed that to 0.12.20 (which I'm using) and at least the island pattern worked perfectly. Maybe you should lower it to a version that you actually need as a basic minimum to allow people who don't play with the most recent version to play with it.

swni
Long Handed Inserter
Long Handed Inserter
Posts: 69
Joined: Sat Mar 05, 2016 1:54 am

Re: [MOD 0.12.x] Water maze

Post by swni » Sun Mar 20, 2016 7:16 pm

Thanks for catching these issues. I tried to automate the process as much as possible but this is the second time I've tested different code than I deployed by accident... Anyhow, I removed the requirement of a specific Factorio version (I've still only tested it on 0.12.26 / 0.12.27) and fixed the version in info.json.

mraider94
Burner Inserter
Burner Inserter
Posts: 5
Joined: Sun Mar 20, 2016 6:03 am

Re: [MOD 0.12.x] Water maze

Post by mraider94 » Mon Mar 21, 2016 2:05 am

I have a general idea of what was a comment and what was a setting, but notepad is shit for coding. Opened it in chrome the other night to see what its supposed to look like, just notepad seemed to have scrambled it or something.

Found this https://repl.it/ and was able to change it. Just one question, changing the thickness, going up make them thicker on thinner?

swni
Long Handed Inserter
Long Handed Inserter
Posts: 69
Joined: Sat Mar 05, 2016 1:54 am

Re: [MOD 0.12.x] Water maze

Post by swni » Mon Mar 21, 2016 2:27 am

mraider94 wrote:I have a general idea of what was a comment and what was a setting, but notepad is shit for coding. Opened it in chrome the other night to see what its supposed to look like, just notepad seemed to have scrambled it or something.

Found this https://repl.it/ and was able to change it. Just one question, changing the thickness, going up make them thicker on thinner?
The number controls how many tiles wide the branches are; so by default they are 32 tiles wide.

I'm not familiar with repl.it, but I would recommend Notepad++ as a drop-in replacement for Notepad. Notepad++ is very similar to Notepad, but has syntax highlighting suitable for use in coding, has many fewer bugs (although in the newest versions of Windows they have done a decent job getting rid of the most irritating Notepad bugs), and has bunches of other features which you can just ignore. (Personally I use vim but that takes time to learn to use.)

DonovanHawkins
Manual Inserter
Manual Inserter
Posts: 3
Joined: Sat Jan 30, 2016 6:02 pm

Re: [MOD 0.12.x] Water maze

Post by DonovanHawkins » Mon Mar 21, 2016 5:00 pm

Great mod! I've always wanted to get more interesting water barriers without losing map connectivity, and your mod means I can finally play on island chains like this:

Image.

This is a composition of your islands pattern with your maze2 pattern:

Code: Select all

function islandify(pattern, islandradius, pathlength, pathwidth)
    local pattern_get = pattern.get
    local r = islandradius or 32
    local k = pathlength or 48
    local w = pathwidth or 2
    local n = 2 * r + w + k
    local function get(x, y)
        local pattern_x = math.floor((x + r) / n)
        local pattern_y = math.floor((y + r) / n)
        if not pattern_get(pattern_x, pattern_y) then
          return false
        end
        x = x % n
        y = y % n
        if (x < w and pattern_get(pattern_x, pattern_y + 1)) or (y < w and pattern_get(pattern_x + 1, pattern_y)) then
            return true
        else
            x = (x + r) % n
            y = (y + r) % n
            return (x < 2 * r + w) and (y < 2 * r + w)
        end
    end
    return {get = get, lua = 'islandify(' .. pattern.lua .. ', ' .. r .. ', ' .. k .. ', ' .. w .. ')'}
end

pattern = maze2()

pattern = islandify(pattern, 64, 64, 2)
Your maze2 pattern appears to perform caching, so this should be pretty performant. As a bonus, if you create an identity pattern that always returns true and a delta function pattern that returns true at the origin, you can islandify them to recreate the existing islands/island patterns.

I'm really curious to see what other composition patterns people can come up with.

Donovan

Yinan
Fast Inserter
Fast Inserter
Posts: 125
Joined: Sun Feb 14, 2016 2:40 pm

Re: [MOD 0.12.x] Water maze

Post by Yinan » Mon Mar 21, 2016 6:58 pm

DonovanHawkins wrote:[...]
That is awesome. Now I have to start the game again to use that pattern, as it looks beautiful!
Thanks for the share Donovan :D

orzelek
Smart Inserter
Smart Inserter
Posts: 3254
Joined: Fri Apr 03, 2015 10:20 am

Re: [MOD 0.12.x] Water maze

Post by orzelek » Mon Mar 21, 2016 7:15 pm

This one looks intriguing. Might need to figure out how it will work in conjunction with RSO.
Since both use the on_chunk_generated event it might be a bit tricky.

Small proposal - please add a config.lua and move settings there. Then just use them in other lua files. Thats the convention used around here in mods.

(There is a non-0 chance that to work properly I would need to move mode code into RSO - would you be ok with it? Nicely credited in proper places ofc )

swni
Long Handed Inserter
Long Handed Inserter
Posts: 69
Joined: Sat Mar 05, 2016 1:54 am

Re: [MOD 0.12.x] Water maze

Post by swni » Mon Mar 21, 2016 9:59 pm

Donovan- That looks fantastic, may I have your permission to add your code/ideas to the mod? (with credit of course) (And yes, maze2 caches.)

Incidentally, at first the islands pattern was going to make circular islands, but I thought that was just a bit too cruel.

orzelek- I'll look into moving things to config.lua. I imagine this mod will have no trouble with RSO, assuming RSO doesn't care about land/water. This mod turns off the normal water generation, so the only thing it does during on_chunk_generated is change land tiles to grass, water, or deepwater (or not change them at all), so the only interaction with resources is deleting resources that end up in the water, in which case it shouldn't matter which one is run first. You can copy code if necessary, but maybe using the remote script interface somehow might be better?

DonovanHawkins
Manual Inserter
Manual Inserter
Posts: 3
Joined: Sat Jan 30, 2016 6:02 pm

Re: [MOD 0.12.x] Water maze

Post by DonovanHawkins » Mon Mar 21, 2016 10:35 pm

swni: Certainly, feel free to use them.

orzelek: RSO seems to be working well enough with this mod as long as you bump the resources up or are willing to travel a bit further. The only problem was losing starting area resources when the island radius was small, which is also going to be a problem with vanilla resource generation. An island radius of 32 was bad, but 64 worked fine.

swni
Long Handed Inserter
Long Handed Inserter
Posts: 69
Joined: Sat Mar 05, 2016 1:54 am

Re: [MOD 0.12.x] Water maze

Post by swni » Mon Mar 21, 2016 10:42 pm

You can also use 'union' with island to make a big area of guaranteed land around the origin, so you don't lose starting resources

orzelek
Smart Inserter
Smart Inserter
Posts: 3254
Joined: Fri Apr 03, 2015 10:20 am

Re: [MOD 0.12.x] Water maze

Post by orzelek » Mon Mar 21, 2016 11:08 pm

swni wrote:Donovan- That looks fantastic, may I have your permission to add your code/ideas to the mod? (with credit of course) (And yes, maze2 caches.)

Incidentally, at first the islands pattern was going to make circular islands, but I thought that was just a bit too cruel.

orzelek- I'll look into moving things to config.lua. I imagine this mod will have no trouble with RSO, assuming RSO doesn't care about land/water. This mod turns off the normal water generation, so the only thing it does during on_chunk_generated is change land tiles to grass, water, or deepwater (or not change them at all), so the only interaction with resources is deleting resources that end up in the water, in which case it shouldn't matter which one is run first. You can copy code if necessary, but maybe using the remote script interface somehow might be better?
The thing is that RSO tries to not place resources in the water and can move them by up to a chunk to spawn them. So order will matter since you might get resources you wouldn't in other case. And with RSO this can be quite important.
Idea with remote interfaces would work maybe. We would need have an interface that one mod would call before/after his work is done.
Mods would need to detect each other presence - it can be done by checking for existance of remote interface.

If you could cehck for RSO's interface to skip chunk work and make remote access to your make_chunk I could sort it out on RSO side to make terrain changes first then proceed with resource generation. I'm not sure how this would function in places where resources cross chunk borders.

I have also alternative idea in mind but would need to verify some things to make sure it's actually doable - remote interface seems easier.

swni
Long Handed Inserter
Long Handed Inserter
Posts: 69
Joined: Sat Mar 05, 2016 1:54 am

Re: [MOD 0.12.x] Water maze

Post by swni » Mon Mar 21, 2016 11:39 pm

It should be pretty easy for Water Maze to expose two remote interfaces; one that tells it whether to suppress calling make_chunk in response to on_chunk_generated, and another to explicitly call make_chunk when desired. Then RSO can call the former on_init and on_load, and the latter right before its own chunk generation work. This way RSO needs to be aware of this mod, but not vice versa. (Or we could go the other way.) Does that sound good?

Yinan
Fast Inserter
Fast Inserter
Posts: 125
Joined: Sun Feb 14, 2016 2:40 pm

Re: [MOD 0.12.x] Water maze

Post by Yinan » Tue Mar 22, 2016 6:24 am

I'm using water maze together with Train Outposts (which is an RSO derivat) and it works good.
Only Problem I had with my new Map that I haven't seen any Oil Well so far... maybe I have to adjust the cost for the bergius process mod so that I can research it without needing to have plastic first (only problem will be the initial heavy oil but oh well, if worst comes to worst, I'm just gonna summon a heavy oil barrel -.-).

Post Reply

Return to “Mods”