Code: Select all
-- Put this code into a scenario control.lua, then start up a dedicated server with
-- --start-server-load-scenario name_of_scenario
local is_server = true
require("mod-gui")
script.on_load(function()
print("========================== on_load")
is_server = false
end)
script.on_init(function() print("========================== on_init") end)
script.on_event(defines.events.on_player_joined_game, function(event)
local player = game.players[event.player_index]
local flow = mod_gui.get_button_flow(player)
if is_server then
flow.add{
type = "flow",
name = "desync-button-server",
}
else
flow.add{
type = "sprite-button",
tooltip = "Desync the game",
name = "desync-button-client",
sprite = "utility/heat_exchange_indication",
style = mod_gui.button_style
}
end
end)
script.on_event(defines.events.on_gui_click, function (event)
-- Game doesn't desync until some checked action with the divergent content is done
game.print(event.element.name)
end)