Adding water is technically feasible but also breaks the game as biters can't cross it.
Re: [0.9.x] Landfill
Posted: Thu May 22, 2014 11:04 am
by Neotix
You can add some semi expensive tool with low durability (5-10 use). Player will be able to manipulate terrain but digging canal around the factory will be very expensive.
Re: [0.9.x] Landfill
Posted: Thu May 22, 2014 11:11 am
by Airat9000
I realized that you can create water? and so it is a waste of resources?
Re: [0.9.x] Landfill
Posted: Sat May 24, 2014 5:20 pm
by rubixx
So I have found a bug that renders the mod unusable . The landfill function no longer works after reloading a saved game. It just plops down the green square and leaves the tile as water. I haven't found a way around this and I'm not sure what is causing it. Hopefully you can fix it b/c I was really enjoying using the mod!
Re: [0.9.x] Landfill
Posted: Sat May 24, 2014 6:05 pm
by FreeER
rubixx wrote:The landfill function no longer works after reloading a saved game.
This made me take a look at the code...I'm curious as to why you [GotLag] are even using oninit here, it's unneeded. The code that makes this work (other than the prototypes) is just the landfill function and the anonymous function that's passed to onbuiltentity, putting the onbuiltentity handler registration (ie. game.onevent(defines.events.onbuiltentity...)) inside an Initialise function and calling that through oninit is what's making it only work on new games (the handler is only registered oninit[ialization] of a game, not onload)...
anyways other than removing the oninit (if you don't intend to use it) and just registering the onbuiltentity handler directly, a fix for this is to add
to the control.lua file (so it registers the onbuiltentity handler (which runs the landfill function when an entity is built) when the game is loaded as well).
Re: [0.9.x] Landfill
Posted: Sat May 24, 2014 7:51 pm
by GotLag
I developed the mod by loading an existing save, and onload() wasn't firing and oninit() was.
So am I right to assume that oninit() fires when you load a game with the mod for the first time, and subsequently fires onload()?
Re: [0.9.x] Landfill
Posted: Sat May 24, 2014 8:21 pm
by FreeER
GotLag wrote:So am I right to assume that oninit() fires when you load a game with the mod for the first time, and subsequently fires onload()?
hm...honestly I was half assuming that oninit was only for new worlds (play->new), some testing (due to your comment) shows that it does also work with new mods though (learn something new everyday I guess )...however it does not call onload afterwards it's only used the first time the mod is loaded. If you load a save that was saved after you added the landfill mod the oninit is not called (and so your onbuiltentity handler is not registered and thus it can not call the landfill function), but if you have an onload handler it would be called. As I mentioned in my original post however you don't actually need either oninit or onload for what the mod currently does, just onbuiltentity and the landfill function (though the landfill function could be moved into the onbuiltentity if it was desired...the function probably makes it a bit easier to modify though), the code would work if it was just this
require "defines"
game.onevent(defines.events.onbuiltentity, function(event)
if event.createdentity.name == "landfill" then
landfill(event.createdentity.position)
game.createentity
{
name = "landfill-fade",
position = event.createdentity.position,
force = game.forces.player
}
event.createdentity.destroy()
end
end)
function landfill(position)
xpos = position.x - 1
ypos = position.y - 1
for i = 0,1,1 do --y
for j = 0,1,1 do --x
game.settiles{{name="grass", position={xpos + j, ypos + i}}}
--game.player.print(xpos + j .. ", " .. ypos + i)
end
end
end
or this (moved the landfill function, and removed the for loop for no reason)
require "defines"
game.onevent(defines.events.onbuiltentity, function(event)
if event.createdentity.name == "landfill" then
game.settiles{{name="grass", position={event.createdentity.position.x - 1, event.createdentity.position.y - 1}}}
game.settiles{{name="grass", position={event.createdentity.position.x - 1, event.createdentity.position.y}}}
game.settiles{{name="grass", position={event.createdentity.position.x, event.createdentity.position.y - 1}}}
game.settiles{{name="grass", position={event.createdentity.position.x, event.createdentity.position.y}}}
game.createentity
{
name = "landfill-fade",
position = event.createdentity.position,
force = game.forces.player
}
event.createdentity.destroy()
end
end)
btw, I did notice in testing that bug you mentioned with the tile the player is on turning into water so it does exist with the 2x2. Not a problem if you have a spare landfill item but you could probably check the tile at the player's position after setting the tiles to be grass and if it's water turn it into grass (also, as an aesthetic thing you could probably get the name of a nearby tile and use that for the settiles command rather than hard coding grass...that way if you're in a desert and place the landfill you don't have just a few 'random' grass tiles in the desert )
Re: [0.9.x] Landfill
Posted: Sun May 25, 2014 1:59 am
by GotLag
Thanks, I wish I'd kept a copy of my earlier code so I could look back and see why just setting the event handler straight off didn't work when I tried it.
The very first thing I did was register a function with onbuiltentity via onevent to print a test message on-screen and it just wouldn't show until I registered the registering itself with oninit.
I'll add that player position check and a check that only changes the tile if it's water. The reason it uses grass is that as far as I can tell no other tile is allowed to directly border water.
Re: [0.9.x] Landfill
Posted: Sun May 25, 2014 2:40 am
by FreeER
GotLag wrote:Thanks, I wish I'd kept a copy of my earlier code so I could look back and see why just setting the event handler straight off didn't work when I tried it.
That is where the magic of version control comes in handy! (check out git if you haven't already)
GotLag wrote:The reason it uses grass is that as far as I can tell no other tile is allowed to directly border water.
from testing: out-of-map (useless for this...) and sand can as well...though from looking at the prototype (and testing results) the sand being allowed might, probably, be a bug...the rest get surrounded by grass automatically (so changing one tile in a large body of water actually changes a 3x3 with the center being what you specified) of course I also see that giving settiles an invalid tile name crashes Factorio to the desktop
land->water replacement and a bit of complaining and another discovery about settiles
results_complaining...
hm...water-green seems to only be placeable near other water-green (so placing it in regular water/deepwater creates a ring of grass around it)...jeez this feels clunky when changing one tile at a time...you know, I just looked at why settiles takes a table of tables and it looks like it's meant to be used by passing all of the tiles to be changed in at one time...that may help remove some of the derpyness of using it (when changing more than one tile)
like so (note I've made all variables local because nothing uses them outside of this function):
function landfill(position)
local xpos = position.x - 1
local ypos = position.y - 1
local tiles = {};
for i = 0,1,1 do --y
for j = 0,1,1 do --x
table.insert(tiles, {name="grass", position={xpos + j, ypos + i}})
--game.player.print(xpos + j .. ", " .. ypos + i)
end
end
game.settiles(tiles)
end
It's a shame you can't just pass this a bounding box and the tile that you want...I suppose that would prevent you from making different positions be different tiles though...would be a nice alternative though for changing large patches of ground (think large scale terraforming) rather than using a large for loop to set up the tables...
btw, for testing I found these functions very helpful (in the console that is):
getpos = function() {return game.player.screen2realposition(game.player.cursorposition)}
-- note/question why the [insert exclamation/expletive of choice here] does gettile not take a position table!
gettiles=function() game.player.print(serpent.block(game.gettile(getpos().x, getpos().y).name)) end
settiles = function(name) game.settiles{{name=name, position=getpos()}} end
Re: [0.9.x] Landfill
Posted: Sun May 25, 2014 3:36 am
by GotLag
FreeER wrote:That is where the magic of version control comes in handy! (check out git if you haven't already)
This of course requires that you committed the code in question
I doubt I'd have bothered for some console-printing test code that apparently didn't work.
FreeER wrote:from testing: out-of-map (useless for this...) and sand can as well...though from looking at the prototype (and testing results) the sand being allowed might, probably, be a bug...the rest get surrounded by grass automatically (so changing one tile in a large body of water actually changes a 3x3 with the center being what you specified) of course I also see that giving settiles an invalid tile name crashes Factorio to the desktop
I actually tried sand again after reading this, and it was automatically surrounded with grass.
This game has some... interesting behaviour. When I was feeding the tiles to settiles one at a time, it was quite easy to consistently stick the player by placing landfills in a certain checker-board pattern. When I put them in an array and sent them all at once it suddenly became significantly less likely (although still sometimes possible) to stick the player, although if I was standing out of the affected area it seemed to generate the new water tiles at almost the same frequency as before.
I've updated it to initialise properly, use array for setting tiles, and perform proper checks on player clipping and replaced tiles. Thanks for your help!
Re: [0.9.x] Landfill (1.1)
Posted: Sun May 25, 2014 3:45 am
by FreeER
GotLag wrote:I actually tried sand again after reading this, and it was automatically surrounded with grass.
really? Did you check with gettile or just see that it looked like grass? I found that placing one does look like grass (and the edges I think looked like grass as well...but I think that's masking) but placing multiple sand tiles does make it appear as sand and gettile shows only sand (no grass around it).
GotLag wrote:This of course requires that you committed the code in question
true...but we ALL do that right?
GotLag wrote:I doubt I'd have bothered for some console-printing test code that apparently didn't work.
Ah but console testing is a wonderful way to learn things, it's much faster testing through the console than the control.lua for most things
GotLag wrote:Thanks for your help!
No problem, helping is something I love doing
edit: btw, if you want the mod to be loadable without unzipping it the zip's file name must be exactly the same as the name provided in the info.json (no -1.1 in the zip name for example).
Re: [0.9.x] Landfill (1.1)
Posted: Sun May 25, 2014 4:11 am
by GotLag
FreeER wrote:really? Did you check with gettile or just see that it looked like grass? I found that placing one does look like grass (and the edges I think looked like grass as well...but I think that's masking) but placing multiple sand tiles does make it appear as sand and gettile shows only sand (no grass around it).
I turn off transitions for testing, and can confirm those tiles are what they look like. This was attempting to only place sand.
FreeER wrote:edit: btw, if you want the mod to be loadable without unzipping it the zip's file name must be exactly the same as the name provided in the info.json (no -1.1 in the zip name for example).
Fixed
Re: [0.9.x] Landfill (1.1)
Posted: Sun May 25, 2014 4:29 am
by FreeER
GotLag wrote:I turn off transitions for testing, and can confirm those tiles are what they look like. This was attempting to only place sand.
you can turn off transitions?? I didn't realize that...how?
Here are my results, the first are after placing a few with setcommand in the console. The second is after modifying the changing control.lua to place sand instead (the grass around it is the grass that was originally around the lake).
gettile shows only sand, and if it had been placing grass I'd have expected there to be rings 'within' the lake I'd filled in...weird that we have different results...
Re: [0.9.x] Landfill (1.1)
Posted: Sun May 25, 2014 4:44 am
by GotLag
FreeER wrote:]you can turn off transitions?? I didn't realize that...how?
F4, near the bottom of the list. Maximise your window, there's no scrollbar.
Re: [0.9.x] Landfill (1.1)
Posted: Sun May 25, 2014 4:52 am
by FreeER
GotLag wrote:F4, near the bottom of the list. Maximise your window, there's no scrollbar.
Oh...well, I'm on a laptop with a 1366x768 res so...I won't ever get to see/use that until it has a scrollbar The last one I can (half way) see is tile variations but that's not it
Re: [0.9.x] Landfill (1.1)
Posted: Sun May 25, 2014 5:26 am
by GotLag
It's the one immediately below that. Oh well. I can't remember if F5 shows transitions by default or not, but F6 or F7 should.
Re: [0.9.x] Landfill (1.1)
Posted: Wed May 28, 2014 5:51 pm
by Airat9000
GotLag wrote:It's the one immediately below that. Oh well. I can't remember if F5 shows transitions by default or not, but F6 or F7 should.
the question of how to create the river water? ..
ground that it creates, and how to make water?
can make a script that would create the water, next to the river. use of resources, by creating a dam (say tungsten beams iron beams + + sand ( f mod))
Re: [0.9.x] Landfill (1.1)
Posted: Mon Jun 02, 2014 8:03 am
by tetkris
very good idea, factorio need modified terrain function