diff --git a/locale/en/milestones.cfg b/locale/en/milestones.cfg index 8df75b7..61b358b 100644 --- a/locale/en/milestones.cfg +++ b/locale/en/milestones.cfg @@ -13,6 +13,7 @@ milestones_show_estimations=Show estimations milestones_show_incomplete=Show incomplete milestones milestones_disable_chat_notifications=Disable milestone notifications milestones_write_file=Write milestones to file +milestones_global_announcements=Announce to Everyone [mod-setting-description] milestones_check_frequency=The mod will wait this many ticks between each completion check.\nLower this if you care about time precision, raise if you want less performance impact.\nIf you set this to less than 60, the GUI will also show milliseconds. @@ -23,6 +24,7 @@ milestones_show_estimations=If checked, milestone times that were estimated from milestones_show_incomplete=If checked, milestones that have not been achieved will be visible, labelled "[color=100,100,100]Incomplete[/color]". This does not affect milestones specifically marked as "hidden" in presets. milestones_disable_chat_notifications=If checked, no chat notification will appear when a new milestone is reached. This is per-player, so it only affects you. milestones_write_file=If checked, milestone times will be appended to a milestones-MAPSEED.txt file in the script output folder in a machine-readable format.\nThis can be useful for external programs. +milestones_global_announcements=If checked, milestones will be announced to everyone. If unchecked will be announced only to your team. [shortcut-name] milestones_toggle_gui=Show milestones @@ -108,3 +110,4 @@ message_invalid_import_missing_field=[color=red]Invalid import string. Missing f message_invalid_next=[color=red]Invalid next value: [/color] message_invalid_initial_preset=[color=red]Milestones failed to load the initial preset from Mod Settings and will fall back to auto-detection. Error was:[/color] message_invalid_item=[color=red]Milestones removed an invalid item from the list of milestones: __1__[/color] +message_team_completion=[font=default-large-bold][color=__2__]__1__'s[/color] Team[/font] \ No newline at end of file diff --git a/presets/presets.lua b/presets/presets.lua index f20def4..65cd415 100644 --- a/presets/presets.lua +++ b/presets/presets.lua @@ -133,3 +133,4 @@ presets = { {type="item", name="raw-fish", quantity=1, quality="legendary"}, } }, +} \ No newline at end of file diff --git a/scripts/tracker.lua b/scripts/tracker.lua index 022cb46..15b40b3 100644 --- a/scripts/tracker.lua +++ b/scripts/tracker.lua @@ -45,6 +45,10 @@ local function write_milestone_to_file(force, milestone, human_timestamp) end end +local function colorTableToString(colourTable) + return string.format("%s,%s,%s", colourTable.r, colourTable.g, colourTable.b); +end + local function print_milestone_reached(force, milestone) local human_timestamp = format_time(milestone.completion_tick) local sprite_name = sprite_prefix(milestone) .. "." .. milestone.name @@ -104,10 +108,18 @@ local function print_milestone_reached(force, milestone) end end - force_print(force, message) + if (settings.global["milestones_global_announcements"].value) then + local colorStr = colorTableToString(force.custom_color or force.color); + local forceMsg = {"milestones.message_team_completion", force.players[1].name, colorStr}; + game.print({"", forceMsg, " ", message}) + game.play_sound{path="utility/achievement_unlocked"} + else + force.play_sound{path="utility/achievement_unlocked"} + force_print(force, message); + end + raise_milestone_reached_event(force, milestone, message) write_milestone_to_file(force, milestone, human_timestamp) - force.play_sound{path="utility/achievement_unlocked"} end function track_item_creation(event) diff --git a/settings.lua b/settings.lua index df4d936..98c59fb 100644 --- a/settings.lua +++ b/settings.lua @@ -57,5 +57,12 @@ data:extend{ setting_type = "runtime-per-user", default_value = false, order = "f", - } + }, + { + type = "bool-setting", + name = "milestones_global_announcements", + setting_type = "runtime-global", + default_value = true, + order = "g", + }, }