3 LUA modding suggestions

Post Reply
User avatar
GproKaru
Burner Inserter
Burner Inserter
Posts: 12
Joined: Mon Mar 21, 2016 2:45 am
Contact:

3 LUA modding suggestions

Post by GproKaru »

Suggestion 1: Could it be possible for the get_tiles function to return nil if it can't find a tile at all?

I know this seems like something that won't get used often but I'm trying to work on something that involves tile checking in areas where there are no generated tiles yet and it throws up an LUA:Tile error since it can't find one.
My current alternative is to use can_place_entity to check if the space is available. While it does help detect if there is a space available there, it becomes extremely performance taxing when overused where a tile check wouldn't be as intense since it wouldn't require multiple collision checks per tick.



Suggestion 2: Either create completely empty surfaces* (or) disable/toggle surface chunk generation

One reason why I'm suggesting this is because I'm trying to create a new surface area but it's contents immediately replaced by the original surface template when chunks generate.

* by completely empty, I mean that it doesn't use the default generated surface made by the map generation.



Suggestion 3: set_tiles_area function?

I know that I could use for loops to do this but I thought maybe for a simple immediate area placement of tiles could be convenient, just a small extension on the set_tiles function where instead of just a position, it takes an area.

User avatar
ssilk
Global Moderator
Global Moderator
Posts: 12888
Joined: Tue Apr 16, 2013 10:35 pm
Contact:

Re: 3 LUA modding suggestions

Post by ssilk »

Moved from suggestions to modding interface requests.
Cool suggestion: Eatable MOUSE-pointers.
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...

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

Re: 3 LUA modding suggestions

Post by orzelek »

From what I know it would be like this:

1. You can check if chunk exists by using is_chunk_generated method of surface.
2. This one is more annoying - you would need to use on_chunk_generated and replace tiles with nothing. Would be nice to have empty terrain from start.
3. set_tiles method of surface can accept table already. It needs to be of proper format - one I seen working is like that :

Code: Select all

table.insert(tileTable,{ name = "water", position = {x,y}})

Rseding91
Factorio Staff
Factorio Staff
Posts: 13209
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: 3 LUA modding suggestions

Post by Rseding91 »

1. That sounds logical to me - getting a tile that doesn't exist can be a common thing and having to check constantly seems like pointless CPU time.

2. You can specify the map_gen_settings when making a new surface and leave out all auto-place controls to get an empty map. You can't currently specify tiles for a new surface but eventually I would like to add support for that.

3. I'm not sure on this one - it might be pretty easy to implement but I'm not going to promise anything.[/list]
If you want to get ahold of me I'm almost always on Discord.

User avatar
GproKaru
Burner Inserter
Burner Inserter
Posts: 12
Joined: Mon Mar 21, 2016 2:45 am
Contact:

Re: 3 LUA modding suggestions

Post by GproKaru »

orzelek wrote:From what I know it would be like this:

1. You can check if chunk exists by using is_chunk_generated method of surface.
2. This one is more annoying - you would need to use on_chunk_generated and replace tiles with nothing. Would be nice to have empty terrain from start.
3. set_tiles method of surface can accept table already. It needs to be of proper format - one I seen working is like that :

Code: Select all

table.insert(tileTable,{ name = "water", position = {x,y}})

1. I can't really use is_chunk_generated on a map that is 1x1 since it's only a single chunk, I did this to prevent the default map from replacing anything I generate down there before the chunk is generated. Which is why I specifically would like tiles to return nil when I do a check instead of throwing up an LUA error.

3. That's what I'm already doing, but I thought a very basic single lined script for it would be just a bit of added convenience, but I can still live without this feature.

Also, question for Rseding91:
Would it be possible to have a setting to prevent a chunk from replacing things upon generation? That's mostly what I'm trying to achieve with all of the tile checks. Making the chunk check that it's not going to replace something before it fills it up with terrain or water.

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

Re: 3 LUA modding suggestions

Post by orzelek »

I'm not 100% sure what do you mean in first point?

Are you placing tiles then game overrides them somehow?
If yes then it would mean you should actually trigger the game to generate that chunk and then place the tiles in on_chunk_generated.

User avatar
GproKaru
Burner Inserter
Burner Inserter
Posts: 12
Joined: Mon Mar 21, 2016 2:45 am
Contact:

Re: 3 LUA modding suggestions

Post by GproKaru »

orzelek wrote:I'm not 100% sure what do you mean in first point?

Are you placing tiles then game overrides them somehow?
If yes then it would mean you should actually trigger the game to generate that chunk and then place the tiles in on_chunk_generated.
That only allows for a 32x32 area of tiles, but most of the time it's not being placed within the 32x32 area and overlaps to the next area, then when that chunk generates, whatever was placed there is then replaced with the chunk generation.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13209
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: 3 LUA modding suggestions

Post by Rseding91 »

A note on #1 here: checking tile.valid will return false if the tile gotten from get_tile isn't valid (doesn't exist).
If you want to get ahold of me I'm almost always on Discord.

Post Reply

Return to “Implemented mod requests”