[MOD 0.18.X] Pollution detector

Topics and discussion about specific mods
User avatar
Schorty
Fast Inserter
Fast Inserter
Posts: 185
Joined: Tue Aug 12, 2014 10:29 am
Contact:

Re: [MOD 0.13.X] Pollution detector

Post by Schorty »

Mod has been updated. Just download it from here or via mod portal.
Tired of not being able to reduce the pollution? Try the Air-Filter-Mod
With this, you are able to use the pollution levels in your circuit network: Pollution detector
Pagan_PL
Burner Inserter
Burner Inserter
Posts: 11
Joined: Wed May 18, 2016 12:57 pm
Contact:

Re: [MOD 0.13.X] Pollution detector

Post by Pagan_PL »

I' ve got an error about pollution detector entity: Error while loading pollution detector(constant combinator) No such node(sprite). Can anyone help me with this? I'm using newest STABLE release downloaded from here...
User avatar
Schorty
Fast Inserter
Fast Inserter
Posts: 185
Joined: Tue Aug 12, 2014 10:29 am
Contact:

Re: [MOD 0.14.X] Pollution detector

Post by Schorty »

Updated to work with Version 0.14.
Pagan_PL wrote:I' ve got an error about pollution detector entity: Error while loading pollution detector(constant combinator) No such node(sprite). Can anyone help me with this? I'm using newest STABLE release downloaded from here...
It's working fine for me. Could you upload the savegame, so I can check if it's something wrong there?
Tired of not being able to reduce the pollution? Try the Air-Filter-Mod
With this, you are able to use the pollution levels in your circuit network: Pollution detector
User avatar
Schorty
Fast Inserter
Fast Inserter
Posts: 185
Joined: Tue Aug 12, 2014 10:29 am
Contact:

Re: [MOD 0.15.X] Pollution detector

Post by Schorty »

Mod has been updated for Factorio 0.15.X. Just download it from here or via mod portal.
Tired of not being able to reduce the pollution? Try the Air-Filter-Mod
With this, you are able to use the pollution levels in your circuit network: Pollution detector
Veden
Filter Inserter
Filter Inserter
Posts: 294
Joined: Wed Jul 13, 2016 3:54 pm
Contact:

Re: [MOD 0.15.X] Pollution detector

Post by Veden »

Cool mod. I updated your control file to scale better with more detectors

The biggest change is only a set amount of detectors are processed each pass.

Code: Select all

local DETECTORS_TO_PROCESS = 30

local pollutionDetectors
local pollutionRuntime

local function onConfigChange()
    if not pollutionRuntime then
	if not global.pollutionRuntime then
	    global.pollutionRuntime = {}
	end
	pollutionRuntime = global.pollutionRuntime
    end

    if (pollutionRuntime.version ~= 1) then
	pollutionRuntime.processEvent = (math.ceil(game.tick / 60) + 1) * 60

	print(pollutionRuntime.processEvent)
	pollutionRuntime.queueIndex = 1
	pollutionRuntime.virtualSignalParam = {
	    parameters={
		{
		    index=1,
		    signal={
			type="item",
			name="pollution"
		    },
		    count=-1
		}
	    }
	}
	pollutionRuntime.version = 1
    end
    
end

local function onInit()
    global.pollutionDetectors = {}
    global.pollutionRuntime = {}

    pollutionDetectors = global.pollutionDetectors
    pollutionRuntime = global.pollutionRuntime
    
    onConfigChange()
end

local function onLoad()    
    pollutionDetectors = global.pollutionDetectors
    pollutionRuntime = global.pollutionRuntime
end

-- Logic

