[0.13.4] Input loaders are not set back to active state

This subforum contains all the issues which we already resolved.
User avatar
y.petremann
Filter Inserter
Filter Inserter
Posts: 421
Joined: Mon Mar 17, 2014 4:24 pm
Contact:

[0.13.4] Input loaders are not set back to active state

Post by y.petremann »

I know that the loaders are not meant to be used, but they are still there and I know that a lot of modders would be glad to use them.

I've tried something with some stuff to see the comparison between loaders and inserters and found that targeted entities set inserter to active state but not loaders, this mean that only the loader's input (transport-belt) can set it to actve state, but if that transport belt is full, nothing could happens unless you refresh it.
Rseding91
Factorio Staff
Factorio Staff
Posts: 14265
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [0.13.4] Input loaders are not set back to active state

Post by Rseding91 »

It's not in the base game for a reason - it's not fully implemented.
If you want to get ahold of me I'm almost always on Discord.
User avatar
y.petremann
Filter Inserter
Filter Inserter
Posts: 421
Joined: Mon Mar 17, 2014 4:24 pm
Contact:

Re: [0.13.4] Input loaders are not set back to active state

Post by y.petremann »

Rseding91 wrote:It's not in the base game for a reason - it's not fully implemented.
I think that right that it's not fully implemented, but it's here and I think that some modders would use it, look at some mods like slipstream chest for example ...

For now this is the only thing I found that make it working improperly for general cases.
snowrabbit
Manual Inserter
Manual Inserter
Posts: 2
Joined: Thu Jun 16, 2016 3:35 pm
Contact:

Re: [0.13.4] Input loaders are not set back to active state

Post by snowrabbit »

I added the following control.lua to the loaders mod. It deactivates and activates them every now and then. This solves the problem that loaders stay deactivated even when they have work to do.

Code: Select all

script.on_init(function()
	if global.tickTable == nil then 
	  global.tickTable = { } 
	  global.loaderCount = 0
	  global.removedIndex = -1
	end
end)

script.on_load(function()
    if global.tickTable == nil then 
	  global.tickTable = { } 
	  global.loaderCount = 0
	end
end)

script.on_event(defines.events.on_built_entity, function(event) onBuild(event.created_entity) end)
script.on_event(defines.events.on_robot_built_entity, function(event) onBuild(event.created_entity) end)
script.on_event(defines.events.on_tick, function(event) onTick(event.tick) end)

function onBuild(entity)
	if entity.name == "loader" or entity.name == "fast-loader" or entity.name == "express-loader" then
	
		if global.removedIndex ~= -1 then
			loaders = global.tickTable[removedIndex]
			loaders[getEntityId(entity)] = entity
			global.removedIndex = -1
		else
	
			global.loaderCount = global.loaderCount + 1
			index = global.loaderCount % 240
			if global.tickTable[index] == nil then
				global.tickTable[index] = {}
			end
			
			global.tickTable[index][getEntityId(entity)] = entity
		
		end
		
		
		
	end
end

function onTick(tick)
	index = tick % 240
	local loaders = global.tickTable[index]
	
	if loaders == nil then return end
	
	for i,v in pairs(loaders) do
		if v and v.valid then
			v.active = false
			v.active = true
		else
			loaders[i] = nil
			removedIndex = index
		end
	end
	global.tickTable[index] = loaders

end

function getEntityId(entity)
	return "lldr:" .. entity.position.x .. "---" .. entity.position.y
end
I'm no LUA expert, but it did the trick for me and did not influence script update time in a significant way.

greets
posila
Factorio Staff
Factorio Staff
Posts: 5349
Joined: Thu Jun 11, 2015 1:35 pm
Contact:

Re: [0.13.4] Input loaders are not set back to active state

Post by posila »

Hi, we have decided to fix and support loader entity after all, even thought we don't plan to use it in vanilla for now.

Thanks for the report,
this will be fixed in 0.13.14
atehxx
Inserter
Inserter
Posts: 30
Joined: Sat Jun 21, 2014 9:35 pm
Contact:

Re: [0.13.4] Input loaders are not set back to active state

Post by atehxx »

Yes yes yes thanks! :)
Post Reply

Return to “Resolved Problems and Bugs”