# Locomotive implementation feasibility

**URL:** <https://discourse.stonehearth.net/t/locomotive-implementation-feasibility/14249>\
**Category:** Modding\
**Created:** [July 7, 2015, 10:37pm UTC](https://discourse.stonehearth.net/t/locomotive-implementation-feasibility/14249 "2015-07-07T22:37:19Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Doc](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.stonehearth.net/doc/32/2916_2.png) [@Doc](https://discourse.stonehearth.net/u/Doc)\
**Post date:** [July 7, 2015, 10:37pm UTC](https://discourse.stonehearth.net/t/locomotive-implementation-feasibility/14249/1 "2015-07-07T22:37:19Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![8BitCrab](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.stonehearth.net/8bitcrab/32/48512_2.png) [@8BitCrab](https://discourse.stonehearth.net/u/8BitCrab)\
**Post date:** [July 7, 2015, 10:45pm UTC](https://discourse.stonehearth.net/t/locomotive-implementation-feasibility/14249/2 "2015-07-07T22:45:33Z")

</div>

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

> **[REPEATFEED RᴇᴘᴇᴀᴛFᴇᴇᴅ RepeatFeed](http://discourse.stonehearth.net/t/repeatfeed-r-f-repeatfeed/11079/2?u=8bitcrab)**
>
> \#hypetrain

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

---

<div class="post-metadata">

**Author:** ![Doc](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.stonehearth.net/doc/32/2916_2.png) [@Doc](https://discourse.stonehearth.net/u/Doc)\
**Post date:** [July 7, 2015, 10:47pm UTC](https://discourse.stonehearth.net/t/locomotive-implementation-feasibility/14249/3 "2015-07-07T22:47:36Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Froggy](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.stonehearth.net/froggy/32/12576_2.png) [@Froggy](https://discourse.stonehearth.net/u/Froggy)\
**Post date:** [July 7, 2015, 11:08pm UTC](https://discourse.stonehearth.net/t/locomotive-implementation-feasibility/14249/4 "2015-07-07T23:08:47Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![RepeatPan](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.stonehearth.net/repeatpan/32/46418_2.png) [@RepeatPan](https://discourse.stonehearth.net/u/RepeatPan)\
**Post date:** [July 7, 2015, 11:50pm UTC](https://discourse.stonehearth.net/t/locomotive-implementation-feasibility/14249/5 "2015-07-07T23:50:47Z")

</div>

> [@Doc](#):
>
> Yeah but looking at that I suspect that guy has some serious experience with Lua.

Awww, stop it.

> [@Doc](#):
>
> 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.

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.

> [@Doc](#):
>
> 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.

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:

> [@REPEATFEED RᴇᴘᴇᴀᴛFᴇᴇᴅ RepeatFeed](http://discourse.stonehearth.net/t/repeatfeed-r-f-repeatfeed/11079/139):
>
> It’s been some time and I’m sure Discourse will tell you that too by inserting a snarky “1 MONTH LATER” comment right above this post. Let’s get back on track. hohoho. I’ve been paged to this little thread and I’ll write an answer over there as soon as this post is done, because I want to link to this post. Being prepared is everything. Right, so how feasible are locomotives? Pretty. You’ve seen the (Unity3D-made) trailers and some obscure screens. What I haven’t posted up until now was the …

---

<div class="post-metadata">

**Author:** ![SteveAdamo](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.stonehearth.net/steveadamo/32/13955_2.png) [@SteveAdamo](https://discourse.stonehearth.net/u/SteveAdamo)\
**Post date:** [July 8, 2015, 12:04am UTC](https://discourse.stonehearth.net/t/locomotive-implementation-feasibility/14249/6 "2015-07-08T00:04:49Z")

</div>

> [@Froggy](#):
>
> More Chianti Clarice?

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! 🚆 🚆 👍

---

<div class="post-metadata">

**Author:** ![Doc](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.stonehearth.net/doc/32/2916_2.png) [@Doc](https://discourse.stonehearth.net/u/Doc)\
**Post date:** [July 8, 2015, 12:05am UTC](https://discourse.stonehearth.net/t/locomotive-implementation-feasibility/14249/7 "2015-07-08T00:05:52Z")

</div>

Thanks for all the information.

> [@RepeatPan](#):
>
> Because of the modularity, radiant.terrain.get\_movement\_speed is only used in one location - but that one is used everywhere

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.
