[MOD 0.12.x] Finite Water

Topics and discussion about specific mods
User avatar
db48x
Fast Inserter
Fast Inserter
Posts: 106
Joined: Wed Mar 13, 2013 12:15 pm
Contact:

Re: [MOD 0.12.x] Finite Water

Post by db48x »

Darkestnoir wrote:

Code: Select all

Error while running the event handler: __finitewater__/water_drain.lua:52: attempt to index field 'water_drain' (a nil value)
Can't start a new game with 12.13.
Oops, that's my fault. This version should work correctly.
Attachments
finitewater_1.0.2.zip
Fixes initialization on new maps
(87.23 KiB) Downloaded 1501 times

User avatar
ZombieMooose
Filter Inserter
Filter Inserter
Posts: 289
Joined: Mon Feb 09, 2015 7:23 am
Contact:

Re: [MOD 0.12.x] Finite Water

Post by ZombieMooose »

EDIT: I found it
"men will literally learn everything about ancient Rome instead of going to therapy"

roxblnfk
Manual Inserter
Manual Inserter
Posts: 1
Joined: Mon Dec 28, 2015 6:10 pm
Contact:

Re: [MOD 0.12.x] Finite Water

Post by roxblnfk »

db48x wrote:
Darkestnoir wrote:

Code: Select all

Error while running the event handler: __finitewater__/water_drain.lua:52: attempt to index field 'water_drain' (a nil value)
Can't start a new game with 12.13.
Oops, that's my fault. This version should work correctly.
multiplayer arises dissynchronization (factorio 0.12.11 + hardcorio)
when new player picked in game with the pumps

User avatar
db48x
Fast Inserter
Fast Inserter
Posts: 106
Joined: Wed Mar 13, 2013 12:15 pm
Contact:

Re: [MOD 0.12.x] Finite Water

Post by db48x »

Yes, I've noticed the desyncs as well. Perhaps now that Christmas is past I can get around to debugging them...

ulposch
Manual Inserter
Manual Inserter
Posts: 3
Joined: Wed Feb 03, 2016 7:51 pm
Contact:

Re: [MOD 0.12.x] Finite Water

Post by ulposch »

I already hated infinite water playing minecraft and was more than happy when Redpower introduced pumps that really used up existing water. When i saw this mod i hoped to add water to the transport management of factorio. So i installed your mod and created a testworld to see how it works and adjust water per tile to my needs.

First problem was that it only worked with offshore pumps but not with the ones in other mods. This was easy to fix by adding the other pumps to your code.
find this in waterdrain.lua:

Code: Select all

function WaterDrain.OnBuiltEntity( entity )
	if entity.valid and entity.name == "offshore-pump" then
		WaterDrain.AddWaterDrainingPump( entity )
	end
end
and add needed pumps like this:

Code: Select all

function WaterDrain.OnBuiltEntity( entity )
	if entity.valid and entity.name == "offshore-pump" then
		WaterDrain.AddWaterDrainingPump( entity )
	end
	if entity.valid and entity.name == "5d-offshore-pump" then
		WaterDrain.AddWaterDrainingPump( entity )
	end
	if entity.valid and entity.name == "5d-offshore-pump-2" then
		WaterDrain.AddWaterDrainingPump( entity )
	end
end
Don't forget to also add tem to

Code: Select all

function WaterDrain.OnDestroyEntity( entity )
This works very good and all pumps produce the same amount of water but at different speeds.

And then i ran into some problems i can't fix. It started with some random freezes (had to use the taskmanager to end factorio). I don't know what causes them but they only happen when a body of water gets depleted and the pump is connected to a pipe. (had one when my base was destroyed by biters but was not able to reproduce this). If i put a tank behind the pump all works well.
Now i had enough data on the amount of water i can get from small lakes i made in a custom scenario to start testing how long i can produce energy with a small power plant. Made a small build and let it run. Well, i got massive amounts of water from the same small lakes i used for testing. I was able to identify the problem but unfortunately it means i can't use your mod at the moment.
Pumps produce the right amount of water only when connected to only one tank. as soon as the tank is connected to anything else (pipes, other tanks, boilers) i get massive amounts of water and often the lake turns to infinite water.
Hope this information helps because i would really love to add this to my game.

Setup:
laptop with 16 GB ram
Win 7 Ultimate

Factorio 0.12.20
shadowmegamodpack
and a few more mods
Ask if you want detailed specs :-)

Edit: i used finitewater_1.0.2

devilwarriors
Filter Inserter
Filter Inserter
Posts: 311
Joined: Sat Jan 09, 2016 1:11 am
Contact:

Re: [0.12.x] Finite Water

Post by devilwarriors »

ljdp wrote:
orzelek wrote:I think you might need to mark this mod as single player only.

