Advertisement
Guest User

Untitled

a guest
Jan 25th, 2020
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.42 KB | None | 0 0
  1. local function render_bottlenecks(event)
  2.     local colors = {
  3.         {r=0,g=1,b=0},  -- defines.entity_status.working
  4.         {r=1,g=0,b=0},  -- defines.entity_status.no_power
  5.         {r=1,g=0,b=0},  -- defines.entity_status.no_fuel
  6.         {r=1,g=0,b=0},  -- defines.entity_status.no_recipe
  7.         {r=1,g=0,b=0},  -- defines.entity_status.no_input_fluid
  8.         {r=1,g=1,b=0},  -- defines.entity_status.no_research_in_progress
  9.         {r=1,g=0,b=0},  -- defines.entity_status.no_minable_resources
  10.         {r=1,g=0,b=0},  -- defines.entity_status.low_input_fluid
  11.         {r=1,g=0,b=0},  -- defines.entity_status.low_power
  12.         {r=1,g=0,b=0},  -- defines.entity_status.disabled_by_control_behavior
  13.         {r=1,g=0,b=0},  -- defines.entity_status.disabled_by_script
  14.         {r=1,g=0,b=0},  -- defines.entity_status.fluid_ingredient_shortage
  15.         {r=1,g=1,b=0},  -- defines.entity_status.fluid_production_overload
  16.         {r=1,g=0,b=0},  -- defines.entity_status.item_ingredient_shortage
  17.         {r=1,g=1,b=0},  -- defines.entity_status.item_production_overload
  18.         {r=1,g=0,b=0},  -- defines.entity_status.marked_for_deconstruction
  19.         {r=1,g=0,b=0},  -- defines.entity_status.missing_required_fluid
  20.         {r=1,g=0,b=0},  -- defines.entity_status.missing_science_packs
  21.         {r=1,g=0,b=0},  -- defines.entity_status.waiting_for_source_items
  22.         {r=1,g=0,b=0},  -- defines.entity_status.waiting_for_space_in_destination
  23.         {r=1,g=0,b=0}   -- defines.entity_status.waiting_to_launch_rocket
  24.     };
  25.  
  26.     for _,player in pairs(game.players) do
  27.         local surface = player.surface;
  28.         local player_pos = player.position;
  29.         local res = player.display_resolution;
  30.         local zoom = 0.3;
  31.         local s = {x=res.width/zoom/64, y=res.height/zoom/64};
  32.         local view_top_left = {x=player_pos.x-s.x, y=player_pos.y-s.y};
  33.         local view_bottom_right = {x=player_pos.x+s.x, y=player_pos.y+s.y};
  34.         local visible_entities = surface.find_entities_filtered{area = {view_top_left, view_bottom_right}, type={"furnace", "assembling-machine"}};
  35.         for _, e in pairs(visible_entities) do
  36.             local color = colors[e.status]
  37.             rendering.draw_rectangle{players={player},surface=surface,color=color,filled="true",left_top=e,left_top_offset={-0.2,-0.2}, right_bottom=e,right_bottom_offset={0.2,0.2},time_to_live=61};
  38.         end
  39.     end
  40. end
  41.  
  42. script.on_nth_tick(60, render_bottlenecks);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement