Page 1 of 1

API request :)

Posted: Mon Jan 03, 2022 4:49 am
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.

Re: API request :)

Posted: Mon Jan 03, 2022 10:30 pm
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.

Re: API request :)

Posted: Tue Jan 04, 2022 6:47 pm
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.

Re: API request :)

Posted: Tue Jan 04, 2022 9:49 pm
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.

Re: API request :)

Posted: Sat Jan 08, 2022 4:52 pm
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.

Re: API request :)

Posted: Wed Jan 12, 2022 3:53 pm
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}.

Re: API request :)

Posted: Wed Jan 12, 2022 8:29 pm
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.

Re: API request :)

Posted: Thu Apr 07, 2022 9:46 pm
by FuryoftheStars
I'm sorry it took me so long... but I've finally tested this and it worked. Thanks!