Challenge

Don't know how to use a machine? Looking for efficient setups? Stuck in a mission?
Post Reply
Diablo
Inserter
Inserter
Posts: 46
Joined: Thu Apr 21, 2016 12:35 pm
Contact:

Challenge

Post by Diablo »

So, I have a challenge.
I kinda maybe lost my chest with blue prints (specifically power generation blue prints) somewhere on the map.
After having run around the entire know world 3 times and power demand growing steadily, i'm getting desperate to find all the designs.
is there a way to actually locate a specific box on a map? (maybe through the lua?)

I could obviously remake the blueprints but I would rather save the time and effort and use the ones I already have.

Hope anyone can help.

User avatar
prg
Filter Inserter
Filter Inserter
Posts: 947
Joined: Mon Jan 19, 2015 12:39 am
Contact:

Re: Challenge

Post by prg »

Code: Select all

local p = game.local_player
local s = p.surface
for chunk in s.get_chunks() do
    local entities = s.find_entities_filtered{area={{chunk.x*32, chunk.y*32}, {(chunk.x+1)*32, (chunk.y+1)*32}}, force=p.force}
    for _, e in pairs(entities) do
        local count = e.get_item_count("blueprint")
        if count > 0 then
            p.print(e.name.." containing "..count.." blueprint(s) at "..e.position.x.."x"..e.position.y)
        end
    end
end
Automatic Belt (and pipe) Planner—Automate yet another aspect of constructing your factory!

Diablo
Inserter
Inserter
Posts: 46
Joined: Thu Apr 21, 2016 12:35 pm
Contact:

Re: Challenge

Post by Diablo »

Looks great, just doesn't return anything.
Even if I put a test blueprint in a box next to me.

I copied the code directly into the lua, was that ok?

User avatar
prg
Filter Inserter
Filter Inserter
Posts: 947
Joined: Mon Jan 19, 2015 12:39 am
Contact:

Re: Challenge

Post by prg »

You're actually executing the code with /c?
Automatic Belt (and pipe) Planner—Automate yet another aspect of constructing your factory!

Diablo
Inserter
Inserter
Posts: 46
Joined: Thu Apr 21, 2016 12:35 pm
Contact:

Re: Challenge

Post by Diablo »

No sorry for the misunderstanding.
I copied the code into the game by going into the console with ~

User avatar
prg
Filter Inserter
Filter Inserter
Posts: 947
Joined: Mon Jan 19, 2015 12:39 am
Contact:

Re: Challenge

Post by prg »

Right, now just prefix it with /c so it gets executed instead of resulting in a chat message.
Automatic Belt (and pipe) Planner—Automate yet another aspect of constructing your factory!

Diablo
Inserter
Inserter
Posts: 46
Joined: Thu Apr 21, 2016 12:35 pm
Contact:

Re: Challenge

Post by Diablo »

YAY :D

Found it, thank you so much.

Post Reply

Return to “Gameplay Help”