Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions locale/en/milestones.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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]
1 change: 1 addition & 0 deletions presets/presets.lua
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,4 @@ presets = {
{type="item", name="raw-fish", quantity=1, quality="legendary"},
}
},
}
16 changes: 14 additions & 2 deletions scripts/tracker.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
9 changes: 8 additions & 1 deletion settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
}