Locomotive implementation feasibility

At some point I’ll be interested in starting to mod this game, specifically I’m interested in introducing locomotives.

I only have experience in Python, not Lua, so I’m wondering what the opinion is of some members of the community more experienced with modding at the implementation of Trains in Stonehearth’s current state just via modifying Jsons and such.

Idea:

Introduce a “rail” which acts just as a modified road.
The roads in vanilla currently give a boost in speed, what I’m wondering is whether or not we can set an entity with a base movement speed that is very low or effectively 0, and have a clause in the new “rail-road” that increases just that entity, or that class of entity’s movement speed by some reasonable amount, thus enabling motion.

I figure in this way, using a reskinned entity form from existing code (with a qubicle made train model with animations), borrowing the code for mounting from the wolves, and introducing + modifying the properties of a special roadtype, we could have effectively what could be a locomotive without having to implement anything ‘new’ in Lua.

Does this seem feasible to people experienced with modding?

1 Like

i believe you will want to take a look at this my good sir,

to my knowledge @RepeatPan actually got a working train, or at least the model for one.

Yeah but looking at that I suspect that guy has some serious experience with Lua.

That looks amazing and would make whatever I try to do likely obsolete, but I’m wondering about the feasibility of this method as a method itself.

It is a fully working train in game train that’s part of a collaborative mod he and I are working on. However the guy is a genius and the implementation is far from trivial. Makes me want to scoop out his brains.

More Chianti Clarice?

4 Likes

Awww, stop it.

Not possible. You won’t get around making some sort of custom movement mechanics. Some kind of “train” concept (moving multiple entities at the same time or rather managing them) is required, too.

Roads are weird. Basically, your basic road is just a replacement (“replace block (-5, 1, 3) grass -> road_cobble”) and telling the terrain (component) “at (-5, 1, 3), scale the speed by factor X”. This is not per-entity, it’s a global kind of thing (for all classes that implement it). Because of the modularity, radiant.terrain.get_movement_speed is only used in one location - but that one is used everywhere.

So you would have to code your own system. From zero. It’s not a good approach in my opinion, however. I mean, it’s a sound idea and all, but you wouldn’t end up with proper trains.

Setting the movement speed to zero will likely cause this area to be ignored, or heavily avoided, by all pathfinding related actions: No AI would walk over those tracks, ever. You would need an own pathfinding, which wouldn’t be too bad, all things considered…


I mean, I do value your effort to create something purely using data. That’s some serious thinking to work around a system like that (a valuable trait that comes in handy often). I just don’t think that you’re going to get far in this case - at the very least, not without some very serious side effects that maybe can be avoided, but doing so will cost you much more time than learning lua and creating a component or two.

I’ve laid out my concept a bit over in the RepeatFeed - but of course, there’s many definitions of “train”. I chose one that I found appropriate. However, you might get some input from there:

3 Likes

I just, quite literally, “lol’d” … I don’t like to lol… refrain from using your humor in the future, lest I be forced to lol once more…

as for locomotives, I say bring um’ on! :train: :train2: :+1:

3 Likes

Thanks for all the information.

This is something I suspected would make this a non-starter.

After I get better with Python (I need it for research), I’ll be able to devote time to getting better at Lua. Unavoidable.

1 Like