REPEATFEED RᴇᴘᴇᴀᴛFᴇᴇᴅ RepeatFeed

when i see how some items work, i think that there should be a function that would put together items that have less than full stack size, like wood and stone that goes like crazy when building. (sorry if you can’t understand, bad english, trying to polish it a little)

2 Likes

I was actually writing walls of text here before Discourse seemingly decided that, for once, it doesn’t want to save the text. Oh well, bummer. I’ll not document the parts then in detail, just brief:

Building a better inventory system: Part 1, current status

There’s a few components involved:

  • The stonehearth:stockpile entity is, well, a stockpile. It’s raison d’être is, by and large, to hold the stonehearth:stockpile component.
  • The stonehearth:stockpile component does most of the job: Managing what can be stocked into a stockpile, creating the tasks that force workers to restock stockpiles, what items are in which stockpile and a bit more.
  • The AI actions regarding stockpiles (see an earlier post) that are responsible for the restocking. Note that additional actions are involved, such as the backpack stuff.
  • The inventory service of Stonehearth (or rather, one of its instances) that keeps track of player items.

What we need to do now, basically, is finding something that can replace the stonehearth:stockpile component with something a little more generic. In addition, stockpiles ought to be harmless, i.e. we’ll make sure that they won’t launch any more worker tasks (our inventory service will take care of that). To do that, the inventory service needs to be extended.

So, first task: Creating outvetory:storage, a component that is (generally) responsible for holding some stuff, but abstract. This can be a stockpile, or a barrel (in Minecraft sense: One entity holding a lot of the same entities), or a chest. It’s the idea of a stockpile, an idea that can be expanded.

6 Likes

Continuing from Part 1 (which got submitted way too early).

Well, there’s the first step:

  • Right from the start, a somewhat boring outvert:storage component has been created. Its purpose, right now, is to simply exist. It will be expanded later on with functions that are required for its task, such as adding items, removing items, finding an item, getting a list of items inside… But for now, it has a few, very necessary functions which are all not implemented.
  • I’ve added the normal stockpile code (washed with my custom lunadry) with one major change: The stockpile does not plan tasks anymore. This leads to stockpiles, for the time being, effectively useless… Unless you happen to place them right where the items are.
  • A little server init file patches the “normal” stockpile component with my new one. We’ll have lots of fun with that function, I can already see it, I’m afraid.
6 Likes

Continuing from Part 1, still:

This is a rather huge commit, but there’s lots to it.

On one hand, I’ve documented the entire stockpile component (which at this point, is still mostly the vanilla one). On the other, I’ve fixed (by discovering it by accident) a bug that may cause stockpiles to “forget” a slot. Lastly, I’ve refactored some code to what I consider “cleaner” code, such as taking shortcuts where possible (i.e. if something then --[[ huge block ]] end to if not something then return end --[[ huge block ]]), including a little fix that should make creating stockpiles a lot faster if on a map with lots of entities. Hopefully, at least!


Let’s talk a bit about the structure of things. Ideally, I would define an interface and stockpiles would just inherit it, but Stonehearth doesn’t support interfaces, so we have to work around that a bit.

The storage component has grown a little bit and can now redirect calls to another component, in this case, the (“vanilla”) stockpile component. The idea is that the inventory service, and the AI to some extent, can simply interact with the storage component, which will then delegate stuff to the “sub component”, or implementation component. So basically, we will have a hierarchy; a stockpile will delegate its calls to a stockpile component, while a chest might delegate it to a chest component. Portals will delegate it to the portal component, which will just accept any item and swoosh it around a bit.

However, it’s impossible to redirect everything, so I’ll have to mess around with the stockpile functionality a bit too. That’s not too bad, because I’m overriding it anyway. The kind of deal breaker is the dependency that’s going on: Lots of places require stuff from stockpiles specifically, starting with every single AI action there ever was (approximately).

So there will be lots of refactoring, probably in lots of different places. In the best case, I can somehow redirect the current calls to the new inventory manager, or just replace the places where it’s used.

But I think I’m on a good path so far.

8 Likes

The next step would be to modify how restocking works.

The very simple version of the current implementation is that stockpiles schedule a task whenever they have free slots. This task searches for available items, reserves a slot, and then takes the item to said slot. When the stockpile is full, the task is destroyed - and as soon as there’s space again, the task is re-created.

