fixes for set-goal set-goal-v1.0.1

Sun, 29 Jun 2025 18:27:23 +0300

author
Teemu Piippo <teemu.s.piippo@gmail.com>
date
Sun, 29 Jun 2025 18:27:23 +0300
changeset 3
b0344856f104
parent 2
415dcf69f5f5
child 4
01053f3be1a6

fixes for set-goal

set-goal/changelog.txt file | annotate | diff | comparison | revisions
set-goal/control.lua file | annotate | diff | comparison | revisions
set-goal/data.lua file | annotate | diff | comparison | revisions
set-goal/info.json file | annotate | diff | comparison | revisions
set-goal/locale/en/set-goal.cfg file | annotate | diff | comparison | revisions
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/set-goal/changelog.txt	Sun Jun 29 18:27:23 2025 +0300
@@ -0,0 +1,8 @@
+---------------------------------------------------------------------------------------------------
+Version: 1.0.1
+Date: 2025-06-29
+  Changes:
+    - Changed mod name to "Set objective" to be consistent with the word "objective"
+  Bugfixes:
+    - Fixed the default control shortcut not working
+    - Fixed missing strings
--- a/set-goal/control.lua	Sun Jun 29 18:27:00 2025 +0300
+++ b/set-goal/control.lua	Sun Jun 29 18:27:23 2025 +0300
@@ -8,9 +8,20 @@
 			caption = {"set-goal-gui.title"},
 			direction = "vertical"
 		}
+		local goal_description_text = player.get_goal_description()
+		if type(goal_description_text) == "table"
+		then
+			local translation_request_id = player.request_translation(goal_description_text)
+			goal_description_text = ""
+			if not storage.translation_requests
+			then
+				storage.translation_requests = {}
+			end
+			storage.translation_requests[translation_request_id] = {player_index=event.player_index, type = "goal-description"}
+		end
 		frame.add{
 			type = "text-box",
-			text = player.get_goal_description(),
+			text = goal_description_text,
 			name = "goal-description",
 			style = "set-goal-gui-textbox",
 			icon_selector = true,
@@ -50,7 +61,7 @@
 		then
 			if event.element.tags.action == "confirm"
 			then
-				player.set_goal_description(player.gui.goal["set-goal"]["goal-description"].text)
+				player.set_goal_description(player.gui.goal["set-goal"]["goal-description"].text, player.get_goal_description() ~= "")
 				player.gui.goal["set-goal"].destroy()
 			elseif event.element.tags.action == "close"
 			then
@@ -69,4 +80,19 @@
 			open_gui(event)
 		end
 	end
+)
+
+script.on_event(defines.events.on_string_translated,
+	function(event)
+		local player = game.players[event.player_index]
+		if storage.translation_requests
+		then
+			local request_data = storage.translation_requests[event.id]
+			if request_data and request_data.type == "goal-description" and player.gui.goal["set-goal"] and player.gui.goal["set-goal"]["goal-description"]
+			then
+				player.gui.goal["set-goal"]["goal-description"].text = event.result
+			end
+			storage.translation_requests[event.id] = nil
+		end
+	end
 )
\ No newline at end of file
--- a/set-goal/data.lua	Sun Jun 29 18:27:00 2025 +0300
+++ b/set-goal/data.lua	Sun Jun 29 18:27:23 2025 +0300
@@ -3,7 +3,7 @@
 		type = "custom-input",
 		name = "open-set-goal-gui",
 		order = "open-set-goal-gui",
-		key_sequence = "Shift + G"
+		key_sequence = "SHIFT + G"
 	},
 	{
 		type = "shortcut",
--- a/set-goal/info.json	Sun Jun 29 18:27:00 2025 +0300
+++ b/set-goal/info.json	Sun Jun 29 18:27:23 2025 +0300
@@ -1,9 +1,9 @@
 {
     "name": "set-goal",
-    "title": "Set goal",
-    "description": "Adds a simple GUI to change your objective description.",
+    "title": "Set objective",
+    "description": "Take control over the \"objective\" window and write whatever you want into it, maybe use it as a to-do list.",
     "author": "teemu",
-    "version": "1.0.0",
+    "version": "1.0.1",
     "factorio_version": "2.0",
     "dependencies": ["base"]
 }
\ No newline at end of file
--- a/set-goal/locale/en/set-goal.cfg	Sun Jun 29 18:27:00 2025 +0300
+++ b/set-goal/locale/en/set-goal.cfg	Sun Jun 29 18:27:23 2025 +0300
@@ -3,4 +3,6 @@
 close-tooltip=Close this window and discard any changes.
 confirm-tooltip=Confirm changes.
 [shortcut-name]
-open-set-goal-gui=Change your objective
\ No newline at end of file
+open-set-goal-gui=Open the "set objective" window
+[controls]
+open-set-goal-gui=Open the "set objective" window
\ No newline at end of file

mercurial