API request :)

Replaces resource spawning system, so that the distances between resources are much bigger. Railway is needed then.

Moderators: orzelek, Dark

Post Reply
FuryoftheStars
Smart Inserter
Smart Inserter
Posts: 2483
Joined: Tue Apr 25, 2017 2:01 pm
Contact:

API request :)

Post by FuryoftheStars »

Hey orzelek,

Any chance you can grant outside access to your isInStartingArea function? I have an infinite resource mod that I just added a setting for applying only to starting area resources. While I'm still trying to figure out how exactly to determine that in regards to vanilla seems the starting area slider doesn't apply to resources, I did want to get it to work with your mod as well.
My Mods: Classic Factorio Basic Oil Processing | Sulfur Production from Oils | Wood to Oil Processing | Infinite Resources - Normal Yield | Tree Saplings (Redux) | Alien Biomes Tweaked | Restrictions on Artificial Tiles

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

Re: API request :)

Post by orzelek »

This might not be difficult but are you prepared to handle multiple starting areas that this function will take into account?

I'd also need to figure out how to ensure that passed surface index points to something that actually exists - I'm not sure how game behaves if you ask for surface that doesn't exist.

Hmm opsie. Scratch above - this function relies on internally held table of surface data. So publishing it might not be that easy since you have no idea about that table and I'd need to somehow map function input to that table and it doesn't have even surface name I think.

Actually I checked when looking at the other API and I'm using game surface index to index my table. So this might be doable. Multiple starting areas remaing a valid question altho I have no idea if anyone out there is using that.

FuryoftheStars
Smart Inserter
Smart Inserter
Posts: 2483
Joined: Tue Apr 25, 2017 2:01 pm
Contact:

Re: API request :)

Post by FuryoftheStars »

Without looking back into the code, my memory of the function was that I feed it a surface index and x/y coords that I want it to check. It then handles all of the checking and returns true if it's in any starting area, if I understood it correctly. This is perfectly fine for me and my use.
My Mods: Classic Factorio Basic Oil Processing | Sulfur Production from Oils | Wood to Oil Processing | Infinite Resources - Normal Yield | Tree Saplings (Redux) | Alien Biomes Tweaked | Restrictions on Artificial Tiles

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

Re: API request :)

Post by orzelek »

FuryoftheStars wrote:
Tue Jan 04, 2022 6:47 pm
Without looking back into the code, my memory of the function was that I feed it a surface index and x/y coords that I want it to check. It then handles all of the checking and returns true if it's in any starting area, if I understood it correctly. This is perfectly fine for me and my use.
Thats correct. The thing is it's checking the main starting area but also all other custom starting areas that can be added to RSO. There is a big chance no-one is actually using those.

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

Re: API request :)

Post by orzelek »

Added access to isInStartingArea in 6.2.12.
Let me know if it works properly.
It requires surface index (can be read from game surface index property) and tile coordinates x,y.

FuryoftheStars
Smart Inserter
Smart Inserter
Posts: 2483
Joined: Tue Apr 25, 2017 2:01 pm
Contact:

Re: API request :)

Post by FuryoftheStars »

Thanks. Haven't had a chance to try yet, but hopefully soon.

Question, regarding vanilla, does the game technically only have 1 start position? How does it handle competitive MP? At the moment, I'm checking to see if something is outside of the start area with this

Code: Select all

util.distance({0,0}, resource.position) > resource.surface.get_starting_area_radius()
But that makes the assumption of only 1 start point at {0,0}.
My Mods: Classic Factorio Basic Oil Processing | Sulfur Production from Oils | Wood to Oil Processing | Infinite Resources - Normal Yield | Tree Saplings (Redux) | Alien Biomes Tweaked | Restrictions on Artificial Tiles

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

Re: API request :)

Post by orzelek »

FuryoftheStars wrote:
Wed Jan 12, 2022 3:53 pm
Thanks. Haven't had a chance to try yet, but hopefully soon.

Question, regarding vanilla, does the game technically only have 1 start position? How does it handle competitive MP? At the moment, I'm checking to see if something is outside of the start area with this

Code: Select all

util.distance({0,0}, resource.position) > resource.surface.get_starting_area_radius()
But that makes the assumption of only 1 start point at {0,0}.
Game has one starting position per surface I think. Everything else is handled in lua like in PvP scenario for example.

FuryoftheStars
Smart Inserter
Smart Inserter
Posts: 2483
Joined: Tue Apr 25, 2017 2:01 pm
Contact:

Re: API request :)

Post by FuryoftheStars »

I'm sorry it took me so long... but I've finally tested this and it worked. Thanks!
My Mods: Classic Factorio Basic Oil Processing | Sulfur Production from Oils | Wood to Oil Processing | Infinite Resources - Normal Yield | Tree Saplings (Redux) | Alien Biomes Tweaked | Restrictions on Artificial Tiles

Post Reply

Return to “Resource Spawner Overhaul”