logo
Factorio Whiteboard
Find nearest ore
Initializing search
    combe15/factorio-whiteboard
    • Home
    • AssemblyStorm
    • Typesetter
    • Benchmarks
    • Blueprints
    • Lua scripts
    combe15/factorio-whiteboard
    • Home
    • AssemblyStorm
    • Typesetter
      • 2022-03-05
      • Blueprints
      • Lua scripts
      • Backup logistics requests
      • Spider requester slots
      • Adds a query for modules
      • Deconstruct disconnected solar
      • Delete chunks around box
      • Early requests slots
      • Find empty labs
      • Find entities with zero finished products
      • Find ghost solar
      • Find nopath trains
      • Find recipe
      • Find nearest ore
      • Get trains pathing to station
      • Get inventory filters
      • Groups of requests
      • Hack roboports
      • Inventory get filter
      • Landfill undo
      • Launch all trains
      • Launch trains
      • Module everything
      • Morsk's shitty station finder
      • Player set filter by default
      • Print items launched
      • Print research progress
      • Print solar build queue
      • Protect crash site
      • Restart partially filled mining trains
      • Scan player inventories
      • Solar tribute
      • Solar calc
      • Tree restoration

    Find nearest ore

    ./lua/find_nearest_ore.lua
    /c 
    min = 1000000000 
    for k,c in pairs(game.player.surface.find_entities_filtered{name="coal"}) do 
      d = ((c.position.x * c.position.x) + (c.position.y * c.position.y)) 
      if d < min then 
        min = d 
        game.print('new min [gps'..'='..c.position.x..','..c.position.y..']: ' .. d) 
      end 
    end
    
    Made with Material for MkDocs