Rocket silo events

by Quezler

Provides rocket silo animation keyframe events to other mods.

Internal
1 year, 6 months ago
1.1
1.23K
Owner:
Quezler
Source:
https://github.com/Quezler/glutenfree
Homepage:
https://discord.gg/ktZNgJcaVA
License:
MIT
Created:
2 years ago
Latest Version:
1.0.9 (1 year, 6 months ago)
Factorio version:
1.1
Downloaded by:
1.23K users

once 2.x drops do not expect new 1.x mods from me, mods will be slowly ported based on my needs and/or requests from the community, thx for playing!

This mod provides an event for when the rocket silo status changes several times after a launch has been initiated:

defines.rocket_silo_status.launch_starting
defines.rocket_silo_status.launch_started
defines.rocket_silo_status.engine_starting
defines.rocket_silo_status.arms_retract
defines.rocket_silo_status.rocket_flying
defines.rocket_silo_status.lights_blinking_close
defines.rocket_silo_status.doors_closing
defines.rocket_silo_status.building_rocket

The first time a rocket is launched the mod will look for changes in status every tick, but subsequent launches will use a cache.

You can listen for the events in your own mod via: (placed properly within init and load)

local rocket_silo_status = {}
for string, i in pairs(defines.rocket_silo_status) do
  rocket_silo_status[i] = string
end

script.on_event(remote.call("glutenfree-rocket-silo-events", "on_rocket_silo_status_changed"), function()
    local text = rocket_silo_status[event.old_status] ..' -> '.. rocket_silo_status[event.rocket_silo.rocket_silo_status]
    game.print(event.tick .. ': ' .. text)

    event.rocket_silo.surface.create_entity({
      name = "flying-text",
      position = event.rocket_silo.position,
      text = text,
    })
  end
end)

Currently this mod does not provide events for when a rocket has enough parts to finish building due to lack of event listeners.