Jump to content

Special Events


Recommended Posts

Ah yes of course the start of any event is going to happen alongside a game update.  I had forgotten that.  So the mod that restarts my server when an update is available is already going to activate the special event.

Thanks for your help.

Ahh, and I see Settings.last_world_specialevent and Settings.current_world_specialevent in GLOBAL.  I assume I'll be able to use those to check if a new event has begun whenever the server restarts.  I'll give it a try.

Thanks again.

Link to comment
Share on other sites

I gave it a try and thought I may as well post my finding here in case it's useful to someone else in the future.

By the time AddGamePostInit gets called in modmain.lua GLOBAL.Settings.last_world_specialevent and GLOBAL.Settings.current_world_specialevent are always equal.

Instead I used GLOBAL.WORLD_SPECIAL_EVENT.

AddGamePostInit(function()
    if not GLOBAL.TheWorld and GLOBAL.TheWorld.ismastershard then return end
    if GLOBAL.WORLD_SPECIAL_EVENT ~= GLOBAL.Settings.current_world_specialevent then
        if GLOBAL.WORLD_SPECIAL_EVENT == "none" then
            for k,v in pairs(GLOBAL.SPECIAL_EVENTS) do
                if v == GLOBAL.Settings.last_world_specialevent then
                    print(GLOBAL.STRINGS.UI.SANDBOXMENU.SPECIAL_EVENTS[k] .. " has ended.")
                    break
                end
            end
        else
            for k,v in pairs(GLOBAL.SPECIAL_EVENTS) do
                if v == GLOBAL.WORLD_SPECIAL_EVENT then
                    print(GLOBAL.STRINGS.UI.SANDBOXMENU.SPECIAL_EVENTS[k] .. " has begun.")
                    break
                end
            end
        end
    end
end)

In the actual code instead of printing event info it sends it to a Discord channel, and this way it only sends it when an event starts or stops, instead of each time the server is restarted.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...