Unable to transfer loot from mod

Place to get help with not working mods / modding interface.
Post Reply
User avatar
fishycat
Filter Inserter
Filter Inserter
Posts: 283
Joined: Thu Apr 09, 2015 7:38 pm
Contact:

Unable to transfer loot from mod

Post by fishycat »

Hi fellow factorians, so I have this request in the mods forum, where I get asked to add the "alien-ores-1-3" from Schall Alien Loot.
I then added, like several times before, this code in control.lua:

Code: Select all

if item.valid and item.stack.valid then
              if string.find(item.stack.name,"alien-ore-1") then
                table.insert(artifactList, {name = item.stack.name, count = item.stack.count})
                item.destroy()
              end
            end
I did so for all three types. Then I started a new game to test it, but the only thing that get transfered, is the alien-artifact, not the ores.

My first thought was, maybe it is because it is an ore, but dismissed it right away, because I already search successfully for "artifafact-ores" from Alien Loot Economy.
I also tried to search only for "alien-ore" - but no success.

Right now I'm out of ideas, so I hope someone can hint me the right way.

Thanks!

User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2897
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: Unable to transfer loot from mod

Post by darkfrei »

Why are you need only this items on grounds?
Try to print all entity names after this string:

Code: Select all

local entities = game.surfaces["nauvis"].find_entities_filtered{name = {}, area = areaToCheck, type = "item-entity"}
for i, entity in pairs (entities) do
  game.print (entity.name)
:arrow: It doesn't work on another surfaces.

User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2897
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: Unable to transfer loot from mod

Post by darkfrei »

Not tested, but you can separate this part as

Code: Select all

local values_list = {"artifact", "corpse"} -- all of them
function is_target (name)
  for i, value in pairs (values_list) do
    if string.find(name, value) then
      return true
    end
  end
  return false
end

User avatar
fishycat
Filter Inserter
Filter Inserter
Posts: 283
Joined: Thu Apr 09, 2015 7:38 pm
Contact:

Re: Unable to transfer loot from mod

Post by fishycat »

This mod I adopted from PiggyWhiskey a while ago. I updated it to 0.16 back then. Now it normally needs an overhaul, to also be compatible with all surfaces, not just Nauvis.
But my time these days is very limited and I can't dive in so super deep and fix it somehow.

Esentially what it does is, to scan around an entity after it died and if there's loot it transfers it in the chest.
What I don't understand is, why it doesn't transfers the alien-ores. :?

User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2897
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: Unable to transfer loot from mod

Post by darkfrei »

fishycat wrote:
Mon Jun 17, 2019 7:07 pm
What I don't understand is, why it doesn't transfers the alien-ores. :?
Not sure, but probably it has another internal name. If you try to take all items from the ground and print it, then you can find what the name you must define.

User avatar
fishycat
Filter Inserter
Filter Inserter
Posts: 283
Joined: Thu Apr 09, 2015 7:38 pm
Contact:

Re: Unable to transfer loot from mod

Post by fishycat »

I usually look in the locale file. Ther is alien-ore-1, alien-ore-2, alien-ore-3, alien-artifact. I also looked into data.updates for the loot, same name.
But will also try out your solution.

User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2897
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: Unable to transfer loot from mod

Post by darkfrei »

fishycat wrote:
Mon Jun 17, 2019 7:07 pm
What I don't understand is, why it doesn't transfers the alien-ores. :?
Try this one (unofficial until mod uploading to the mod portal)
Changes:
- Reworked control lua
- Now the loot chest is much faster
- Now the loot chests takes all items on the floor in the rectangle radius 10
- Now you can set the filter with constant combinator or with items in the circuit network; no connection - taking all of them
:arrow: May be not enough tested.
Attachments
LootChestPlus_1.1.0.zip
(36.42 KiB) Downloaded 33 times

User avatar
fishycat
Filter Inserter
Filter Inserter
Posts: 283
Joined: Thu Apr 09, 2015 7:38 pm
Contact:

Re: Unable to transfer loot from mod

Post by fishycat »

Thanks for taking the time, awesome!

The reason why I chose this mod back then was, it scans globally for loot on Nauvis. It was in a Bob's game and loot was everywhere cluttered and brought my old toaster to its limit.
There already where several loot chest mods but I didn't like that they only scan around itself. With this I needed only one chest. Of course it eats some resources but can't have it all I guess.

So what came in my mind is, to maybe combine the best things. Maybe that it scans general for loot when an entity dies, that part

Code: Select all

local item_entities = surface.find_entities_filtered{area = areaToCheck, type = "item-entity"}
but with area to check globally on all existing surfaces, not just Nauvis.

I like the thing with the network, and that you can search for certain items on ground. Could that be integrated in a way, that the chest primarily scans for loot on_entity_died, but also on request scan for i.e. a pistol on the ground?

Ah and while I tried your version out in a quick test, I got it to crash when I accidentally grenaded the chest :D

Here the log:
Attachments
error.png
error.png (23.26 KiB) Viewed 1028 times

User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2897
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: Unable to transfer loot from mod

Post by darkfrei »

fishycat wrote:
Tue Jun 18, 2019 9:51 pm
Ah and while I tried your version out in a quick test, I got it to crash when I accidentally grenaded the chest :D
Thanks, I forgot the grenade test.
wrong: table.remove (global.next_index, index)

right: table.remove (global.loot_chests, index)

If you have two player forces then loot chests must have area.

If here is only one player force, then it can be done as in https://mods.factorio.com/mod/SmogVisualPollution - just iterate all chunks on the surface, small area every tick. If nothing was found then wait until input signal changing. So you can manipulate with the scanning period internally from the game, just with circuit network.

Post Reply

Return to “Modding help”