Page 1 of 1

"The first one is free", A simple fix for 'trash' items

Posted: Wed Mar 15, 2017 10:45 am
by Moffmaster
This is, I think a very simple to implement mod. Unfortunately, it is still above my own understanding of programming.

For me, one of the most annyoing things in factorio is to deal with random 'trash' items that you tend to pick up. Like a piece of copper wire, an old wooden pole, an iron rod, an old (yellow) underground belt entrance, that kind of thing.
And it gets worse the bigger the mods you use, (like bobs), as the recipes are more complex, and there are more such 'thrash' items to accumulate.

Obviously, a simple solution is to just give yourself more inventory slots, but that changes the game difficulty and also would have to be adjusted to the number of different items in your mods.


Therefore, I would humbly request a mod that does the following:

-On pick up, drop or craft (or every second or so if that is simpler):
-Loops through the player inventory and counts item TYPES.
-Dynamically adds and removes equipment slots. (Basically setting player.character_inventory_slots_bonus = "# of item types found".

This would basically make the first stack of each item type 'free'. Because as soon as you pick it up, you get an extra inventory slot.
This way, you won't have to worry about small amounts of 'random thrash' at all. Only when it becomes more than one full stack, does it take up 'real' space.
It will also allow you to carry a large variety of machines, as is required for mods like angels. This is a welcome side effect.

Does anyone think my request has merit?

Re: "The first one is free", A simple fix for 'trash' items

Posted: Wed Mar 15, 2017 7:43 pm
by DedlySpyder
You may be looking for types +1, btw, not sure if you can even pick an item up if your inventory is full.

Re: "The first one is free", A simple fix for 'trash' items

Posted: Wed Mar 15, 2017 10:54 pm
by Ranakastrasz
I am pretty sure you can detect when you try to pick an item up. Depending on what variables that event throws, it might be possible to detect this, determine what tried to be picked up, validate, and if you get the slot, do so and script picking the item up.

No idea how I might go about doing this however.

-----
The "Real" solution is to stop carrying around trash items, and instead dropping them off in relevant chests, and instead using machines to craft the higher end machines. That way, you have less items to worry about, and way more inventory space.

But yes, I would like this too.

Re: "The first one is free", A simple fix for 'trash' items

Posted: Wed Mar 15, 2017 11:19 pm
by Moffmaster
Honestly, it doesn't really matter if it is #types or #types +1. Building it so that it notices the new item you are about to pick up and add a slot for it would be nice, but not strictly necessary for the basic concept. Usually, you would have a few free slots to put stuff you want to pick up.

The idea is that the prospective mod 'refunds' you inventory slots for items you either a) accidentially carry or b) carry because the mod you are playing is so large that you need to have lots of different machines on hand.


And "not picking up trash items" is not much of a solution, as they tend to find their way into your inventory by accident, more or less.

Re: "The first one is free", A simple fix for 'trash' items

Posted: Wed Mar 15, 2017 11:36 pm
by Ranakastrasz
True enough.

Ideally, by the time you have enough items to worry about, you have logistic bots and auto-trash slots, such that the trash gets removed from your inventory as soon as it shows up.

Mainly it gets into your inventory when you remove a building that is doing something with the items.

Re: "The first one is free", A simple fix for 'trash' items

Posted: Thu Mar 16, 2017 10:03 pm
by DedlySpyder
Here ya go.

Should work in multiplayer and work fine with other mods that mess with the main inventory (from my end of things at least).

There's just a main inventory change event, so just hooking into that made it easy. Kept it at just #types.

Re: "The first one is free", A simple fix for 'trash' items

Posted: Fri Mar 17, 2017 12:57 pm
by Moffmaster
I just gave it a a test, and it works exactly like what I asked for.

I still check the inventory for trash too often (out of habbit, I suppse), but it does make things much less of a hassle, especially for bigger mods.

So thank you a thousand times for doing this mod! I'm very grateful! I put it in my 'default mods' folder right away.

Moffmaster


PS: All hail DedlySpyder!

Re: "The first one is free", A simple fix for 'trash' items

Posted: Sun Apr 02, 2017 10:55 am
by Taurondir
This actually fixes my issue with the fact that (as an extreme example) if my inventory is full of Oil Refinaries (?), I have to drop 100 of them to pick up 1 Gear.

---

I can't Mod to save my life, but I might look into the code of this "First one is free" to see if I can setup a system where you are allowed "x total ore" and "x total factories" and "x total plates" ... etc etc, so that you can carry 100 factories all up MAX, but in any mixed number, or ores or plates.

This Mod _basically_ allows this already, but with no count limit on the "extra" stacks it creates. My spin on it of course would be only as a "balance" thing to fit between vanilla and this mod. After all, this Mod is quite a large power jump over vanilla, I mean, it's good, but maybe too good? :)

Re: "The first one is free", A simple fix for 'trash' items

Posted: Sun Apr 02, 2017 11:42 am
by steinio
This mod is great but I have one thing to complain about.
If a new item is inserted in the inventory the crafting menu jumps back to top position instead of staying at scroll position.

Greetings steinio

Re: "The first one is free", A simple fix for 'trash' items

Posted: Wed Apr 05, 2017 4:31 pm
by DedlySpyder
steinio wrote:This mod is great but I have one thing to complain about.
If a new item is inserted in the inventory the crafting menu jumps back to top position instead of staying at scroll position.
That's the game itself doing that, nothing I can do.
Taurondir wrote:I can't Mod to save my life, but I might look into the code of this "First one is free" to see if I can setup a system where you are allowed "x total ore" and "x total factories" and "x total plates" ... etc etc, so that you can carry 100 factories all up MAX, but in any mixed number, or ores or plates.
Feel free to take what's here and modify it. Check for the loop that increments a count based on the inventory contents. If you check what it's interating over you could probably compare them to a list of items and do your check there.

Re: "The first one is free", A simple fix for 'trash' items

Posted: Mon May 01, 2017 4:43 pm
by sparr
I just auto-trash the stuff I shouldn't be carrying around, and let logistics bots carry it all away.

Re: "The first one is free", A simple fix for 'trash' items

Posted: Thu May 04, 2017 11:37 am
by Ranakastrasz
Which is all well and good, once you get to that point in the game. Earlier in the game, it can be just as much a problem.