Page 1 of 1
[MOD 0.10.x] Faster Spilling
Posted: Tue Aug 05, 2014 11:52 pm
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
Current version: 1.1.1
Download [0.10.6]:
Download [0.10.8]:
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
Re: [MOD 0.10.x] Faster Spilling
Posted: Wed Aug 06, 2014 12:20 am
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.
Re: [MOD 0.10.x] Faster Spilling
Posted: Wed Aug 06, 2014 1:00 am
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.
Re: [MOD 0.10.x] Faster Spilling
Posted: Wed Aug 06, 2014 2:13 am
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
Re: [MOD 0.10.x] Faster Spilling
Posted: Wed Aug 06, 2014 2:25 am
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
#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.
Re: [MOD 0.10.x] Faster Spilling
Posted: Wed Aug 06, 2014 2:44 am
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.
Re: [MOD 0.10.x] Faster Spilling
Posted: Wed Aug 06, 2014 3:17 am
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.
Re: [MOD 0.10.x] Faster Spilling
Posted: Wed Aug 06, 2014 4:13 am
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
Re: [MOD 0.10.x] Faster Spilling
Posted: Wed Aug 06, 2014 7:58 am
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.
Re: [MOD 0.10.x] Faster Spilling
Posted: Wed Aug 06, 2014 5:11 pm
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.
Re: [MOD 0.10.x] Faster Spilling
Posted: Wed Aug 06, 2014 8:08 pm
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.
Re: [MOD 0.10.x] Faster Spilling
Posted: Wed Aug 20, 2014 9:09 am
by Rseding91
Updated to 1.1.0: I found a way to fix not having the text popup when picking up chests
Re: [MOD 0.10.x] Faster Spilling
Posted: Wed Aug 20, 2014 2:20 pm
by SHiRKiT
This is one of those mods that are not actually mods but bugfixing. Excellent catch.
Re: [MOD 0.10.x] Faster Spilling
Posted: Fri Jun 05, 2015 1:56 pm
by StanFear
maybe move this thread to the obsolete mods section ?
Re: [MOD 0.10.x] Faster Spilling
Posted: Fri Jun 05, 2015 7:26 pm
by Koub
As suggested, this mod has become obsolete with 0.10.9, moved to obsolete Mods.