Making inserters ignore custom rolling stock

Place to get help with not working mods / modding interface.
Tim_412AO
Burner Inserter
Burner Inserter
Posts: 9
Joined: Fri Jun 15, 2018 4:50 pm
Contact:

Making inserters ignore custom rolling stock

Post by Tim_412AO »

I'm working on a small (but technically complex) mod as my first foray into poking at the guts of this wonderful game. Ideally, I want to have a few new rolling stock extensions that mostly act like the existing specializations, but don't interact with inserters when stopped on track. Looking at the prototypes, I don't see a flag for this behavior on either side, so it doesn't seem like there's an easy solution. My next thought is to extend the entities in a way so that the inserters don't see an inventory, even though there is one. This seems fine for most of the rolling stock, but I think it might be a problem for locomotives when they try to burn a new piece of fuel. Has anyone else messed about with this side of the engine, or do I need to just start poking about at things and see what breaks?
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5211
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Making inserters ignore custom rolling stock

Post by eradicator »

Tim_412AO wrote: My next thought is to extend the entities in a way so that the inserters don't see an inventory, even though there is one.
The factorio mod api does not offer that kind of access. Entity types can not be "bent to do your bidding" so to speak, they are exactly as defined in base. Inserters detect things by collision_box, so as long as their output position doesn't collide with the rolling stocks position they couldn't insert. Though the collision_box is also part of the wagon length and hitbox ofc. Might still work. Not sure why you'd want to break a basic gameplay mechanic like that. But the only other option i see would be a performance eating script that does live-tracking on each inserters in the game.

Protip for the future: Most new modders tend to ask "does this method work" instead of "how do i solve this problem". More experienced modders might know better methods for the same problem ;).
Tim_412AO
Burner Inserter
Burner Inserter
Posts: 9
Joined: Fri Jun 15, 2018 4:50 pm
Contact:

Re: Making inserters ignore custom rolling stock

Post by Tim_412AO »

Thanks for the insightful reply! I'm still getting used to how inflexible factorio is about types.
eradicator wrote:Inserters detect things by collision_box, so as long as their output position doesn't collide with the rolling stocks position they couldn't insert.
Ooooooh, that changes some things... Do you know of any resource on how inserter logic works? The wiki and API seem rather sparse in terms of operational logic (unless I'm looking at the wrong wiki pages). (EDIT: I was looking at the wrong wiki pages)
Protip for the future: Most new modders tend to ask "does this method work" instead of "how do i solve this problem". More experienced modders might know better methods for the same problem ;).
True, and I do want to ask more "how to solve this problem" questions. I just want to do a feasibility check before talking about the overall plan, since I suspect what I'm trying to do would be received with some ridicule until I show that it actually works.
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5211
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Making inserters ignore custom rolling stock

Post by eradicator »

Tim_412AO wrote:I just want to do a feasibility check before talking about the overall plan, since I suspect what I'm trying to do would be received with some ridicule until I show that it actually works.
I'd never do that *coughcough*. I just meant...without knowing what you actually want to do it's very difficult to help. Making the collision box a line instead of a box (i.e. minimal width, normal length) might get you where you want, but no clue what you want, so... ;). Also i've never seen anyone ridicule peoples ideas on the modding help subforum, because most people don't come here i guess, so the worst thing that's going to happen is either being ignored, or experienced modders telling you how utterly impossible to implement your concept is ^^ (totally including me).
Tim_412AO wrote:Thanks for the insightful reply! I'm still getting used to how inflexible factorio is about types.
Well. Factorio has official mod support. As opposed to many other games like minecraft, which doesn't even have an api. So the api nessecarily needs to be build to minimize modders ability to utterly break the game. Or to completely ruin performance, or trigger mountains of wrong bug reports i guess. I've never modded anything but factorio so i don't really know, but as far as i understand in minecraft for example half of modding works by doing binary patching? Which sounds like the most horrible hack ever. And explains why minecraft mods are so horrible for performance and stability.
Tim_412AO
Burner Inserter
Burner Inserter
Posts: 9
Joined: Fri Jun 15, 2018 4:50 pm
Contact:

Re: Making inserters ignore custom rolling stock

Post by Tim_412AO »

I've only got a cursory understanding of minecraft modding, but it's less binary patching and more decompilation, deobfuscation, reobfuscation, and a whole lot of glue layers to make mods play nice with each other. The reason mods are so awful for performance is that the game engine itself is awful and there is not good way to make it do more without major performance hits. Primarily, it's just a mess because the base code was never meant to be the thing it became. As for playing my cards close to my chest, I've seen quite a few terse responses to seemingly reasonable but technically impossible ideas, so I got the impression that experienced modders don't like people asking about such things. Hence I figured I'd try some stuff to show that what I'm trying to do isn't impossible.

