[MOD 0.10.x] Faster Spilling

Topics and discussion about specific mods
Post Reply
Rseding91
Factorio Staff
Factorio Staff
Posts: 13204
Joined: Wed Jun 11, 2014 5:23 am
Contact:

[MOD 0.10.x] Faster Spilling

Post by Rseding91 »

EDIT: this mod is now obsolete as of 0.10.9 :) I'm leaving it here for anyone running pre-0.10.9 (but you should update so you don't need it).


This mod changes chests so when they're harvested by a player and the items are going to spill onto the ground (chest-splosion) it doesn't lock the game while they drop. Instead of freezing while all the items are spilled the mod uses a faster method and is able to drop all the chest contents within a fraction of a second.

I filled a Dytech extra large steel chest full of steel plates (with a stack size of 200) and then mined it with a full inventory. It took 3~ seconds to "spill" the chest contents compared to the 5+ minutes which I eventually gave up on without the mod:

Here's a short video demonstrating the mod in action: https://www.youtube.com/watch?v=lf7rcNzvKAI


Example
Here

Current version: 1.1.1
Download [0.10.6]:
Faster Spilling.zip
(3.07 KiB) Downloaded 262 times
Download [0.10.8]:
Faster Spilling_1.1.1.zip
(3.16 KiB) Downloaded 309 times
Changelog:

Code: Select all

1.1.1: fixed a typo with a variable name
1.1.0: fixed not having the "picked up ..." text when picking up chests
1.0.0: initial release



Note: If the Factorio devs want to use this method for the vanilla game that would be awesome :)
Last edited by Rseding91 on Fri Aug 29, 2014 7:43 pm, edited 6 times in total.
If you want to get ahold of me I'm almost always on Discord.

OBAMA MCLAMA
Filter Inserter
Filter Inserter
Posts: 337
Joined: Fri May 30, 2014 4:23 am
Contact:

Re: [MOD 0.10.x] Faster Spilling

Post by OBAMA MCLAMA »

I'm curious, are you using some kind of like... sqrt(1000) = 31.### and then going to the corner > 31 and continuing it?