The new implementation would work the opposite way (the one that is more “logical” for us). Whenever an item is dropped, all storages (for now, only stockpiles) are checked if they can stock this item. For the first iteration, if there is a stockpile, a new task is arranged that takes the entity to the storage. So we don’t have to look for anything really, we know the stockpile and the entity.

Sounds simple enough, but not quite. I’m currently a bit too distracted to do proper research on the AI and task system…

That being said, I’ve pushed a new change that changes the way the AI works. The inventory service now sends workers to pick up item X and put it into stockpile Y. There’s no advanced heuristics yet and the task isn’t cancelled, so the item will be placed again and again and again…

But it kind of “proves” that the concept could work. The inventory service now successfully dispatches workers and routes items, even though it’s only after a fashion.

3 Likes

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 original video that I’ve sent to Tom the same day I’ve opened this thread, in fact. So here it is, For Tom With Love:

It’s a simple video showing three stages: Arrival, unloading, departure. The train arrives, is unloaded by workers, and then departs again. Both arrival and departure are currently triggered by console commands, but are also wired to (daily) timers. Let’s talk about structure.

Railroad Service

The core of the whole operation is the railroad service, responsible for about everything. At the beginning, only straight lines will be possible. Tunnels and bridges are supposed to be there, but curves are a bit difficult. The main issue with curves is, well, there’s no “round” thing, so trains themselves can’t really go around curves. It would look odd. Of course, this can be avoided by having huge curve radii, but that’s also odd. Plus, having a single, straight line makes things much easier.

Building the tracks

You can tell him “Build me a railroad starting at (X, Y, Z)” and it will build tracks properly until it runs out of map. In this example map, I’ve artificially added “more” to the map to get a better view of the arrival/departure process.

In the future, the service would also build bridges and dig tunnels. In an even further future, it wouldn’t just do it, but rather hand out tasks to an AI to do it.

Managing the trains

Trains are spawned by the service, currently one at a time. Trains can spawn at any side of the railway driving towards the opposite end. They’re spawned properly (i.e. no cart is “off the rails”) and they’re despawned properly (upon reaching the edge) so it doesn’t look “odd”.

Each train consists of one locomotive, one tender cart and a random amount of other carts. In the video above, only one type of cart is used, the open goods cart - there are multiple, including the passenger cart seen in the previous videos. This cart is special as it has goods loaded that can be unloaded. These can be locked however, so only certain goods can be unloaded - the others are only decoration (as of now).

Once the train has been created, it’s schedule is set (see below). This is adjusted so the locomotive precisely always stops at the same location.

The train component

The heart of the whole deal, the train component is stuck to an invisible entity that represents the train. This component is responsible for moving it and therefore keeps track of direction, velocity and acceleration. It also has a schedule, which contains orders in the form of “X meters into the track, do Y” - for example, “break with 1 m/s after 150m”. The schedule is usually set by the railroad service. The train component itself does nothing except respawning, all input comes from the outside.

The cart component

A rather simple component whose only real purpose is to tag along and make some neat collision boxes.

The goods cart component

More interesting, the goods cart component can load goods. The railroad service (or whatever is “filling” them) tells them what they should load (and where) and they’ll make sure the entity is kept there. Currently, this means they’re just creating the entity at said location.

Entities can then be unlocked after the train has stopped, becoming available to the player. In this case, the cart acts pretty much like a stockpile. So it’s possible to say “I want log #3 on cart #5 to become available to the player” over the API.


Tie that up with some AI tasks and that’s what you get. It’s not that difficult because trains themselves aren’t too complicated (at least, in theory). There’s some issues unsolved however:

  • Putting items on a cart is a bit more complicated than putting them on. Because that’s tied to the inventory stuff and they’re doing a rewrite of that just now, I’ve put that on hold.
  • Animations are a pain. Especially because there is currently little to no API available, all animations need to be synchronised with the velocity/acceleration the train is currently going at. It’s not (really) possible to just say “Alright, move the animation to frame X”. At least, I didn’t stumble across a way to do that.
  • Stonehearth, in its current state, is not big enough to warrant more than one train station, so the only real train destinations are all fictive (or “AI”, depending on your point of view).
  • The whole thing still has a few concept flaws.
