Looking for Ideas for a Smelting System (Like Stardew Valley/Minecraft)

Hi folks,

I'm looking to add a smelting system to my game, and am not too sure what the best way is to do it.

I would like to have a system where you place an item into an event (using Select Item), then it runs for a while with a little animation, and when it is done, you can interact with it again to collect the items.

I was hoping there would be a plugin out there to do something like this, but I can't seem to find one.

My current plan, since my game has a time system, would be to:
- Select the item
- If it is suitable, change self switch to a new state with the smelting animation, and run a smelting common event via switch.
- The common event would record the starting time to a variable, then run as a parallel process checking every 120 frames or so to see if the current time is >= the (starting time + smelting duration for that item). If it is, it changes the smelter to a complete stage.
- When the player interacts with the smelter in the complete stage, it gives the proper smelted items based on what was put in, and then reverts to its initial state.

This system has a big problem though - I would need many duplicate common events for every possible smelter to do this, and I intend to allow the player to make many smelters. Each smelter would need its own separate parallel common event so that it can still update while on other maps, and it would need to know which common event is dedicated to it specifically (or which common event is free).
I can get around the redundant variables needed with a self-variable plugin, and I can re-use the switch that initiates the common event, but if the player can place 50 smelters, I need 50 separate parallel events, as I can't just keep re-running the same one, as far as I know.

Does anyone have any ideas for a way to implement this? Has anyone done it before?

If I intended to stay on the same map, I would just give the event a page with a parallel event, but I need it to keep updating while the player does other things and leaves the map.

All I need is to add item + fuel to an event, and have that event update its self-switch after X time has passed even while on other maps.

Thanks!
Hi folks,

I'm looking to add a smelting system to my game, and am not too sure what the best way is to do it.

I would like to have a system where you place an item into an event (using Select Item), then it runs for a while with a little animation, and when it is done, you can interact with it again to collect the items.

I was hoping there would be a plugin out there to do something like this, but I can't seem to find one.

My current plan, since my game has a time system, would be to:
- Select the item
- If it is suitable, change self switch to a new state with the smelting animation, and run a smelting common event via switch.
- The common event would record the starting time to a variable, then run as a parallel process checking every 120 frames or so to see if the current time is >= the (starting time + smelting duration for that item). If it is, it changes the smelter to a complete stage.
- When the player interacts with the smelter in the complete stage, it gives the proper smelted items based on what was put in, and then reverts to its initial state.

This system has a big problem though - I would need many duplicate common events for every possible smelter to do this, and I intend to allow the player to make many smelters. Each smelter would need its own separate parallel common event so that it can still update while on other maps, and it would need to know which common event is dedicated to it specifically (or which common event is free).
I can get around the redundant variables needed with a self-variable plugin, and I can re-use the switch that initiates the common event, but if the player can place 50 smelters, I need 50 separate parallel events, as I can't just keep re-running the same one, as far as I know.

Does anyone have any ideas for a way to implement this? Has anyone done it before?

If I intended to stay on the same map, I would just give the event a page with a parallel event, but I need it to keep updating while the player does other things and leaves the map.

All I need is to add item + fuel to an event, and have that event update its self-switch after X time has passed even while on other maps.

Thank
when you find out please be sure to share with me cheers
I had a similar problem when I wanted a lot of plants to grow off screen. My workaround is instead of running the process while elsewhere, I just keep track of how much time passes while elsewhere and then run it all at once when returning to the appropriate area.

Since you already have a time system you could likely bake it into there. The way I do it is having a 'plant growth' variable running at all times, and when that reaches 800 in my case the growth progresses. It works on the map, and it stores up while elsewhere.

It may introduce a moment of lag while it resolves this when entering the map, some clever math could get around that depending on how your stuff works.
I had a similar problem when I wanted a lot of plants to grow off screen. My workaround is instead of running the process while elsewhere, I just keep track of how much time passes while elsewhere and then run it all at once when returning to the appropriate area.

Since you already have a time system you could likely bake it into there. The way I do it is having a 'plant growth' variable running at all times, and when that reaches 800 in my case the growth progresses. It works on the map, and it stores up while elsewhere.

It may introduce a moment of lag while it resolves this when entering the map, some clever math could get around that depending on how your stuff works.

Are you doing this with a growth variable for every plant?

