diff options
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 aa50069..f58b3d6 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 = "" |
@@ -451,6 +452,8 @@ func _on_data(): | |||
451 | i += 1 | 452 | i += 1 |
452 | 453 | ||
453 | elif cmd == "PrintJSON": | 454 | elif cmd == "PrintJSON": |
455 | parse_printjson(message) | ||
456 | |||
454 | if ( | 457 | if ( |
455 | !message.has("receiving") | 458 | !message.has("receiving") |
456 | or !message.has("item") | 459 | or !message.has("item") |
@@ -684,6 +687,10 @@ func setValue(key, value, operation = "replace"): | |||
684 | ) | 687 | ) |
685 | 688 | ||
686 | 689 | ||
690 | func say(textdata): | ||
691 | sendMessage([{"cmd": "Say", "text": textdata}]) | ||
692 | |||
693 | |||
687 | func completedGoal(): | 694 | func completedGoal(): |
688 | sendMessage([{"cmd": "StatusUpdate", "status": 30}]) # CLIENT_GOAL | 695 | sendMessage([{"cmd": "StatusUpdate", "status": 30}]) # CLIENT_GOAL |
689 | 696 | ||
@@ -855,6 +862,43 @@ func colorForItemType(flags): | |||
855 | return "#14de9e" | 862 | return "#14de9e" |
856 | 863 | ||
857 | 864 | ||
865 | func parse_printjson(message): | ||
866 | var parts = [] | ||
867 | for message_part in message["data"]: | ||
868 | if !message_part.has("type") and message_part.has("text"): | ||
869 | parts.append(message_part["text"]) | ||
870 | elif message_part["type"] == "player_id": | ||
871 | if int(message_part["text"]) == _slot: | ||
872 | parts.append("[color=#ee00ee]%s[/color]" % _player_name_by_slot[_slot]) | ||
873 | else: | ||
874 | var from = float(message_part["text"]) | ||
875 | parts.append("[color=#fafad2]%s[/color]" % _player_name_by_slot[from]) | ||
876 | elif message_part["type"] == "item_id": | ||
877 | var item_name = "Unknown" | ||
878 | var item_player_game = _game_by_player[message_part["player"]] | ||
879 | if _item_id_to_name[item_player_game].has(float(message_part["text"])): | ||
880 | item_name = _item_id_to_name[item_player_game][float(message_part["text"])] | ||
881 | |||
882 | parts.append( | ||
883 | "[color=%s]%s[/color]" % [colorForItemType(message_part["flags"]), item_name] | ||
884 | ) | ||
885 | elif message_part["type"] == "location_id": | ||
886 | var location_name = "Unknown" | ||
887 | var location_player_game = _game_by_player[message_part["player"]] | ||
888 | if _location_id_to_name[location_player_game].has(float(message_part["text"])): | ||
889 | location_name = _location_id_to_name[location_player_game][float( | ||
890 | message_part["text"] | ||
891 | )] | ||
892 | |||
893 | parts.append("[color=#00ff7f]%s[/color]" % location_name) | ||
894 | elif message_part.has("text"): | ||
895 | parts.append(message_part["text"]) | ||
896 | |||
897 | var textclient_node = get_tree().get_root().get_node_or_null("Spatial/AP_TextClient") | ||
898 | if textclient_node != null: | ||
899 | textclient_node.parse_printjson("".join(parts)) | ||
900 | |||
901 | |||
858 | func compareVersion(lhs, rhs): | 902 | func compareVersion(lhs, rhs): |
859 | if lhs["major"] == rhs["major"]: | 903 | if lhs["major"] == rhs["major"]: |
860 | if lhs["minor"] == rhs["minor"]: | 904 | if lhs["minor"] == rhs["minor"]: |