(i don't know how your mod or factorio does this, this is just a thought)

edit: btw great mod, deff using incase of an accident.
When i stream twitch i always answer questions and try to help, come visit me.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13204
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [MOD 0.10.x] Faster Spilling

Post by Rseding91 »

OBAMA MCLAMA wrote:I'm curious, are you using some kind of like... sqrt(1000) = 31.### and then going to the corner > 31 and continuing it?

(i don't know how your mod or factorio does this, this is just a thought)

edit: btw great mod, deff using incase of an accident.

I'm not sure how the default Factorio method works but the way this mod works is an expanding square from the chest origin checking if It can place the spilled contents as it goes until it's out of items to spill. The time taken to drop a chest's contents is linearly scaled with the number of items that have to be dropped.
If you want to get ahold of me I'm almost always on Discord.

User avatar
FreeER
Smart Inserter
Smart Inserter
Posts: 1266
Joined: Mon Feb 18, 2013 4:26 am
Contact:

Re: [MOD 0.10.x] Faster Spilling

Post by FreeER »

...I am really surprised that this is faster than the game's version, it doesn't seem like it should be unless the game is doing something strange (which it apparently is lol).
hm, is there a reason you are manually creating a table for 'spillableChests' rather than looping through the game.entityprototypes and getting the names of types (container/logistic-container) that can spill (it'd only be done when the save is loaded and would improve mod compatibility)?
You should be able to check if a chest has contents with "#chestContents > 0", or with "event.entity.getitemcount() > 0", instead of a for loop (which would create two variables as well as an iterator). Also, I'm somewhat surprised you didn't just create a single item entity for each item, though I suppose you wanted to keep with the original 'spilling' mechanic.
BTW, I imagine that you're excluding blueprints to avoid them losing saved data, you might want to do the same with modular armor (though I will admit it's fairly unlikely for them to be in a chest instead of on a player lol)

Nice mod by the way :P

Rseding91
Factorio Staff
Factorio Staff
Posts: 13204
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [MOD 0.10.x] Faster Spilling

Post by Rseding91 »

FreeER wrote:...I am really surprised that this is faster than the game's version, it doesn't seem like it should be unless the game is doing something strange (which it apparently is lol).
hm, is there a reason you are manually creating a table for 'spillableChests' rather than looping through the game.entityprototypes and getting the names of types (container/logistic-container) that can spill (it'd only be done when the save is loaded and would improve mod compatibility)?
You should be able to check if a chest has contents with "#chestContents > 0", or with "event.entity.getitemcount() > 0", instead of a for loop (which would create two variables as well as an iterator). Also, I'm somewhat surprised you didn't just create a single item entity for each item, though I suppose you wanted to keep with the original 'spilling' mechanic.
BTW, I imagine that you're excluding blueprints to avoid them losing saved data, you might want to do the same with modular armor (though I will admit it's fairly unlikely for them to be in a chest instead of on a player lol)

Nice mod by the way :P
#chestContents actually doesn't work for some reason - I did try that :) As for the manual table: so you can disable ones if you don't want them in there. The vanilla game does 1 item per item-on-ground so that's what I used to maintain compatibility with anything that expects that. As for blueprints - yep.
If you want to get ahold of me I'm almost always on Discord.

User avatar
FreeER
Smart Inserter
Smart Inserter
Posts: 1266
Joined: Mon Feb 18, 2013 4:26 am
Contact:

Re: [MOD 0.10.x] Faster Spilling

Post by FreeER »

Rseding91 wrote:#chestContents actually doesn't work for some reason - I did try that :)
oh right, now that you say you've tried it I remember why. '#' only gets the number of numeric based indexes, not the string based...
Rseding91 wrote:As for the manual table: so you can disable ones if you don't want them in there
Hm... why would anyone want to disable it? The main reason I ask is that a entityprototypes loop would allow compatibility with other mods (without needing this to be updated either by you or the player), you could always have an 'exclusion' table that was looked at prior to inserting into the spillableChests table if you wanted both functionalities (<- is that even a word? probably not, 'features' would probably be the proper word here)
Rseding91 wrote:The vanilla game does 1 item per item-on-ground so that's what I used to maintain compatibility with anything that expects that.
hm...decent reason I suppose, of course I'd say that any mod that's not using the item stack's count has a bug :) I'll probably change that for myself.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13204
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [MOD 0.10.x] Faster Spilling

Post by Rseding91 »

FreeER wrote:
Rseding91 wrote:As for the manual table: so you can disable ones if you don't want them in there
Hm... why would anyone want to disable it? The main reason I ask is that a entityprototypes loop would allow compatibility with other mods (without needing this to be updated either by you or the player), you could always have an 'exclusion' table that was looked at prior to inserting into the spillableChests table if you wanted both functionalities (<- is that even a word? probably not, 'features' would probably be the proper word here)
There's also the issue that not every item container should be handled the way this mod handles it. Two such examples I can think of are two of my other mods: Compression Chests and Heavy Chests. If I just auto-included every item container it would mess both of them up.
If you want to get ahold of me I'm almost always on Discord.

Schmendrick
Fast Inserter
Fast Inserter
Posts: 222
Joined: Wed Apr 30, 2014 11:17 pm
Contact:

Re: [MOD 0.10.x] Faster Spilling

Post by Schmendrick »

Rseding91 wrote:There's also the issue that not every item container should be handled the way this mod handles it. Two such examples I can think of are two of my other mods: Compression Chests and Heavy Chests. If I just auto-included every item container it would mess both of them up.
Aw, crap. :p
Like my mods? Check out another! Or see older, pre-0.12.0 mods.

MF-
Smart Inserter
Smart Inserter
Posts: 1235
Joined: Sun Feb 24, 2013 12:07 am
Contact:

Re: [MOD 0.10.x] Faster Spilling

Post by MF- »

FreeER wrote:...I am really surprised that this is faster than the game's version, it doesn't seem like it should be unless the game is doing something strange (which it apparently is lol).
Well.. The game might be using the same "enlarging square" method,
but checking the full square instead of just checking it's outline?
That would make a performance difference...
.. but also a difference in the outcome if there are empty belts leading from the chest
Well... haven't played for quite a while, does the time move when exploding or not? In latter case it won't matter of course

The other thing that comes to my mind is interactions with replays and multiplayer.
Again, only if any time passes during the explosion.

Rahjital
Filter Inserter
Filter Inserter
Posts: 435
Joined: Thu May 29, 2014 10:44 am
Contact:

Re: [MOD 0.10.x] Faster Spilling

Post by Rahjital »

I have a feeling the game simply uses the findnoncollidingposition function for each item, which is going to do a lot of unnecessary checks when there's thousands of items in the chest.
Rseding91 wrote:There's also the issue that not every item container should be handled the way this mod handles it. Two such examples I can think of are two of my other mods: Compression Chests and Heavy Chests. If I just auto-included every item container it would mess both of them up.
You could do automatic detection and then a manual exclusion table to determine which chests not to spill, and/or add an interface to allow mod makers to make their chest non-spillable.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13204
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [MOD 0.10.x] Faster Spilling

Post by Rseding91 »

Rahjital wrote:I have a feeling the game simply uses the findnoncollidingposition function for each item, which is going to do a lot of unnecessary checks when there's thousands of items in the chest.
I'm pretty sure (95%) that's exactly what it does now.

Rahjital wrote:
Rseding91 wrote:There's also the issue that not every item container should be handled the way this mod handles it. Two such examples I can think of are two of my other mods: Compression Chests and Heavy Chests. If I just auto-included every item container it would mess both of them up.
You could do automatic detection and then a manual exclusion table to determine which chests not to spill, and/or add an interface to allow mod makers to make their chest non-spillable.
I've never been a fan of black-lists, they always end up having some fringe-case issue where as white lists virtually never have issues since I know all of the whitelisted entities will work without issues. With that being said, you're welcome to change the mod how you want and use that :)

As for the script interface, that's not a bad idea. One for adding and one for removing/black-listing.
If you want to get ahold of me I'm almost always on Discord.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13204
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [MOD 0.10.x] Faster Spilling

Post by Rseding91 »

Updated to 1.1.0: I found a way to fix not having the text popup when picking up chests :)
If you want to get ahold of me I'm almost always on Discord.

User avatar
SHiRKiT
Filter Inserter
Filter Inserter
Posts: 706
Joined: Mon Jul 14, 2014 11:52 pm
Contact:

Re: [MOD 0.10.x] Faster Spilling

Post by SHiRKiT »

This is one of those mods that are not actually mods but bugfixing. Excellent catch.

User avatar
StanFear
Fast Inserter
Fast Inserter
Posts: 236
Joined: Sun Dec 15, 2013 2:49 pm
Contact:

Re: [MOD 0.10.x] Faster Spilling

Post by StanFear »

maybe move this thread to the obsolete mods section ?

Koub
Global Moderator
Global Moderator
Posts: 7199
Joined: Fri May 30, 2014 8:54 am
Contact:

Re: [MOD 0.10.x] Faster Spilling

Post by Koub »

As suggested, this mod has become obsolete with 0.10.9, moved to obsolete Mods.
Koub - Please consider English is not my native language.

Post Reply

Return to “Mods”