I do have a full farming system implemented already, with crop plots that update at midnight every night and update their events both at midnight and map load, however the same system wont work for smelters as they can all have different starting and ending times, and work on a smaller scale (easier to update 200 crop plots once per day, but harder to update 20 different smelters that all started at different times, and need to finish by different times on that same day).
Are you doing this with a growth variable for every plant?

I do have a full farming system implemented already, with crop plots that update at midnight every night and update their events both at midnight and map load, however the same system wont work for smelters as they can all have different starting and ending times, and work on a smaller scale (easier to update 200 crop plots once per day, but harder to update 20 different smelters that all started at different times, and need to finish by different times on that same day).
No just 1 variable, and self switches to control what stage of growth they're at. If there's few enough stages of smelting that could work there too, or a plugin to give more self switches if not.
Isn't this basically a resource spawning system, just with the event timer triggered by the user? I don't see why Trihan's script wouldn't work

No just 1 variable, and self switches to control what stage of growth they're at. If there's few enough stages of smelting that could work there too, or a plugin to give more self switches if not.

Hmm, yeah I see what you're saying.

I'm using a self variables plugin, so I essentially have unlimited self switches.

I could store the starting time and smelting item for the smelter in self-variables, then have a global process that runs once every in-game hour, comparing each smelter ID's saved starting time to the current time, then add an amount of time based on the smelted item to find the "finish" time. If it is greater than the current time, update its self-variable to change to the finished state.

Isn't this basically a resource spawning system, just with the event timer triggered by the user? I don't see why Trihan's script wouldn't work


This is pretty interesting. I do already have a time system that is always running, so I can probably simplify this quite a bit to fit my project. I will have to play around with these ideas!


I have a plugin installed that lets me auto-run a common event whenever a specific variable changes. Since my game time is stored in variables, I could potentially run a common event every time the minute (or maybe hour to reduce lag) changes which checks if any of my building plots are smelter states that are actively smelting, and if so, runs the check to see if they should be done.

This might actually be the simplest way to do it. Hmmm....
I had a similar problem when I wanted a lot of plants to grow off screen. My workaround is instead of running the process while elsewhere, I just keep track of how much time passes while elsewhere and then run it all at once when returning to the appropriate area.

Since you already have a time system you could likely bake it into there. The way I do it is having a 'plant growth' variable running at all times, and when that reaches 800 in my case the growth progresses. It works on the map, and it stores up while elsewhere.

It may introduce a moment of lag while it resolves this when entering the map, some clever math could get around that depending on how your stuff works.
I do something like this with a large product DB in the day job. I have to have things talk back and forth, but I don't want to check everyone each time, so I run queries against the time since we last talked. If the timestamp is less than or equal to now - 5 minutes, its been too long since we "talked", so its a candidate. We update that "last talked" timestamp to now, compare info, and move on. On the next run of queries, that one doesn't come up because we "talked" within the last 5 minutes.

So what you would do is run a script to mark the current timestamp to one of your event variables when you set it up. This becomes a "initial time" variable. When you return, check the "initial time" timestamp against the time it takes to smelt that item. If the "initial time" timestamp + timer value is equal to or less than the current timestamp, you've met or exceeded the time to process and its good. If it is greater than, you still have time to go. No need to run things all the time, just when you actually do something like load a map, check the thing, etc.
Now, a parallel event on the screen can update things in real time. So say you're growing crops, you can "see" the crop pop into its next stage, otherwise without that it would only do something when you manually check the event/item. The event itself can be the parallel; your page 1 contains the initiator code and runs as a player action initiated event, throws self switch A as a part of its process. Page 2, with SS A thrown, runs as parallel event checking that initial timestamp + wait time against the current time. If the current time meets or exceeds that value, throw self switch B. Page 3, with SSB thrown, is your product (or even another stage).
I do something like this with a large product DB in the day job. I have to have things talk back and forth, but I don't want to check everyone each time, so I run queries against the time since we last talked. If the timestamp is less than or equal to now - 5 minutes, its been too long since we "talked", so its a candidate. We update that "last talked" timestamp to now, compare info, and move on. On the next run of queries, that one doesn't come up because we "talked" within the last 5 minutes.