local function addPDToTable(event)
    local entity = event.created_entity
    if (entity.name == "pollution-detector") then
	entity.operable = false
	pollutionDetectors[#pollutionDetectors+1] = entity
    end
end

local function removePollutionDetector(event)
    local entity = event.entity
    if (entity.name == "pollution-detector") then
	for i = #pollutionDetectors,1,-1 do
	    local pd = pollutionDetectors[i]
	    if pd.valid then 
		if (entity == pd) then
		    table.remove(pollutionDetectors, i)
		    break
		end
	    else
		table.remove(pollutionDetectors, i)
	    end
	end
    end
end

local function setPollutionValue(entity)
    if (entity.valid) then
	local pollutionSignal = pollutionRuntime.virtualSignalParam
	pollutionSignal.parameters[1].count = math.floor(entity.surface.get_pollution(entity.position))
	entity.get_control_behavior().parameters = pollutionSignal
    end
end

local function onTick(event)
    local tick = event.tick
    if (pollutionRuntime.processEvent == tick) then
	pollutionRuntime.processEvent = pollutionRuntime.processEvent + 60
	local startIndex = pollutionRuntime.queueIndex
	local endIndex = math.min(#pollutionDetectors, startIndex + DETECTORS_TO_PROCESS)
	for i = startIndex, endIndex do
	    setPollutionValue(pollutionDetectors[i])
	end
	if (endIndex == #pollutionDetectors) then
	    pollutionRuntime.queueIndex = 1
	else
	    pollutionRuntime.queueIndex = endIndex
	end
    end
end

-- Events
script.on_init(onInit)

script.on_load(onLoad)

script.on_configuration_changed(onConfigChange)

script.on_event({defines.events.on_built_entity,
		 defines.events.on_robot_built_entity}, addPDToTable)

script.on_event({defines.events.on_player_mined_entity,
		 defines.events.on_robot_mined_entity,
		 defines.events.on_entity_died}, removePollutionDetector)

script.on_event(defines.events.on_tick, onTick)

User avatar
Optera
Smart Inserter
Smart Inserter
Posts: 2920
Joined: Sat Jun 11, 2016 6:41 am
Contact:

Re: [MOD 0.15.X] Pollution detector

Post by Optera »

My megabase heavily relies on this to control the air filters.
Sadly its performance wasn't up to the task, so i rewrote it from scratch.
pollution-detector_0.3.0.zip
Factorio 0.15 version
(28.57 KiB) Downloaded 323 times
Update:
added version for Factorio 0.16 with hr graphics
pollution-detector_0.4.0.zip
Factorio 0.16 with hr graphics
(97.01 KiB) Downloaded 312 times
User avatar
Schorty
Fast Inserter
Fast Inserter
Posts: 185
Joined: Tue Aug 12, 2014 10:29 am
Contact:

Re: [MOD 0.15.X] Pollution detector

Post by Schorty »

Thank you, Optera,

I'll take 0.4.0 as the current version. I'll give you credit aswell ;)

Greetings,
Schorty
Tired of not being able to reduce the pollution? Try the Air-Filter-Mod
With this, you are able to use the pollution levels in your circuit network: Pollution detector
User avatar
Optera
Smart Inserter
Smart Inserter
Posts: 2920
Joined: Sat Jun 11, 2016 6:41 am
Contact:

Re: [MOD 0.15.X] Pollution detector

Post by Optera »

Good to see you still around Schorty.

Sidenote to my forks:
I replaced the pollution icon with a pollution signal a while ago and never bothered adding a migration script, so all circuit logic using the pollution item will have to be reset.
foodfactorio
Filter Inserter
Filter Inserter
Posts: 454
Joined: Tue Jun 20, 2017 1:56 am
Contact:

Re: [MOD 0.15.X] Pollution detector

Post by foodfactorio »

i like the air filter mod :) usually i go around the base manually adding the building where EvoGui shows lots of pollution (for fine tuning) plus the main map. but now that my base gets low on power, i can try using the detector to let me know when somewhere reaches a certain pollution level, and hopefully to be able to switch on (and off) the filters to save power.

(im almost ready to set up the reactor - but i made a silly mistake here) :D
viewtopic.php?f=208&t=56192#p347182 (picture below this post)

also Optera greetings to you :)
i like your Deep Mine, as it gave me a way to get new madclown ores that did not appear on the map, after adding it to a widely-explored existing game. i couldnt find a forum page for your mod so hi here.

a possible fix for the above issue could be here though, https://mods.factorio.com/mod/DeleteEmp ... 1024d77364 but still waiting to see.
(also me from the mod portal - im not dustine lol) = https://mods.factorio.com/mods/Dustine/ ... ssion/9108
my 1st Mod Idea :) viewtopic.php?f=33&t=50256
User avatar
Schorty
Fast Inserter
Fast Inserter
Posts: 185
Joined: Tue Aug 12, 2014 10:29 am
Contact:

Re: [MOD 0.17.X] Pollution detector

Post by Schorty »

Updated the mod to work with 0.17
Tired of not being able to reduce the pollution? Try the Air-Filter-Mod
With this, you are able to use the pollution levels in your circuit network: Pollution detector
User avatar
Optera
Smart Inserter
Smart Inserter
Posts: 2920
Joined: Sat Jun 11, 2016 6:41 am
Contact:

Re: [MOD 0.17.X] Pollution detector

Post by Optera »

