#https://i.gyazo.com/
1 messages · Page 1 of 1 (latest)
this is the exact idea I had months ago đź’€ It'll be interesting to see how two different implementations of the same ideas turn out
Oh woah lmao, I was looking through chats to see if anyone else was already making the idea but I must’ve missed it, I can stop if you want btw just let me know!
Nah no need to. I am so surprised that we had the exact same idea. And I mean the EXACT same. I've done some work on mine but it's kind of come to a stand still because of difficulties with determining how close you are to a space location. I don't have the crafting stuff implimented in this mod, but I've done that in another before as practice for this. I do have some stuff that I was debating doing differently, so I am confident that we can both do our own versions. Plus, options are good
I imagine you are finding distances by summing up a platforms speed each tick?
Yeah, exactly! If you pass Vulcanus it ticks into negatives so you can’t just turn around and get “closer” without approaching the sun
And if you’re starting from any other planet, the distance is just 0 since it’s irrelevant, this way it stays accurate enough! It’s not perfectly 1:1 ofc but it doesn’t need to be
Wait could you explain that a little bit more? As far as I am aware (as I've said, I haven't touched this in a while) there is no easy way to figure out the distance from a space location. The way I do it here (https://mods.factorio.com/mod/promethium-crafting-rework) is I think I check the last station, and check the next station it is heading to and then sum up the distances then. This works fine, but has issues with returning, and going past the starting station and then turning back around before it can reach a new station
Btw feel free to ping me about any of this stuff if we wanna try and avoid duplicating ideas lol. I have no issue with it
Yeah of course, I appreciate it!
Okay so I have three checks and the only path to the sun is vulcanus -> sun
I check the active station on the schedule and the last_visited_space_location from the platform.
If you're traveling to the sun and your previous planet is vulcanus, then add the platform's speed to "distance_to_sun"
If you're traveling to any planet other than the sun and your previous planet is vulcanus, subtract the platform's speed from "distance_to_sun"
If you're traveling to the sun and your previous planet isn't vulcanus, then "distance_to_sun" is 0.
This eliminates the problem of your crafting rework because if you travel to Aquilo and then turn around, you'd be ticking up from roughly -30,000
You need the third check though, because theoretically you could do laps on other planets and if you're not traveling to the target planet, it'll just go to really low negative numbers.
See I believe that is how I do it as well (if I understand my own code correctly), but still it does have that issue. For this case, it would be like your platform left Vulcanus towards the Sun, and then of course turns back to Vulcanus. It passes Vulcanus to Nauvis but doesn't make it all the way before turning around (player intervention, or interrupt). Here, the game sees the last_visited_space_location = Vulcanus, and the current destination is the Sun (if you are going off of the platforms schedule, it doesn't read the locations in between).
That would mean that it's ticking up the distance, despite not actually even being past Vulcanus yet
If your implementation doesn't have that issue then hell yeah, but I believe that you may face the same problem
Yes it does tick up the distance! But the value at that point would be negative.
Let me give an example, you start at Vulcanus and the distance_to_sun is 0. If you start heading towards the sun, you meet the conditions active = "sun" and prev_planet = "vulcanus" so you tick up, you go around 10k km so distance_to_sun is 10,000
If you turn around and head to Nauvis, now the active = "nauvis" and prev_planet = "vulcanus" so it ticks down, once you reach Vulcanus the distance_to_sun is 0, when you get near Nauvis it'll be around -14,000.
Now if you turn around and head to the sun, active = "sun" and prev_planet = "vulcanus" it ticks up from -14,000, so by the time you reach vulcanus, distance_to_sun will be around 0.
@harsh nexus Meant to reply, so just @ing you 
Wait yeah that's true. Looking at my code it should function exactly like that, so what was I seeing? đź’€
I'll take a look at the code and see if I can spot anything
Here is the little snippet responsible for me. From what I can tell, it should function how you described. Maybe I had just an odd edge case?
I'm not sure what the last_station_index is, but mine just checks the current and the last_visited, if the current isn't the sun, then it's not heading towards the sun
I think I did that because the solar system edge never actually gets visited, and so it will never be the last_visited location. the last_station_index is just a workaround to that
correct
I'm guessing last station index is the current-1?
So if you pick a location that's not the next in line, I don't think that will activate?
You'd be exactly right.
what do you mean?
rip 🫡
So the schedule is like
- Vulcanus
- Solar System Edge
- Shattered Planet
- Gleba
- Fulgora
and you're heading to the shattered planet, so last_station_index is solar system edge, but if you pick Fulgora, you'll head back, but the last_station_index is Gleba, so it won't decrement
Well, I can actually test that real quick. I am rusty on this stuff.
In the mean time, how are you defining what your next_planet is?
It's just the active record in the schedule, since you can't move the platform without picking from the schedule
next_planet = platform.schedule.records[platform.schedule.current].station
Try just doing your current ~= shattered-planet and see if it works!
Gotcha, I see now
Ok well, I implimented those changes and yeah nah it is still running into the issue. Have you tested it on your end?
It was headed to Gleba when I clicked back on the shattered planet.
I tidied it up as well
In this case, the last_planet would still be solar-system-edge as it hasn't reached Gleba, or even Aquilo or anything else yet. And the next_planet would then be shattered-planet assuming it is interrupted. Thus, it thinks it is heading out (which it is) too early
Something about the negative distances must not be working for me then
Oh wait I forgot to remove a chunk of code I had in place specifically to prevent negative numbers lmao.
Ohh lmao, yeah I have tested mine, it works great!
Hope it works once you remove that negative number prevention lol
Unsurprisingly it does work great now
I'm glad we could figure that out :)
Same, because that was the one hurdle keeping me from working on the Sun mod
Currently I'm trying to use the beacon-interface mod to change it up because right now I'm directly modifying the crafting progress, but because of that there's no obvious indicator (like the crafting speed percentage) and doesn't allow for more than 1 pack per tick
plus experience working with dependencies :)
If you work more on your sun mod, let me know! We can talk about our methods
Funnily enough, I am also drawing inspiration from that mod and making a minor tweak to mine (in the name of performance). Otherwise, it should function the same/exactly how we need. Feel free to draw inspiration from mine as well, although I know it kind of ballooned a bit. My sun mod will def allow me to be neater about this
Yeah of course :) I actually saw your prometheum science rework mod awhile ago and was like "Okay if I struggle to get my distance tracking working, I can look at theirs and get a basic one going until they update the api to include distance" lol
I did put in an api request a while ago for distances. They say it's something they'd like to add but its lower priority
Yeah I noticed that! Didn't know it was also you tho
I'm following in the path of my ancestors it seems 🙏
đź’€ Lot's of cool things that can be done with this mechanic. I've got my own personal little library mod (mostly for learning), but I'm debating making my own little api for this invisible beacon mechanic (mostly for learning again) seeing how often I use it
I did use this mechanic before 2.0 to mimic the prod research, but that was an unoptimzied mess. Learned a lot
Ayy that's awesome! I've known about Factorio for a long time but I didn't get super into until the 2.0 update, and with being a CS student I'm like, I GOTTA make mods now don't I lmao. Still learning a lot myself!
I'm entirely self taught, so I'm sure you're at an advantage here with dos and dont's to coding
Oh that's impressive! You're doing great it looks like :), yeah I'm 3 years into my CS program, but I also did some programming for fun and slightly academic during high school as well, still always learning though of course
Well I do have python experience, so it's not like coding is entirely unfamiliar. But I've never had to optimize things until I started modding
oh im surprised the platform's distance isn't in the api
Yeah same! They responded to Bunshaman's api request and they said it's possible, but it hasn't been implemented yet
Hopefully they get around to it, would save us some headache calculating the distance ourselves lol
link?
Hello, I think this would be fantastic because as of right now, the only way of obtaining the distance a platform has traveled is by summing up a platforms s…
i might know of a cursed way to detect how far along a platform is 
sounds like writing is what's holding it back, I'll try to dig around to see if i can get reading to work at least
We do have a somewhat cursed way of detecting it. We can read a platforms speed, and so each tick we just sum it up
Works very well actually
a nice estimation yes
beats creating tons of hidden asteroids to use as sensors
or reading the platform's circuit stuff
I almost went this route for something else, but it would've been a pain to learn how to spawn an invisible entity with a circuit condition so that the circuit stuff of the platform couldn't be turned off. Much less the fact that the signals can be read or not depending on what a player wants
I've weaponized circuits for a bunch of mods 
I have yet to explore that as it seems like a scary beast to learn. I'm sure it's not bad though
oh its easy peasy
the hardest part is making sure players can't break or abuse it
by like connecting their own wire and sending signals or changing configs
like in the case of platforms i dont really see something in my bag of tricks to do it properly, easiest would just be to get read access
some parts of the modding api can be worked around but in this case it's pretty tough
though i wonder if you set the solar power in space at the shattered planet a little higher if you can accurately use the minuscule decimal difference to determine the position đź‘€
in theory it should work i suppose
That is clever, although if I'd wanna maintain the vanilla feeling of solar being useless out there, I'd have to work with really small numbers. I wonder how accurate that could be
Especially over such a long distance
yea in curious how high the difference would need to be to make an accurate enough measurement with so many decimals
Most certainly is more accurate to just sum up speeds each tick
thought honestly if the shattered planet is brighter who would really care, getting there is the hard part so once your 30 million something out you've earned your 10% of solar power 
I was actually looking into that, but I couldn't find out how to read the solar power level on a space platform. It's very easy to read it from the space location, but couldn't figure it out for the platforms
in case anyone goes to check, solar_power_multiplier is not the solar power percentage of a surface, that's a separate thing you can add to a surface
I was looking more into it because I was like "Surely SOMEONE had made a sun mod" and I found one for making a dyson sphere https://mods.factorio.com/mod/slp-dyson-sphere-reworked
Who needs a fusion reactor when you have the whole sun? Steer the starship directly into its orbit and channel an incredible amount of energy where you need it with new technologies. The main thing is not to forget to leave the ship before departure! Make dyson sphere near star and forget about other energy sources in planets and in space!
Oh yeah I've heard about that one a while ago. They seem to have a unique spin on it all
hmm, would the real distance make most sense to get from the api, or the 0-1 range, that you then have to check against the connection distance from the prototype?
@worldly shuttle Interesting behavior; When you have some stations (say, vulcanus) with a wait condition like 1 second, when a platform is waiting there it's next_planet is the planet it is currently stopped at, as well as it's last_planet. I believe with your logic and how it's coded for you, then this will start counting down the distance. Might not mean much if a platform waits for a while, but there is a brief moment where a platform is "at" a station, but still slowing down
Oh yeah that's very true, I didn't think of that! That's perfectly fine with my stuff for now since the goal is just to be near the sun so I just need a rough approximation
I could add a check where I read the platform's state and distance is only calculated when the state is on_the_path, so only when it's actively moving towards it's destination
I just added this one segment, seems to work well so far
Actually, kidding. That doesn't work as this also counts as the return trip lol. Ignore this
You can add a statement that sets the distance to 0 if the state of the platform is waiting
Or make it only increment if the state is moving on path
Exactly what I ended up doing
I'm liking how it's shaping up. In a real game a platform should die before it gets there, but I'm liking how this looks
Hello, I think this would be fantastic because as of right now, the only way of obtaining the distance a platform has traveled is by summing up a platforms s…
enjoy 
-# wasn't my pull request that got merged tho, so its a general "enjoy" instead of in the "you're welcome" context
@worldly shuttle 2.0.34 is out on experimental, and boy is it amazing
ooo?
OORAHHHH
I'll have to get back on the grind working on this mod at some point, I got roped into my other fascination (binding books) cause a ton of stuff I ordered months ago came in :)
I can tell you already, this simplifies things greatly
Given the lack of documentation for it just now being out, I've noticed that the distance is a float from 0 to 1, where it ranges from 0 being close to the "from" location in the space_connection, and 1 being the "to" location
I was able to cut the code in half or so 
but it is properly documented
did you not switch the modding api guide website to experimental?
Sure didn't!

79 lines down to 44 to do what I need, hallejujah
the notable implementation quirk is the to & from are on the one directional space connection prototype, so going in reverse might feel like getting the opposite number
Which was the first thing I checked. It doesn't work like that thankfully, so going towards a location and then turning around halfway through will have a neat triangle looking shape to a graph of the distance rather than a sawtooth
still quite a lot of lines tho
Yeah I know for a fact the real number is smaller. I counted empty lines for both (I like readability, so I have a lot of empty lines) and I am seeing some stuff I can do to further reduce that