So what you would do is run a script to mark the current timestamp to one of your event variables when you set it up. This becomes a "initial time" variable. When you return, check the "initial time" timestamp against the time it takes to smelt that item. If the "initial time" timestamp + timer value is equal to or less than the current timestamp, you've met or exceeded the time to process and its good. If it is greater than, you still have time to go. No need to run things all the time, just when you actually do something like load a map, check the thing, etc.
Now, a parallel event on the screen can update things in real time. So say you're growing crops, you can "see" the crop pop into its next stage, otherwise without that it would only do something when you manually check the event/item. The event itself can be the parallel; your page 1 contains the initiator code and runs as a player action initiated event, throws self switch A as a part of its process. Page 2, with SS A thrown, runs as parallel event checking that initial timestamp + wait time against the current time. If the current time meets or exceeds that value, throw self switch B. Page 3, with SSB thrown, is your product (or even another stage).

This is a good solution for a light-weight version of this. The only reason I couldn't do it this way is because I do want to have separate animations that play when event is processing the item, so I need it to update to the finished stage (changing the animation) as soon as it is done processing.

This approach is similar to what I plan to do, though. There will be an event that runs every in-game hour, and checks the recorded "finish time" for each of the processing events. If the current time is >= the finish time, update its switch to change the event page.
This is a good solution for a light-weight version of this. The only reason I couldn't do it this way is because I do want to have separate animations that play when event is processing the item, so I need it to update to the finished stage (changing the animation) as soon as it is done processing.

This approach is similar to what I plan to do, though. There will be an event that runs every in-game hour, and checks the recorded "finish time" for each of the processing events. If the current time is >= the finish time, update its switch to change the event page.
Nope. Not necessary. That's what I was saying about the event being its own parallel.

So, back to the example; you have your Blacksmith breaking things down for instance.
On neutral/initial, Page 1, he's standing there with a toe-tapping animation or something. Speak with him, initiate the process, set the initial time, set self-switch A.
Page 2, with SSA on, shows the blacksmith hammering away. Runs as a parallel event itself, constantly checking the initial timestamp + phase 1 against "now." When it reaches the point where now is greater than timestamp + phase 1, it it kicks off self-switch B.
Page 3, with SSB on, shows the blacksmith pushing the bellows. Also runs as a parallel event, constantly checking the initial timestamp + phase 2 against "now". When it reaches that same point, now is greater than timestamp + phase 2, kick self switch C.
Page 4, with SSC on, shows the blacksmith wiping his brow; for giggles lets say this is the end step. So this is an action initiated event, and when you talk to him you have your dialogue, he hands over the parts, and kicks the self-switches off, resetting everything to Page 1, when you can give him another assignment.

As a parallel event, when you re-enter the map after being away, it will go through the process all at once. If you NEVER returned you might see the Blacksmith pop through animation 2 and 3 as it processes that before settling on the page 4 animation, but that's the worst I can think of running it through in my head.
Nope. Not necessary. That's what I was saying about the event being its own parallel.

So, back to the example; you have your Blacksmith breaking things down for instance.
On neutral/initial, Page 1, he's standing there with a toe-tapping animation or something. Speak with him, initiate the process, set the initial time, set self-switch A.
Page 2, with SSA on, shows the blacksmith hammering away. Runs as a parallel event itself, constantly checking the initial timestamp + phase 1 against "now." When it reaches the point where now is greater than timestamp + phase 1, it it kicks off self-switch B.
Page 3, with SSB on, shows the blacksmith pushing the bellows. Also runs as a parallel event, constantly checking the initial timestamp + phase 2 against "now". When it reaches that same point, now is greater than timestamp + phase 2, kick self switch C.
Page 4, with SSC on, shows the blacksmith wiping his brow; for giggles lets say this is the end step. So this is an action initiated event, and when you talk to him you have your dialogue, he hands over the parts, and kicks the self-switches off, resetting everything to Page 1, when you can give him another assignment.

As a parallel event, when you re-enter the map after being away, it will go through the process all at once. If you NEVER returned you might see the Blacksmith pop through animation 2 and 3 as it processes that before settling on the page 4 animation, but that's the worst I can think of running it through in my head.

Ahh, yeah I see what you mean, acting as its own parallel to do the check. If the map is unloaded, it wont matter as it will just run the comparison check on load.

This is a great idea, and definitely what I will go with. Simplifies so many things.

Thanks!

Original thread: https://forums.rpgmakerweb.com/threads/looking-for-ideas-for-a-smelting-system-like-stardew-valley-minecraft.164764/