diff options
author | Star Rauchenberger <fefferburbia@gmail.com> | 2024-09-07 14:20:13 -0400 |
---|---|---|
committer | Star Rauchenberger <fefferburbia@gmail.com> | 2024-09-07 14:20:13 -0400 |
commit | f72463fda100ea858a154d6473111bc8edc1f697 (patch) | |
tree | 88691311f931422aa4297f0e174cc71000d807cb /Archipelago/client.gd | |
parent | 9ef676bab06b08f12e6fc8c8e2b56db70cea5ac3 (diff) | |
parent | 15fd151d4b7b4b86d65ae37386b96aae7cb6ba79 (diff) | |
download | lingo-archipelago-f72463fda100ea858a154d6473111bc8edc1f697.tar.gz lingo-archipelago-f72463fda100ea858a154d6473111bc8edc1f697.tar.bz2 lingo-archipelago-f72463fda100ea858a154d6473111bc8edc1f697.zip |
Merge branch 'main' into panels
Diffstat (limited to 'Archipelago/client.gd')
-rw-r--r-- | Archipelago/client.gd | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/Archipelago/client.gd b/Archipelago/client.gd index a990fa2..5f8be4e 100644 --- a/Archipelago/client.gd +++ b/Archipelago/client.gd | |||
@@ -8,6 +8,7 @@ var SCRIPT_mypainting | |||
8 | var SCRIPT_notifier | 8 | var SCRIPT_notifier |
9 | var SCRIPT_panel | 9 | var SCRIPT_panel |
10 | var SCRIPT_pilgrimage_terminator | 10 | var SCRIPT_pilgrimage_terminator |
11 | var SCRIPT_textclient | ||
11 | var SCRIPT_uuid | 12 | var SCRIPT_uuid |
12 | 13 | ||
13 | var ap_server = "" | 14 | var ap_server = "" |
@@ -467,6 +468,8 @@ func _on_data(): | |||
467 | i += 1 | 468 | i += 1 |
468 | 469 | ||
469 | elif cmd == "PrintJSON": | 470 | elif cmd == "PrintJSON": |
471 | parse_printjson(message) | ||
472 | |||
470 | if ( | 473 | if ( |
471 | !message.has("receiving") | 474 | !message.has("receiving") |
472 | or !message.has("item") | 475 | or !message.has("item") |
@@ -700,6 +703,10 @@ func setValue(key, value, operation = "replace"): | |||
700 | ) | 703 | ) |
701 | 704 | ||
702 | 705 | ||
706 | func say(textdata): | ||
707 | sendMessage([{"cmd": "Say", "text": textdata}]) | ||
708 | |||
709 | |||
703 | func completedGoal(): | 710 | func completedGoal(): |
704 | sendMessage([{"cmd": "StatusUpdate", "status": 30}]) # CLIENT_GOAL | 711 | sendMessage([{"cmd": "StatusUpdate", "status": 30}]) # CLIENT_GOAL |
705 | 712 | ||
@@ -892,6 +899,43 @@ func colorForItemType(flags): | |||
892 | return "#14de9e" | 899 | return "#14de9e" |
893 | 900 | ||
894 | 901 | ||
902 | func parse_printjson(message): | ||
903 | var parts = [] | ||
904 | for message_part in message["data"]: | ||
905 | if !message_part.has("type") and message_part.has("text"): | ||
906 | parts.append(message_part["text"]) | ||
907 | elif message_part["type"] == "player_id": | ||
908 | if int(message_part["text"]) == _slot: | ||
909 | parts.append("[color=#ee00ee]%s[/color]" % _player_name_by_slot[_slot]) | ||
910 | else: | ||
911 | var from = float(message_part["text"]) | ||
912 | parts.append("[color=#fafad2]%s[/color]" % _player_name_by_slot[from]) | ||
913 | elif message_part["type"] == "item_id": | ||
914 | var item_name = "Unknown" | ||
915 | var item_player_game = _game_by_player[message_part["player"]] | ||
916 | if _item_id_to_name[item_player_game].has(float(message_part["text"])): | ||
917 | item_name = _item_id_to_name[item_player_game][float(message_part["text"])] | ||
918 | |||
919 | parts.append( | ||
920 | "[color=%s]%s[/color]" % [colorForItemType(message_part["flags"]), item_name] | ||
921 | ) | ||
922 | elif message_part["type"] == "location_id": | ||
923 | var location_name = "Unknown" | ||
924 | var location_player_game = _game_by_player[message_part["player"]] | ||
925 | if _location_id_to_name[location_player_game].has(float(message_part["text"])): | ||
926 | location_name = _location_id_to_name[location_player_game][float( | ||
927 | message_part["text"] | ||
928 | )] | ||
929 | |||
930 | parts.append("[color=#00ff7f]%s[/color]" % location_name) | ||
931 | elif message_part.has("text"): | ||
932 | parts.append(message_part["text"]) | ||
933 | |||
934 | var textclient_node = get_tree().get_root().get_node_or_null("Spatial/AP_TextClient") | ||
935 | if textclient_node != null: | ||
936 | textclient_node.parse_printjson("".join(parts)) | ||
937 | |||
938 | |||
895 | func compareVersion(lhs, rhs): | 939 | func compareVersion(lhs, rhs): |
896 | if lhs["major"] == rhs["major"]: | 940 | if lhs["major"] == rhs["major"]: |
897 | if lhs["minor"] == rhs["minor"]: | 941 | if lhs["minor"] == rhs["minor"]: |