Be it huge enemy bases, or accidental inventory overloads, picking up lots of items scattered on the ground can be very annoying.
3 ideas of solving that tedium:
1. Increased player pickup radius (significantly)
2. *Preferred solution* Using Bots. Basically an item like deconstruction blueprint, but instead a pickup items blueprint where you select a region and bots do it
3. A building that picks up specific items in it's radius. F-mod already has this capability, but it's specialized for use within that mod. I don't have the expertise to extrapolate his code and use it. Also, which items to pick up?
[REQUEST] A way to pick items off ground
Re: [REQUEST] A way to pick items off ground
I do not believe that 1 or 2 is possible (at this time) with lua...
3, however should be simple enough.
Fmod's artifact collector code is lines 420 - 437, and the part that makes it specific to small-alien-artifacts is fairly obviously the names of the artifacts[z].stack.name.
A similar machine that instead picks up anything in range could be coded like soIf that looks too simple to be the same functionality as the fmod's collector just realize that the majority of the fmod's complexity in that code is Ficolas's use of for i,_ instead of for _, var which leads to his using table[index].whatever instead of var.whatever and the use of game.findentities instead of game.findentitiesfiltered (which leads to him filtering the table himself with an additional for loop). edit: a closer look at his code and I see he is storing the collector's position rather than a reference to the collector which complicates the code a little bit more than otherwise Without those decisions the code would look remarkably the same
edit:
To make the above code work only for certain items you just need an if statement checking the item.stack.name like so after if item.validthat could even be separated into a function that takes the item.stack.name and returns true or false if the collector should pick it up.
edit2: just in case note: this assume that the 'collector' entity has an inventory to insert into...
3, however should be simple enough.
Fmod's artifact collector code is lines 420 - 437, and the part that makes it specific to small-alien-artifacts is fairly obviously the names of the artifacts[z].stack.name.
A similar machine that instead picks up anything in range could be coded like so
firstcode
Code: Select all
if glob.itemcollector~=nil and event.tick%60==0 then
local items = {}
local itemstack = {}
for index, collector in pairs(glob.itemcollector) do
if collector.valid then
items=game.findentitiesfiltered{type="item-entity", area=getBoundingBox(collector.position, 100)}
for _, item in pairs(items) do
if item.valid then
itemstack = {name=item.stack.name, count=item.stack.count}
if collector.caninsert(itemstack) then
collector.insert(itemstack)
item.destroy()
end
end
end
else -- collector was not valid
table.remove(glob.itemcollector, index)
end
end
end
function getBoundingBox(position, radius)
return {{position.x-radius,position.y-radius},{position.x+radius,position.y+radius}}
end
edit:
To make the above code work only for certain items you just need an if statement checking the item.stack.name like so after if item.valid
Code: Select all
if (item.stack.name == "itemname1") or (item.stack.name == "itemname2") or (item.stack.name == "itemname3") ... then
edit2: just in case note: this assume that the 'collector' entity has an inventory to insert into...
<I'm really not active any more so these may not be up to date>
~FreeER=Factorio Modding
- Factorio Wiki
- My Factorio Modding Guide
- Wiki Modding Guide
Feel free to pm me
Or drop into #factorio on irc.esper.net
~FreeER=Factorio Modding
- Factorio Wiki
- My Factorio Modding Guide
- Wiki Modding Guide
Feel free to pm me
Or drop into #factorio on irc.esper.net
Re: [REQUEST] A way to pick items off ground
Why 1 is not possible currently if we just put player's position into that artifact-collector codes? Of course it's not if what you meant was that by simply changing a property of the player entity prototype.FreeER wrote:I do not believe that 1 or 2 is possible (at this time) with lua...
3, however should be simple enough.
Re: [REQUEST] A way to pick items off ground
This is correct (or through tech). Sure you could use the player as the collector if you so desired...but I think I'd find it quite annoying if everywhere I went I was automatically picking up items, especially if the radius was 100 as I had in my example (just imagine, you'd have to stay x coordinates from ANY belt you didn't want to pick items up from)...there are workarounds of course (guis, script interfaces, etc.) but until you can bind it to an actual key for the player to press I probably wouldn't bother using it myself, it also just makes more sense to me for a (technologically advanced) machine to be able to pick things up in a large radius but not the player (unless we get gravity guns or something...but then I'd rather use those as weapons against the biters )HoneyFox wrote:Of course it's not if what you meant was that by simply changing a property of the player entity prototype.
Re: [REQUEST] A way to pick items off ground
For the filter thing... one idea is to only pick up objects that are already in the quickbar since that might be the most frequently used items (or perhaps not due to the current state of item slot which doesn't lock the type of item by default, though I can use MMB to do that manually)FreeER wrote:This is correct (or through tech). Sure you could use the player as the collector if you so desired...but I think I'd find it quite annoying if everywhere I went I was automatically picking up items, especially if the radius was 100 as I had in my example (just imagine, you'd have to stay x coordinates from ANY belt you didn't want to pick items up from)...there are workarounds of course (guis, script interfaces, etc.) but until you can bind it to an actual key for the player to press I probably wouldn't bother using it myself, it also just makes more sense to me for a (technologically advanced) machine to be able to pick things up in a large radius but not the player (unless we get gravity guns or something...but then I'd rather use those as weapons against the biters )HoneyFox wrote:Of course it's not if what you meant was that by simply changing a property of the player entity prototype.
gravity gun? hmmm... that's something interesting...
Re: [REQUEST] A way to pick items off ground
Thanks for the responses!
Okay let's so say I want to make Roboports automatically pick up all alien artifacts with 100 radius. That would be achievable through modifying the Fmod stuff right? (sorry, I'm not programmer, I've only edited some LUA numbers before)
Okay let's so say I want to make Roboports automatically pick up all alien artifacts with 100 radius. That would be achievable through modifying the Fmod stuff right? (sorry, I'm not programmer, I've only edited some LUA numbers before)
Re: [REQUEST] A way to pick items off ground
you could modify F-mod, but you'd probably be better off by creating your own mod that did it (that way when you update F-mod's files your modified code doesn't vanish, not to mention Ficolas could change how he is using it and then you'd have to rewrite your code to match).
Also, roboports do not seem to allow inserting into them...at least not unless it's something that it expects to have (repair packs, logisitic/construction robots), there is also no way (that I know of) to make the logistic/construction robots collect items (there is an orderdeconstruction command but calling it on an item-entity results in a message (paraphrasing) saying it is not a valid entity to be deconstructed)...
here's the 'mod' I just used to test this (it uses the wooden-chest as a collector and has debug statements turned on currently and a huge checking area of 30). if you wanted to require the collector to have energy (if it was an entity that could use energy) you could also add an if statement after the collector.valid one checking that collector.energy > 0. edit: should also mention that it only picks up alien artifacts and small alien artifacts (due to the itemstack.name checking on line 30)
Also, roboports do not seem to allow inserting into them...at least not unless it's something that it expects to have (repair packs, logisitic/construction robots), there is also no way (that I know of) to make the logistic/construction robots collect items (there is an orderdeconstruction command but calling it on an item-entity results in a message (paraphrasing) saying it is not a valid entity to be deconstructed)...
here's the 'mod' I just used to test this (it uses the wooden-chest as a collector and has debug statements turned on currently and a huge checking area of 30). if you wanted to require the collector to have energy (if it was an entity that could use energy) you could also add an if statement after the collector.valid one checking that collector.energy > 0. edit: should also mention that it only picks up alien artifacts and small alien artifacts (due to the itemstack.name checking on line 30)
Re: [REQUEST] A way to pick items off ground
You're amazing, thank you. I think i can tweak it from there .
Coincidentally, just 5 minutes ago I placed a lab that ended up being dedicated to you.
Coincidentally, just 5 minutes ago I placed a lab that ended up being dedicated to you.
Re: [REQUEST] A way to pick items off ground
You're welcome, feel free to make another post if you need any help tweaking it
niceAvarant wrote:Coincidentally, just 5 minutes ago I placed a lab that ended up being dedicated to you.