Kryzeth

Improved build_allowed_entities

Nov 10th, 2025
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.74 KB | None | 0 0
  1. -- Define the initial machine groups and allowed tiles for each group.
  2. local function build_allowed_entities()
  3.     local allowed = {}
  4.     local filters = {
  5.         --{ filter = "subgroup", subgroup = "inserter" },
  6.         { filter = "subgroup", subgroup = "circuit-network" },
  7.     }
  8.     table.insert(filters, {
  9.         filter = "place-result",
  10.         elem_filters = {
  11.             { filter = "type", type = "inserter" }
  12.         }
  13.     })
  14.    
  15.     if script.active_mods["aai-containers"] then
  16.         table.insert(filters, { filter = "subgroup", subgroup = "container-1" })
  17.     end
  18.     --[[
  19.     if script.active_mods["kry-inserters"] then
  20.         table.insert(filters, { filter = "subgroup", subgroup = "shinyinserter1" })
  21.         table.insert(filters, { filter = "subgroup", subgroup = "shinyinserter2" })
  22.     end]]--
  23.  
  24.     -- get items from filters
  25.     local items = {}
  26.     if filters[1] then
  27.         items = prototypes.get_item_filtered(filters)
  28.     end
  29.  
  30.     for _, item in pairs(items) do
  31.         if item.place_result then
  32.             allowed[item.place_result.name] = true
  33.         end
  34.     end
  35.  
  36.     -- storage group but only chest
  37.     local storage_filters = { { filter = "subgroup", subgroup = "storage" } }
  38.     local storage_items = prototypes.get_item_filtered(storage_filters)
  39.     for _, item in pairs(storage_items) do
  40.         if item.place_result and string.find(item.name, "chest") then
  41.             allowed[item.place_result.name] = true
  42.         end
  43.     end
  44.  
  45.     -- logistic group but only chest
  46.     local logistic_filters = { { filter = "subgroup", subgroup = "logistic-network" } }
  47.     local logistic_items = prototypes.get_item_filtered(logistic_filters)
  48.     for _, item in pairs(logistic_items) do
  49.         if item.place_result and string.find(item.name, "chest") then
  50.             allowed[item.place_result.name] = true
  51.         end
  52.     end
  53.  
  54.     -- logistic group but only chest
  55.     local belt_filters = { { filter = "subgroup", subgroup = "belt" } }
  56.     local belt_items = prototypes.get_item_filtered(belt_filters)
  57.     for _, item in pairs(belt_items) do
  58.         if item.place_result and string.find(item.name, "transport") then
  59.             allowed[item.place_result.name] = true
  60.         end
  61.     end
  62.  
  63.     -- additional stuff
  64.     allowed["gun-turret"] = true
  65.     allowed["heavy-gun-turret"] = true
  66.     allowed["flamethrower-turret"] = true
  67.     allowed["rocket-turret"] = true
  68.     allowed["pipe"] = true
  69.     allowed["steel-chest"] = true
  70.     allowed["barreling-machine"] = true
  71.     allowed["radar"] = true
  72.     allowed["canex-excavator"] = true
  73.     allowed["entity-ghost"] = true
  74.     allowed["pump"] = true
  75.     allowed["long-range-delivery-drone-request-depot"] = true
  76.     allowed["cargo_ship"] = true
  77.     allowed["cargo_ship_engine"] = true
  78.     allowed["oil_tanker"] = true
  79.     allowed["indep-boat"] = true
  80.     allowed["boat_engine"] = true
  81.     allowed["oil_rig"] = true
  82.     allowed["or_power_electric"] = true
  83.     allowed["or_pole"] = true
  84.     allowed["or_radar"] = true
  85.     allowed["or_tank"] = true
  86.  
  87.     return allowed
  88. end
Advertisement
Add Comment
Please, Sign In to add comment