Since you seem so interested, my goal is to implement some means by which we can run trains "around" other trains and make proper 4-leaf clover intersections. Initially I thought I could maybe do some stuff like Factorissimo with surfaces, but teleporting trains piecewise across surfaces at speed seems like a dead end. I also considered pulling the same trick that underground belts do, temporarily storing entities that enter and popping them out of the other side, but that seems like a mess to get the pathing and signal behavior correct for automatic trains, let alone manual ones.

My current idea is to instead make phantom tracks and trains for the "underground" section that don't collide with anything, and have the tunnel entrances swap out the rolling stock as they enter and leave, keeping the original train object intact. Making the entities unable to interact with the player is easy enough, and goofing about with the bounding box to keep the inserters form poking at the inventories seems promising. The thing I'm play with in my head now is tricking the rail signals into allowing regular trains to roll through phantom trains. I'm not sure if that's possible though, the rail system seems very rigid and unmodifiable now that I've taken a closer look at it.
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5211
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Making inserters ignore custom rolling stock

Post by eradicator »

All i know about minecraft is from hear-say from a, let's call it controversial, modder, who's also active here (don't want to tell names). And from the constant stream of ERRORWARNINGERROR, that scrolls through the logging console when starting up any major modpack. Especially the latter always gave me the impression that it's not really only the engine that's at fault here. Factorio doesn't do silent error handling, it stops execution on any error it can detect. Which is also thanks to the rigid api i bet.

If by "terse response" you mean "short", that's definetly what i do too. I've been on this forum for a pretty long time (as you can see to the right :p), and as such for most suggestions i've already seen the same thing 10 times over (including this one by you, search for "tunnels" or "underground trains" or something), so maybe you can understand why i don't want to write lengthy explanations every time. Especially if i've already spent lots of time on thinking about possible solutions myself and come to the conclusion that there is no solution that satisfies my standards (also this very thread). So yea...you actually got a much longer response here than if you'd said what you want in the first place :P. Another reason i often write short "Nah, impossible." answers is that i think that's hopefully better than nobody answering at all.

For "trains not colliding with each other" manipulating the collision_mask would probably be a much more promising way. But the main problem remains the pathing algorythm, which you have no write access too. And trains don't care if they *could* drive through another train at a crossing because it *might* not collide with them. The pathing algorythm does not know this and will stop anyway. This is the part where i have no solution for.
Teleporting/swapping also seems to have another problem i saw in a different thread recently where someone tried to implement OTTD style self-reversing trains for terminal stops. The problem he had was that every time you remove/swap a carriage, the train gets a new TrainID, and so fast that he estimated he'd run out of them after a hundret(ish? don't remember exact number) hours of normal play.

Ages ago (0.11? 0.12?) there was actually a "phantom" train mod that had trains that could drive through the factory (assemblers etc) to save space i guess. But i think they were permament phantoms.
Tim_412AO
Burner Inserter
Burner Inserter
Posts: 9
Joined: Fri Jun 15, 2018 4:50 pm
Contact:

Re: Making inserters ignore custom rolling stock

Post by Tim_412AO »

Huh, I had done a search for train tunnels but didn't see anything. Still new to the forums, I'll have to learn how to search them more thoroughly. Apologies for making you write more than you would have needed to.

After spending more time poring over the documentation, I don't see any way to interact with the train routing system at all. Until we have access to that, some way to make new kinds of track, or even just modify the rail connection network I don't see a way to do this. I'll start poking at things in the actual game now, see if there's some hacky workarounds by chance.
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5211
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Making inserters ignore custom rolling stock

Post by eradicator »

Tim_412AO wrote:After spending more time poring over the documentation, I don't see any way to interact with the train routing system at all. Until we have access to that, some way to make new kinds of track, or even just modify the rail connection network I don't see a way to do this. I'll start poking at things in the actual game now, see if there's some hacky workarounds by chance.
Q.E.D. :P
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5211
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Making inserters ignore custom rolling stock

Post by eradicator »

Oh. So just for personal entertainment. On the whole "old modders give short responses". Someone was nice enough to post a great example just now. It fullfills all the criteria: a) has been suggested many times, b) is elaborately detailed in its description, c) the author is new to the forums (6 posts), d) the author seems totally convinced that it's an awesome idea and that he's the first one who thought of it, and e) the idea is nothing short from rewriting the whole game from scratch.
So. Either someone is nice enough and tells him, or the thread is just going to be ignored. Personally i'd prefer to spare him wasting any more time on the idea by telling him "nope". But i'll wait a bit for the experiements sake.
Bilka
Factorio Staff
Factorio Staff
Posts: 3320
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: Making inserters ignore custom rolling stock

Post by Bilka »

