Skip to content

Commit

Permalink
Improve Better Victory Screen Compatibility (#23)
Browse files Browse the repository at this point in the history
Adds a global.finished, because BVS does not set either the two conditions you currently check for. If this is not added then nothing will go wrong because BVS does this internally already. But it will prevent edge cases, for example if BVS is removed after FF victory is achieved, then you'll be able to trigger the victory again.
---------

Co-authored-by: Tom Burrows <[email protected]>
  • Loading branch information
heinwessels and tburrows13 authored Apr 14, 2024
1 parent 7c7f101 commit 2fb362f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions scripts/endgame.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ local function on_rocket_launched(event)
local rocket = event.rocket
if not (rocket and rocket.valid) then return end

if game.finished or game.finished_but_continuing then return end
if game.finished or game.finished_but_continuing or global.finished then return end

local inventory = rocket.get_inventory(defines.inventory.rocket)
if inventory.get_item_count("ff-interstellar-communicator") > 0 then
global.finished = true

if remote.interfaces["better-victory-screen"] and remote.interfaces["better-victory-screen"]["trigger_victory"] then
remote.call("better-victory-screen", "trigger_victory", rocket.force)
Expand Down Expand Up @@ -51,4 +52,4 @@ Endgame.events = {
Endgame.on_init = disable_rocket_victory
Endgame.on_configuration_changed = disable_rocket_victory

return Endgame
return Endgame

0 comments on commit 2fb362f

Please sign in to comment.