Page 1 of 1

Challenge

Posted: Fri May 13, 2016 10:05 pm
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.

Re: Challenge

Posted: Fri May 13, 2016 10:30 pm
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

Re: Challenge

Posted: Fri May 13, 2016 11:14 pm
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?

Re: Challenge

Posted: Sat May 14, 2016 8:49 am
by prg
You're actually executing the code with /c?

Re: Challenge

Posted: Sat May 14, 2016 11:34 am
by Diablo
No sorry for the misunderstanding.
I copied the code into the game by going into the console with ~

Re: Challenge

Posted: Sat May 14, 2016 11:37 am
by prg
Right, now just prefix it with /c so it gets executed instead of resulting in a chat message.

Re: Challenge

Posted: Sat May 14, 2016 11:48 am
by Diablo
YAY :D

Found it, thank you so much.