16 Likes

Awesome train! Love that they pick it up when arriving at the station.

3 Likes

Do you plan on release this as a mod anytime in the future?

2 Likes

the invention of the wheel… internal plumbing… sliced bread…

all pale in comparison to this… chooochoooooooo!! :smile: :+1:

6 Likes

Nope. Not until beta at the earliest

3 Likes

Any ideas on the sounds for the mod? I personally want to get into sound mixing myself, but I’m still in an early understanding of it.

3 Likes

We’re looking into a variety of choo, huffs and puffs, toot toot, toooeeeoooot, eeeeeeek and pouff. That aside, we haven’t really settled for any sounds.

SFX is hard. I think nobody in our current setup has any real experience with it. It’s something that’s filed as “Extremely important and really required, but not achievable at the moment and therefore delayed”.

11 Likes

Since that started happening, it’s always annoyed me. I already know when the last comment was written due to Discourse’s formula, and if it’s happened a while ago, Discourse won’t give me the exact date or days ago, so it doesn’t care, so I don’t care, so I don’t need to know what exact span of time has passed. And if it has happened recently, I can very well calculate the span of time myself if I really wanted to, but I don’t need to because I don’t care.

I was going to say something important before I started this rant, but now I don’t remember. Uh, nice train, I guess?

2 Likes

Cursor over those text fields will reveal the proper date in a rather stupid formatting though. I’ve made a UserJS that forces Discourse to use the normal European 24h date format, which is so much nicer:

Working with the most recent version of Stonehearth is incredibly infuriating. In Zulser, items transported by conveyor belts suddenly turn invisible once they’re unwrapped from their “conveyor container”. In the train mod, items are suddenly falling through the waggons again - something that I’ve managed to get under control a long while ago after hours and hours of testing and adjusting numbers.

I think it’s time for a longer break from modding Stonehearth. I think I’ve finally reached the boundaries of what is possible, in terms of whatever I want to do now is simply not doable with the current state of the API/documentation/support. At least, not without tremendous effort that just cannot be justified.

In other news, I would like to share the most intense YouTube video you’ve probably seen all week. Don’t judge it merely by the thumbnail. As a disclaimer, contains flashing lights. A lot.

5 Likes

Wow, that was pretty intense.

I hope you return to modding someday and continue to do amazing things. Good luck!

5 Likes

Whoever finds an appropriate name for this show will receive exactly 1 (one) like from me on the post stating said submission.

3 Likes

The Twilight show…

2 Likes

I did try to keep it as a surprise, but as I’m struggling to find a proper soundtrack I thought I might as well try this “crowd source” thing.

For no particular reason whatsoever, I’m looking for a 70s disco themed song. I have a few in mind, but can’t use them due to copyright and/or unsuitable lyrics.

Some music pieces that I think would fit/are heading in the right direction:

I’ve tried a bunch of search engines (most of those listed on the CC site) but couldn’t come up with anything decent. Apparently “Disco” nowadays either means “hardcore dubstep trancemix metal techno” or “Here’s a remix of the 15600 best Disco songs from the 70s!”.

So if any of you happens to know a soundtrack which aims in that direction and that is free to use in public (public domain, almost any Creative Commons license or similar), at least on YouTube and ideally for re-distribution too, leave a reply here or shoot me a PM.

If someone finds something that I can work with, I’ll pursue this project further. Otherwise, it’s dead before it even begun, kind of.

Why is it so hard to find music talent. Seriously, it’s nearly impossible to walk three meters on the internet without stumbling over three web designers, two graphical artists and twenty programmers. But any reasonable musician?

3 Likes

DISCO: Dubstep Is So Cool, Oh yeah!


I'm usually a big fan of Kevin MacLeod's music - most of it is licensed under CC By 3.0. One downside: some of it does show up on YouTube quite a lot to the point where I can recognize it. That doesn't seem to be as much of a problem with his "Disco" collection. But it may still be too

[quote=“RepeatPan, post:152, topic:11079”]
“hardcore dubstep trancemix metal techno” or “Here’s a remix of the 15600 best Disco songs from the 70s!”.
[/quote]for you. You’ll just have to see.

1 Like