Page 1 of 1

3 LUA modding suggestions

Posted: Wed Mar 30, 2016 1:34 pm
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.

Re: 3 LUA modding suggestions

Posted: Wed Mar 30, 2016 11:57 pm
by ssilk
Moved from suggestions to modding interface requests.

Re: 3 LUA modding suggestions

Posted: Thu Mar 31, 2016 5:18 pm
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}})

Re: 3 LUA modding suggestions

Posted: Thu Mar 31, 2016 5:32 pm
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]

Re: 3 LUA modding suggestions

Posted: Fri Apr 01, 2016 2:11 am
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.

Re: 3 LUA modding suggestions

Posted: Fri Apr 01, 2016 5:04 pm
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.

Re: 3 LUA modding suggestions

Posted: Sun Apr 03, 2016 3:35 am
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.

Re: 3 LUA modding suggestions

Posted: Wed May 11, 2016 1:21 am
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).