#https://i.gyazo.com/

1 messages · Page 1 of 1 (latest)

harsh nexus
#

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

worldly shuttle
harsh nexus
#

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?

worldly shuttle
#

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

harsh nexus
#

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

Factorio Mod Portal

Reworks crafting promethium science to yield more productivity while traveling further from the solar system edge to the shattered planet. Greater risk should provide greater reward.

#

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

worldly shuttle
#

Yeah of course, I appreciate it!

worldly shuttle
# harsh nexus Wait could you explain that a little bit more? As far as I am aware (as I've sai...

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.

harsh nexus
#

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

worldly shuttle
#

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 RebeccaThumbsUp

harsh nexus
#

Wait yeah that's true. Looking at my code it should function exactly like that, so what was I seeing? đź’€

worldly shuttle
#

I'll take a look at the code and see if I can spot anything

harsh nexus
#

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?

worldly shuttle
harsh nexus
#

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

worldly shuttle
#

Oh the last_visited also counts for passing the planet

#

or location

harsh nexus
#

correct

worldly shuttle
#

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?

harsh nexus
worldly shuttle
#

n/a, retyping

#

ah hit enter too early

harsh nexus
#

rip 🫡

worldly shuttle
#

So the schedule is like

  1. Vulcanus
  2. Solar System Edge
  3. Shattered Planet
  4. Gleba
  5. 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

harsh nexus
#

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?

worldly shuttle
#

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!

harsh nexus
#

Gotcha, I see now

harsh nexus
#

Ok well, I implimented those changes and yeah nah it is still running into the issue. Have you tested it on your end?

#

I tidied it up as well

harsh nexus
#

Something about the negative distances must not be working for me then

harsh nexus
worldly shuttle
#

Ohh lmao, yeah I have tested mine, it works great!

#

Hope it works once you remove that negative number prevention lol

harsh nexus
#

Unsurprisingly it does work great now

worldly shuttle
#

I'm glad we could figure that out :)

harsh nexus
#

Same, because that was the one hurdle keeping me from working on the Sun mod

worldly shuttle
#

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

harsh nexus
#

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

worldly shuttle
#

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

harsh nexus
#

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

worldly shuttle
#

Yeah I noticed that! Didn't know it was also you tho

#

I'm following in the path of my ancestors it seems 🙏

harsh nexus
#

đź’€ 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

worldly shuttle
#

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!

harsh nexus
#

I'm entirely self taught, so I'm sure you're at an advantage here with dos and dont's to coding

worldly shuttle
#

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

harsh nexus
#

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

tranquil jay
#

oh im surprised the platform's distance isn't in the api

worldly shuttle
#

Hopefully they get around to it, would save us some headache calculating the distance ourselves lol

tranquil jay
#

link?

harsh nexus
tranquil jay
#

i might know of a cursed way to detect how far along a platform is trianglepupper

tranquil jay
harsh nexus
#

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

tranquil jay
#

a nice estimation yes

#

beats creating tons of hidden asteroids to use as sensors

#

or reading the platform's circuit stuff

harsh nexus
# tranquil jay 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

tranquil jay
#

I've weaponized circuits for a bunch of mods shoob

harsh nexus
#

I have yet to explore that as it seems like a scary beast to learn. I'm sure it's not bad though

tranquil jay
#

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

harsh nexus
#

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

tranquil jay
#

yea in curious how high the difference would need to be to make an accurate enough measurement with so many decimals

harsh nexus
#

Most certainly is more accurate to just sum up speeds each tick

tranquil jay
#

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 trianglepupper

worldly shuttle
#

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

worldly shuttle
#

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

Factorio Mod Portal

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!

harsh nexus
#

Oh yeah I've heard about that one a while ago. They seem to have a unique spin on it all

tranquil jay
#

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?

harsh nexus
#

@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

worldly shuttle
#

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

harsh nexus
#

I just added this one segment, seems to work well so far

harsh nexus
#

Actually, kidding. That doesn't work as this also counts as the return trip lol. Ignore this

worldly shuttle
#

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

harsh nexus
#

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

tranquil jay
harsh nexus
#

!!!!

#

This is huge

tranquil jay
#

enjoy ChibiHappy
-# wasn't my pull request that got merged tho, so its a general "enjoy" instead of in the "you're welcome" context

harsh nexus
#

@worldly shuttle 2.0.34 is out on experimental, and boy is it amazing

worldly shuttle
#

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 :)

harsh nexus
#

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 trianglepupper

tranquil jay
#

did you not switch the modding api guide website to experimental?

harsh nexus
#

Sure didn't!

tranquil jay
harsh nexus
tranquil jay
#

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

harsh nexus
#

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

tranquil jay
harsh nexus
#

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