I made a mod that offer a hybrid chest requester/provider.
My issue is that i need to detect when a blueprint is in the making, so it can keep requests in the blueprint.
Does anyone know a way to detect when a blueprint is made?
My mod: https://forums.factorio.com/forum/vie ... 97&t=19438
Source code: https://github.com/Phenix0cs/Smarter-chests
Detect blueprint making [Resolved]
Detect blueprint making [Resolved]
Last edited by Phenix0cs on Wed Jan 27, 2016 3:33 pm, edited 1 time in total.
Re: Detect blueprint making
If your primary entity is a requester, it should keep requests in blueprints automatically.
There is no blueprint_created event.
There is no blueprint_created event.
Re: Detect blueprint making
I know that, but my mod need to disable requests most of the running time.
What I'm looking for is a state that indicate that a blueprint is in the making, I can create my own event if needed.
What I'm looking for is a state that indicate that a blueprint is in the making, I can create my own event if needed.
Re: Detect blueprint making
If it help understand, I will show how i manage to keep requests when the chest is destroyed.
So when I detect that the chest died, I restore the requester slots then destroy the linked entity and cleanup links.
So when I detect that the chest died, I restore the requester slots then destroy the linked entity and cleanup links.
Code: Select all
function entity_died(event)
if event.entity.name == "logistic-chest-storage2-ui" then
local pos = position(event.entity)
local link = global.storage_links[position(event.entity)]
-- Recover requester slots
for slot = 1,8 do -- TODO Change if number of slots can be retrived
request = link.requester_slots[slot]
if request ~= nil then
event.entity.set_request_slot(request,slot)
end
end
link.storage.destroy()
global.storage_links[position(event.entity)] = nil
cleanup_links()
end
end
Re: Detect blueprint making
on_built_entity triggers for all "entity-ghost" entities that blueprint produces. You can check player's cursorstack to make sure they are from blueprint.
Test mode
Searching Flashlight
[WIP]Fluid handling expansion
[WIP]PvP gamescript
[WIP]Rocket Express
Autofill: The torch has been pass to Nexela
Searching Flashlight
[WIP]Fluid handling expansion
[WIP]PvP gamescript
[WIP]Rocket Express
Autofill: The torch has been pass to Nexela
Re: Detect blueprint making
Thanks rk84, with your hints I was able to figure out how to do it.
Code: Select all
function put_item(event)
if game.player.cursor_stack.valid_for_read and
game.player.cursor_stack.name == "blueprint" then
-- code goes here
end
end
script.on_event({defines.events.on_put_item}, put_item)