eradicator wrote:Oh. So just for personal entertainment. On the whole "old modders give short responses". Someone was nice enough to post a great example just now. It fullfills all the criteria: a) has been suggested many times, b) is elaborately detailed in its description, c) the author is new to the forums (6 posts), d) the author seems totally convinced that it's an awesome idea and that he's the first one who thought of it, and e) the idea is nothing short from rewriting the whole game from scratch.
So. Either someone is nice enough and tells him, or the thread is just going to be ignored. Personally i'd prefer to spare him wasting any more time on the idea by telling him "nope". But i'll wait a bit for the experiements sake.
Heh, I just looked at that thread, typed out an answer, deleted it and closed the thread. I feel like it's not even worth the effort to discuss the possibilities of something like that with someone who doesn't know how the code works. But just saying "nope" feels rude, so many threads like it (eg modding interface requests) often end up unanswered. Unless of course someone who is in the same boat as the OP comes by and reinforces the idea....
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.
Tim_412AO
Burner Inserter
Burner Inserter
Posts: 9
Joined: Fri Jun 15, 2018 4:50 pm
Contact:

Re: Making inserters ignore custom rolling stock

Post by Tim_412AO »

As much as I want to keep the experiment running, I hate ignorance running amok. He's definitely better off building his own game engine...
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5211
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Making inserters ignore custom rolling stock

Post by eradicator »

@Bilka: Thanks for sharing btw. I feel a bit less lonely now that i know i'm not the only one. I don't even want to know how many hours i've spend on typing answers that i never pressed the send button for.
Tim_412AO wrote:As much as I want to keep the experiment running, I hate ignorance running amok. He's definitely better off building his own game engine...
Welcome to the rows of the "naysayers who fail to make constructive comments". To very roughly paraphrase some of the less friendly responses i've seen over the years. ;)

Gotten any progress on your own thing? (/me starts a futile attempt to re-rail the topic)
Tim_412AO
Burner Inserter
Burner Inserter
Posts: 9
Joined: Fri Jun 15, 2018 4:50 pm
Contact:

Re: Making inserters ignore custom rolling stock

Post by Tim_412AO »

No major progress, got distracted by Xterminator's PvP stream and the ensuing PvP balance discussion. My current thought is to try and break the rail connection logic to see how it works and exploit something there. Failing that, I'll probably throw in an API request for rail signal related events if there isn't already a standing request.
User avatar
steinio
Smart Inserter
Smart Inserter
Posts: 2638
Joined: Sat Mar 12, 2016 4:19 pm
Contact:

Re: Making inserters ignore custom rolling stock

Post by steinio »

If you use the LTN stop, you get the rolling stock as a circuit signal.
With this you can only enable specific inserters...
Image

Transport Belt Repair Man

View unread Posts
Tim_412AO
Burner Inserter
Burner Inserter
Posts: 9
Joined: Fri Jun 15, 2018 4:50 pm
Contact:

Re: Making inserters ignore custom rolling stock

Post by Tim_412AO »

I'm trying to see if I can make "phantom trains" that barely interact with the world in order to make underground train "tunnels". LTN doesn't really help, and indeed my current idea (as impossible as it looks right now) would really freak LTN out.
User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: Making inserters ignore custom rolling stock

Post by bobingabout »

Bilka wrote:
eradicator wrote:Oh. So just for personal entertainment. On the whole "old modders give short responses". Someone was nice enough to post a great example just now. It fullfills all the criteria: a) has been suggested many times, b) is elaborately detailed in its description, c) the author is new to the forums (6 posts), d) the author seems totally convinced that it's an awesome idea and that he's the first one who thought of it, and e) the idea is nothing short from rewriting the whole game from scratch.
So. Either someone is nice enough and tells him, or the thread is just going to be ignored. Personally i'd prefer to spare him wasting any more time on the idea by telling him "nope". But i'll wait a bit for the experiements sake.
Heh, I just looked at that thread, typed out an answer, deleted it and closed the thread. I feel like it's not even worth the effort to discuss the possibilities of something like that with someone who doesn't know how the code works. But just saying "nope" feels rude, so many threads like it (eg modding interface requests) often end up unanswered. Unless of course someone who is in the same boat as the OP comes by and reinforces the idea....
I do this a fair bit.

I sometimes post my comment anyway, I mean, I just spent 10 minutes typing it, it would be a shame not to commit it to the internet.

oh well, life goes on.
wait, what is this topic about again?
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.
Tim_412AO
Burner Inserter
Burner Inserter
Posts: 9
Joined: Fri Jun 15, 2018 4:50 pm
Contact:

Re: Making inserters ignore custom rolling stock

Post by Tim_412AO »

The current topic is how we don't have much API access to the rail system and how that makes simulating underground trains hard. I found an old (0.12) mod that just made noclipping trains that acted like normal trains but could run through everything. The point of tunnels, though, is to allow for full-speed crossings and that seems to be the main predicament. I've still not had a chance to see about breaking the rail connection logic, so that's the last possibility beyond asking for write access to rail signal states and some rail signal related events.
Post Reply

Return to “Modding help”