My lua knowledge is a bit limited but I was curious to see how you implemented the water removal and took a peek - this mod is threaded which might mean desyncs in multiplayer.
The mod uses coroutines but that isn't to be confused with threads. Coroutines are still deterministic. (But I haven't tested this with multiplayer yet).
just tryed it in multiplayer and even tho I was alone on the server this mod was causing frequent desync :(

it's too bad because it's one of my favorite mod

Aadkins13
Manual Inserter
Manual Inserter
Posts: 2
Joined: Wed Mar 23, 2016 1:50 am
Contact:

Re: [MOD 0.12.x] Finite Water

Post by Aadkins13 »

There is something wrong again. I tried my current game, a new one, everything! I can't make it work, version 0.12.28. Someone fix it please, i love this mod.


EDIT: Through testing, i realize that it does drain the water, but if it is connected to a tank or anything, it is infinite, but if there are only pipes, it will drain the lake to fill the pipes.

Factorio2016
Fast Inserter
Fast Inserter
Posts: 136
Joined: Wed Dec 23, 2015 1:17 pm
Contact:

Re: [MOD 0.12.x] Finite Water

Post by Factorio2016 »

:?: You can make dried up territory was replaced by a new biome - pit (black) ?
English is not my native language. Translator.

devilwarriors
Filter Inserter
Filter Inserter
Posts: 311
Joined: Sat Jan 09, 2016 1:11 am
Contact:

Re: [MOD 0.12.x] Finite Water

Post by devilwarriors »

In the hope of one day be able to play with this mod, I made a test map with 90 pump draining from diverse lake in a map with high terrain segmentation to stress test the mod.

It crash the game every time about 5-10 second after you plug the power to all pump.

There a chest near the map start area, grab a power pole from it and complete the circuit to start all the pump.

I used the liquid void mod to get rid of all the water and an inline pump so it need power as well as the test mode for the cheated infinite power solar panel. The map is locked to day only.

http://www.mediafire.com/download/iks6y ... urrent.log
http://www.mediafire.com/download/4wgad ... st_map.zip

Thanks!

User avatar
db48x
Fast Inserter
Fast Inserter
Posts: 106
Joined: Wed Mar 13, 2013 12:15 pm
Contact:

Re: [MOD 0.12.x] Finite Water

Post by db48x »

You'll need to report that in the bug reporting forum; it's crashing in the lua interpreter.

devilwarriors
Filter Inserter
Filter Inserter
Posts: 311
Joined: Sat Jan 09, 2016 1:11 am
Contact:

Re: [MOD 0.12.x] Finite Water

Post by devilwarriors »

Yeah I wasn't sure if they would check it or just told me that it's the mod code that is the problem, without checking it.

anyway I posted it, let's see what they say :
viewtopic.php?f=7&t=23461

I tried to isolate the part that crashing, but I had no success yet and that log file is kinda useless.

devilwarriors
Filter Inserter
Filter Inserter
Posts: 311
Joined: Sat Jan 09, 2016 1:11 am
Contact:

Re: [MOD 0.12.x] Finite Water

Post by devilwarriors »

it went exactly as I expected :(
Rseding91 wrote:The finite water mod uses coroutines which we haven't done any testing with and as such don't officially support at this time.

Ishbo
Burner Inserter
Burner Inserter
Posts: 7
Joined: Sun Apr 17, 2016 1:24 pm
Contact:

Re: [MOD 0.12.x] Finite Water

Post by Ishbo »

Hello :D

My first post here.

I have looked at your code and i modified it to consume the lake water that is actually pumped by the pump more precisely regarding the amount (didn't liked how it was calculated before with epsilon and stuff).... so if you have steam engines or 20 storage tanks in which you are pumping it shouldn't matter now regarding the difference between those 2 setup because it should be less than 1% plus minus regarding the amount of water which could be extracted from that lake.
I did this modification for myself and tought i share it. It should also work with 5 dim mod but i didn't tested it yet but as i said should work.

The offshore pumps are a bit affected , in order to get the most exact amount of water pumped i needed to reduce their pressure a bit by 10%. You will only get affected if you run a huge pipe to supply with water your steam engines , of course without additional small pumps to keep the pressure up because they still pump the same amount of water 60 units/sec.

I had set WATER_PER_TILE in water_drain.lua to 2500 default now but if you want to clear a lake faster 100 times you can set it to 25 or 100 times slower just set it to 250000. The number now represents something close to the amount of units of water which can be extracted from a tile.

Also a good idea would be to make the huge lakes oceans with lots of tiles harder to drain by adding additional bonuses to the total amount of water per tile which should directly depend on their size total number of tiles.
Attachments
finitewater_1.0.2.zip
(87.25 KiB) Downloaded 136 times

Darloth
Fast Inserter
Fast Inserter
Posts: 118
Joined: Sun Jun 08, 2014 3:57 pm
Contact:

Re: [MOD 0.12.x] Finite Water

Post by Darloth »

It would be interesting if the total water per lake were related to, say, tiles^2.

That might do what you want, and might even be possible? You'd need to scan the lake to see how big it was, mind you, then divide to get the appropriate value per-tile.

Vas
Long Handed Inserter
Long Handed Inserter
Posts: 91
Joined: Tue Apr 12, 2016 11:02 pm
Contact:

Re: [MOD 0.12.x] Finite Water

Post by Vas »

This is a single player only mod, it does not synchronize with everyone and causes massive amounts of desyncronization errors.
You can get my mods by clicking here, and use discussions there or PMs here to suggest or report issues.
Want some blueprints made by me? Click here then!

User avatar
bloc97
Inserter
Inserter
Posts: 47
Joined: Sat Apr 16, 2016 4:57 am
Contact:

Re: [MOD 0.12.x] Finite Water

Post by bloc97 »

Vas wrote:This is a single player only mod, it does not synchronize with everyone and causes massive amounts of desyncronization errors.
The OP has to use global.* tables in order for this mod to be MP-Compatible, anything "local" is never synced between clients, and thus never to be used on "on.tick", local variables should only be used inside a function that returns a variable that is not dynamic. (i.e. does not modify the game state). For example, SEARCH_OFFSET can be "local", but not "WATER_PER_TILE", since the latter actually affects how the tiles get removed.
Image-Vehicles, Defense, Energy & More!
Image-Keep inventory on death!

devilwarriors
Filter Inserter
Filter Inserter
Posts: 311
Joined: Sat Jan 09, 2016 1:11 am
Contact:

Re: [MOD 0.12.x] Finite Water

Post by devilwarriors »

bloc97 wrote:
Vas wrote:This is a single player only mod, it does not synchronize with everyone and causes massive amounts of desyncronization errors.
The OP has to use global.* tables in order for this mod to be MP-Compatible, anything "local" is never synced between clients, and thus never to be used on "on.tick", local variables should only be used inside a function that returns a variable that is not dynamic. (i.e. does not modify the game state). For example, SEARCH_OFFSET can be "local", but not "WATER_PER_TILE", since the latter actually affects how the tiles get removed.
also like I proved a few post ago, even in single player the performance is pretty awfull.. anything more than 3-5 pumps and you're looking at a game crash.
I made a bug report but the DEV discarded it because the mod use co-routine which they don't officially support at the moment.

a recode from scratch would be nice if one of you lua experts ever have the time, I'm available for testing if you need me.
Last edited by devilwarriors on Fri Apr 22, 2016 3:36 am, edited 2 times in total.

User avatar
bloc97
Inserter
Inserter
Posts: 47
Joined: Sat Apr 16, 2016 4:57 am
Contact:

Re: [MOD 0.12.x] Finite Water

Post by bloc97 »

devilwarriors wrote:also like I proved a few post ago, even in single player the performance is pretty awfull.. anything more than 3-5 pumps and your locking at a game crash.
I made a bug report but the DEV discarded it because the mod use co-routine which they don't officially support at the moment.

a recode from scratch would be nice if one of you lua experts ever have the time, I'm available for testing if you need me.
I currently see two ways this concept can work without lagging the entire game:

The easy, fast and rough way:
1-Search for water tiles in an area of radius r around the pump, and compute how much water there is on that area, save that in a variable. When that variable "water" runs out, replace the tiles around the pump to "grass" or "sand".

The elegant way, but much more complex to create:
2-Find all water tiles connected to the pump, and list the coordinates. Save that list and associate the coordinates to a UNIQUE and COMMON "water value". (Note every tile uses that one variable)
If there is multiple pumps, there's not more calculations to do, the water value just has to decrease faster
When that value runs out, for every x seconds the pump still runs, use a function to gradually replace the water tiles.
The only way this method can lag is
i. List the coordinates too fast when placing the pump, game might freeze for a couple ticks. Slower listing can compensate.
ii. Replacing the water tiles too fast, again, doing it slower and more gradually will compensate.

Note that you can abandon the "water value", and start slowly removing the tiles as soon you place the pump. For every k water used by pump, remove a water tile. If there is 2 pumps, you can just check for k1+k2.

Just don't save a water value for each tile for performance's sake, and don't compute the water value of each tile each tick...
The API already runs multiple lines of code for each event, multiplied by each water tile per tick... ouch...

I'm not a lua expert, but I have common sense regarding performance... (not insulting anyone, just giving constructive criticism)

Edit: That crash log looks like that the game ran out of threads... Probably too computationally intensive. You can make a similar crash by looping an bit of entity creation code.
Image-Vehicles, Defense, Energy & More!
Image-Keep inventory on death!

Factorio2016
Fast Inserter
Fast Inserter
Posts: 136
Joined: Wed Dec 23, 2015 1:17 pm
Contact:

Re: [MOD 0.12.x] Finite Water

Post by Factorio2016 »

You need to make the tiles had the number of the resource as ore.
Dark tile lot of water - 10000, bright tile - 5000. for example
This is the only sane way out! Somewhere I read on the forum that they will implement in version 0.13.
Or support or function in the game. Look forward to...
English is not my native language. Translator.

Vas
Long Handed Inserter
Long Handed Inserter
Posts: 91
Joined: Tue Apr 12, 2016 11:02 pm
Contact:

Re: [MOD 0.12.x] Finite Water

Post by Vas »

Factorio2016, water above a certain size can not be depleted, that size is by default 10,000. So if there are 10k water blocks, it won't drain.
You can get my mods by clicking here, and use discussions there or PMs here to suggest or report issues.
Want some blueprints made by me? Click here then!

Post Reply

Return to “Mods”