With 0.17.12 you will have to multiply pollution by 60 to get appropriate values.
User avatar
Schorty
Fast Inserter
Fast Inserter
Posts: 185
Joined: Tue Aug 12, 2014 10:29 am
Contact:

Re: [MOD 0.17.X] Pollution detector

Post by Schorty »

Thanks for the heads up. Will update the mod soon.

edit: Technically it outputs the appropriate pollution amount. It may or may not break previous designs, because the ratio changed, but it reads the correct numbers. I guess I'll keep the mod as it is.
Tired of not being able to reduce the pollution? Try the Air-Filter-Mod
With this, you are able to use the pollution levels in your circuit network: Pollution detector
User avatar
Optera
Smart Inserter
Smart Inserter
Posts: 2920
Joined: Sat Jun 11, 2016 6:41 am
Contact:

Re: [MOD 0.17.X] Pollution detector

Post by Optera »

Schorty wrote: Fri Mar 15, 2019 4:52 pm edit: Technically it outputs the appropriate pollution amount. It may or may not break previous designs, because the ratio changed, but it reads the correct numbers. I guess I'll keep the mod as it is.
I think we loose too much granularity moving the value range where air filters should be turned on to keep pollution in check from 200-300 down to 2-5.
User avatar
Schorty
Fast Inserter
Fast Inserter
Posts: 185
Joined: Tue Aug 12, 2014 10:29 am
Contact:

Re: [MOD 0.17.X] Pollution detector

Post by Schorty »

This is a fair point. Pollution is given as a floating point value, so multiplying might actually be a helpful change, because combinators wont accept floating point values..

I'll get to changing the mod right away :)
Tired of not being able to reduce the pollution? Try the Air-Filter-Mod
With this, you are able to use the pollution levels in your circuit network: Pollution detector
User avatar
Schorty
Fast Inserter
Fast Inserter
Posts: 185
Joined: Tue Aug 12, 2014 10:29 am
Contact:

Re: [MOD 0.17.X] Pollution detector

Post by Schorty »

Mod has been updated. As stated befor, I multiplied the returned value by 60, because values have been divided by 60 as of 0.17.13 (See https://www.factorio.com/blog/post/fff-286).
Tired of not being able to reduce the pollution? Try the Air-Filter-Mod
With this, you are able to use the pollution levels in your circuit network: Pollution detector
User avatar
Schorty
Fast Inserter
Fast Inserter
Posts: 185
Joined: Tue Aug 12, 2014 10:29 am
Contact:

Re: [MOD 0.18.X] Pollution detector

Post by Schorty »

Updated for Version 0.18
Tired of not being able to reduce the pollution? Try the Air-Filter-Mod
With this, you are able to use the pollution levels in your circuit network: Pollution detector
WildBraas
Inserter
Inserter
Posts: 44
Joined: Sat Feb 16, 2019 6:25 am
Contact:

Re: [MOD 0.18.X] Pollution detector

Post by WildBraas »

Maybe 1.1 please?

Krastorio 2 need your mod!

I got some updates for 1.1 support + NanoBots support. Please upload new version or upgrade me as contributor in mod portal please (I am).
Attachments
pollution-detector.zip
(138.01 KiB) Downloaded 128 times
User avatar
Schorty
Fast Inserter
Fast Inserter
Posts: 185
Joined: Tue Aug 12, 2014 10:29 am
Contact:

Re: [MOD 0.18.X] Pollution detector

Post by Schorty »

Sorry, I don't have the time at the moment. If someone else updates the mod, I'll place it in the mod portal. Sorry guys! =(
Tired of not being able to reduce the pollution? Try the Air-Filter-Mod
With this, you are able to use the pollution levels in your circuit network: Pollution detector
WildBraas
Inserter
Inserter
Posts: 44
Joined: Sat Feb 16, 2019 6:25 am
Contact:

Re: [MOD 0.18.X] Pollution detector

Post by WildBraas »

Mr Shorty, I posted upper updated version. Or you may set me as contributor in mod portal
Zarnoo
Long Handed Inserter
Long Handed Inserter
Posts: 57
Joined: Thu Mar 31, 2016 6:01 pm
Contact:

Re: [MOD 0.18.X] Pollution detector

Post by Zarnoo »

That mod crashes as it's not named properly in the json file.

The file should be called pollution-detector_0.1.0.zip, and the directory inside it should be named the same (without .zip). Could you not post this as a mod on the mod portal, with a note to deprecate if the original author updates ?
Post Reply

Return to “Mods”