From 0d7a3fb0f14a4e309e5175c34a32684c51e5353a Mon Sep 17 00:00:00 2001 From: Lucia Ceionia Date: Tue, 5 Nov 2024 17:55:16 -0600 Subject: [PATCH] bbcode update - 0.4 --- Godot/mods/Lucy.LucysTools/lucys_menu.gd | 54 +++-- Godot/mods/Lucy.LucysTools/lucys_menu.tscn | 100 +++++++-- Godot/mods/Lucy.LucysTools/main.gd | 124 ++++++++--- LucysTools/Mod.cs | 242 ++++++--------------- 4 files changed, 288 insertions(+), 232 deletions(-) diff --git a/Godot/mods/Lucy.LucysTools/lucys_menu.gd b/Godot/mods/Lucy.LucysTools/lucys_menu.gd index 9feb485..ce05120 100644 --- a/Godot/mods/Lucy.LucysTools/lucys_menu.gd +++ b/Godot/mods/Lucy.LucysTools/lucys_menu.gd @@ -1,31 +1,53 @@ extends Control -var MANAGER = null +var MANAGER -func setup(manager): - MANAGER = manager - get_node("%lucy_bbcode").pressed = manager.allow_bbcode - get_node("%lucy_punchback").pressed = manager.do_punchback - get_node("%lucy_servername").text = manager.custom_server_name - get_node("%lucy_servername_preview").bbcode_text = manager.custom_server_name + "'s Lobby" - get_node("%lucy_servermsg").text = manager.server_join_message - get_node("%lucy_servermsg_preview").bbcode_text = manager.server_join_message - get_node("%lucy_fpackets").value = manager.frame_packets - get_node("%lucy_bpackets").value = manager.bulk_packets - get_node("%lucy_binterval").value = manager.bulk_interval - get_node("%lucy_finterval").value = manager.full_interval +func setup(): + get_node("%lucy_bbcode").pressed = MANAGER.allow_bbcode + get_node("%lucy_punchback").pressed = MANAGER.do_punchback + get_node("%lucy_servername").text = MANAGER.custom_server_name + get_node("%lucy_servername_preview").bbcode_text = MANAGER.custom_server_name + "'s Lobby" + get_node("%lucy_servermsg").text = MANAGER.server_join_message + get_node("%lucy_servermsg_preview").bbcode_text = MANAGER.server_join_message + get_node("%lucy_fpackets").value = MANAGER.frame_packets + get_node("%lucy_bpackets").value = MANAGER.bulk_packets + get_node("%lucy_binterval").value = MANAGER.bulk_interval + get_node("%lucy_finterval").value = MANAGER.full_interval - get_node("%lucy_chatcolor_bool").pressed = manager.custom_color_enabled - get_node("%lucy_chatcolor").color = Color(manager.custom_color) + get_node("%lucy_intbbcode").pressed = MANAGER.allow_intrusive_bbcode + + get_node("%lucy_chatcolor_bool").pressed = MANAGER.custom_color_enabled + get_node("%lucy_chatcolor").color = Color(MANAGER.custom_color) + + get_node("%lucy_name").text = MANAGER.custom_name update() + func update(): get_node("%lucy_srv_allow_bbcode").text = "Yes" if MANAGER.srv_allow_bbcode else "No" + _on_lucy_name_text_changed(MANAGER.custom_name) + + +func _on_lucy_name_text_changed(new_text): + var result = MANAGER.bbcode_process(new_text) + #print("[fin] ", result.fin) + #print("[tags] ", result.tags) + #print("[stripped] ", result.stripped) + + var lol_steam_username = Network.STEAM_USERNAME.replace("[", "").replace("]", "") + var good = result.stripped == lol_steam_username + get_node("%lucy_name_preview").bbcode_text = result.fin + get_node("%lucy_namegood").bbcode_text = "[color=green]Good[/color]" if good else "[color=red]Bad[/color]" + + MANAGER.custom_name_enabled = good + MANAGER.custom_name = result.fin func _ready(): print("[LUCY] Menu Ready") + MANAGER = $"/root/LucyLucysTools" + get_node("%lucy_bbcode").disabled = MANAGER.host_required and not Network.GAME_MASTER get_node("%lucy_raincloud").disabled = not Network.GAME_MASTER or not MANAGER.ingame get_node("%lucy_meteor").disabled = not Network.GAME_MASTER or not MANAGER.ingame @@ -68,6 +90,8 @@ func _on_lucy_chatcolor_bool_toggled(button_pressed): MANAGER.custom_color_enabled = button_pressed func _on_lucy_chatcolor_color_changed(color): MANAGER.custom_color = color +func _on_lucy_intbbcode_toggled(button_pressed): + MANAGER.allow_intrusive_bbcode = button_pressed func _on_lucy_raincloud_pressed(): if not MANAGER.ingame: return diff --git a/Godot/mods/Lucy.LucysTools/lucys_menu.tscn b/Godot/mods/Lucy.LucysTools/lucys_menu.tscn index e61f3f6..3a67ef7 100644 --- a/Godot/mods/Lucy.LucysTools/lucys_menu.tscn +++ b/Godot/mods/Lucy.LucysTools/lucys_menu.tscn @@ -36,27 +36,40 @@ rect_pivot_offset = Vector2( -141, -49 ) [node name="Label" type="Label" parent="PanelContainer/VBoxContainer/HFlowContainer"] margin_top = 13.0 -margin_right = 286.0 +margin_right = 138.0 margin_bottom = 27.0 -text = "Allow BBCode in Chat (start message with %)" +text = "Allow BBCode (Client)" [node name="lucy_bbcode" type="CheckButton" parent="PanelContainer/VBoxContainer/HFlowContainer"] unique_name_in_owner = true -margin_left = 290.0 -margin_right = 366.0 +margin_left = 142.0 +margin_right = 218.0 +margin_bottom = 40.0 + +[node name="Label3" type="Label" parent="PanelContainer/VBoxContainer/HFlowContainer"] +margin_left = 222.0 +margin_top = 13.0 +margin_right = 471.0 +margin_bottom = 27.0 +text = "Allow Intrusive BBCode (requires Host)" + +[node name="lucy_intbbcode" type="CheckButton" parent="PanelContainer/VBoxContainer/HFlowContainer"] +unique_name_in_owner = true +margin_left = 475.0 +margin_right = 551.0 margin_bottom = 40.0 [node name="Label2" type="Label" parent="PanelContainer/VBoxContainer/HFlowContainer"] -margin_left = 370.0 +margin_left = 555.0 margin_top = 13.0 -margin_right = 505.0 +margin_right = 690.0 margin_bottom = 27.0 text = "Punch back on Punch" [node name="lucy_punchback" type="CheckButton" parent="PanelContainer/VBoxContainer/HFlowContainer"] unique_name_in_owner = true -margin_left = 509.0 -margin_right = 585.0 +margin_left = 694.0 +margin_right = 770.0 margin_bottom = 40.0 [node name="HFlowContainer3" type="HFlowContainer" parent="PanelContainer/VBoxContainer"] @@ -66,14 +79,14 @@ margin_bottom = 84.0 rect_pivot_offset = Vector2( -141, -49 ) [node name="Label" type="Label" parent="PanelContainer/VBoxContainer/HFlowContainer3"] -margin_right = 196.0 +margin_right = 199.0 margin_bottom = 14.0 -text = "Server Allows BBCode in Chat: " +text = "Host Allows Intrusive BBCode: " [node name="lucy_srv_allow_bbcode" type="Label" parent="PanelContainer/VBoxContainer/HFlowContainer3"] unique_name_in_owner = true -margin_left = 200.0 -margin_right = 218.0 +margin_left = 203.0 +margin_right = 221.0 margin_bottom = 14.0 text = "No" @@ -203,10 +216,51 @@ margin_bottom = 24.0 rect_min_size = Vector2( 42, 0 ) edit_alpha = false -[node name="HFlowContainer2" type="HFlowContainer" parent="PanelContainer/VBoxContainer"] +[node name="HFlowContainer9" type="HFlowContainer" parent="PanelContainer/VBoxContainer"] margin_top = 232.0 margin_right = 786.0 -margin_bottom = 252.0 +margin_bottom = 256.0 +rect_pivot_offset = Vector2( -141, -49 ) +hint_tooltip = "Must match Steam username" + +[node name="Label" type="Label" parent="PanelContainer/VBoxContainer/HFlowContainer9"] +margin_top = 5.0 +margin_right = 91.0 +margin_bottom = 19.0 +text = "Custom Name" + +[node name="lucy_namegood" type="RichTextLabel" parent="PanelContainer/VBoxContainer/HFlowContainer9"] +unique_name_in_owner = true +margin_left = 95.0 +margin_right = 145.0 +margin_bottom = 24.0 +rect_min_size = Vector2( 50, 0 ) +bbcode_enabled = true +bbcode_text = "[color=green]Good[/color]" +text = "Good" +scroll_active = false + +[node name="lucy_name" type="LineEdit" parent="PanelContainer/VBoxContainer/HFlowContainer9"] +unique_name_in_owner = true +margin_left = 149.0 +margin_right = 207.0 +margin_bottom = 24.0 +expand_to_text_length = true +placeholder_text = "Name" + +[node name="lucy_name_preview" type="RichTextLabel" parent="PanelContainer/VBoxContainer/HFlowContainer9"] +unique_name_in_owner = true +margin_left = 211.0 +margin_right = 786.0 +margin_bottom = 24.0 +size_flags_horizontal = 3 +bbcode_enabled = true +scroll_active = false + +[node name="HFlowContainer2" type="HFlowContainer" parent="PanelContainer/VBoxContainer"] +margin_top = 260.0 +margin_right = 786.0 +margin_bottom = 280.0 [node name="lucy_clearchat" type="Button" parent="PanelContainer/VBoxContainer/HFlowContainer2"] margin_right = 76.0 @@ -250,14 +304,14 @@ margin_bottom = 20.0 text = "Clear Meteor" [node name="HSeparator2" type="HSeparator" parent="PanelContainer/VBoxContainer"] -margin_top = 256.0 -margin_right = 786.0 -margin_bottom = 260.0 - -[node name="HSplitContainer" type="HSplitContainer" parent="PanelContainer/VBoxContainer"] -margin_top = 264.0 +margin_top = 284.0 margin_right = 786.0 margin_bottom = 288.0 + +[node name="HSplitContainer" type="HSplitContainer" parent="PanelContainer/VBoxContainer"] +margin_top = 292.0 +margin_right = 786.0 +margin_bottom = 316.0 split_offset = 100 [node name="HFlowContainer3" type="HFlowContainer" parent="PanelContainer/VBoxContainer/HSplitContainer"] @@ -302,9 +356,9 @@ rounded = true allow_greater = true [node name="HSplitContainer2" type="HSplitContainer" parent="PanelContainer/VBoxContainer"] -margin_top = 292.0 +margin_top = 320.0 margin_right = 786.0 -margin_bottom = 316.0 +margin_bottom = 344.0 split_offset = 100 [node name="HFlowContainer3" type="HFlowContainer" parent="PanelContainer/VBoxContainer/HSplitContainer2"] @@ -349,11 +403,13 @@ value = 6.4 allow_greater = true [connection signal="toggled" from="PanelContainer/VBoxContainer/HFlowContainer/lucy_bbcode" to="." method="_on_lucy_bbcode_toggled"] +[connection signal="toggled" from="PanelContainer/VBoxContainer/HFlowContainer/lucy_intbbcode" to="." method="_on_lucy_intbbcode_toggled"] [connection signal="toggled" from="PanelContainer/VBoxContainer/HFlowContainer/lucy_punchback" to="." method="_on_lucy_punchback_toggled"] [connection signal="text_changed" from="PanelContainer/VBoxContainer/HFlowContainer4/lucy_servername" to="." method="_on_lucy_servername_text_changed"] [connection signal="text_changed" from="PanelContainer/VBoxContainer/HFlowContainer5/lucy_servermsg" to="." method="_on_lucy_servermsg_text_changed"] [connection signal="toggled" from="PanelContainer/VBoxContainer/HFlowContainer8/lucy_chatcolor_bool" to="." method="_on_lucy_chatcolor_bool_toggled"] [connection signal="color_changed" from="PanelContainer/VBoxContainer/HFlowContainer8/lucy_chatcolor" to="." method="_on_lucy_chatcolor_color_changed"] +[connection signal="text_changed" from="PanelContainer/VBoxContainer/HFlowContainer9/lucy_name" to="." method="_on_lucy_name_text_changed"] [connection signal="pressed" from="PanelContainer/VBoxContainer/HFlowContainer2/lucy_clearchat" to="." method="_on_lucy_clearchat_pressed"] [connection signal="pressed" from="PanelContainer/VBoxContainer/HFlowContainer2/lucy_raincloud" to="." method="_on_lucy_raincloud_pressed"] [connection signal="pressed" from="PanelContainer/VBoxContainer/HFlowContainer2/lucy_meteor" to="." method="_on_lucy_meteor_pressed"] diff --git a/Godot/mods/Lucy.LucysTools/main.gd b/Godot/mods/Lucy.LucysTools/main.gd index 938b325..aa966c9 100644 --- a/Godot/mods/Lucy.LucysTools/main.gd +++ b/Godot/mods/Lucy.LucysTools/main.gd @@ -2,13 +2,11 @@ extends Node const LUCYS_MENU_SCENE = preload("res://mods/Lucy.LucysTools/lucys_menu.tscn") -var host_required = true - var lucys_menu = null onready var root = get_tree().root -var do_punchback = false setget set_punchback -var allow_bbcode = false setget set_bbcode +var do_punchback = false +var allow_bbcode = false var custom_server_name = "" setget set_server_name var server_join_message = "[color=#5BCEFA]TRAN[/color][color=#F5A9B8]S RIG[/color][color=#ffffff]HTS![/color]" setget set_join_message var frame_packets = 50 setget set_frame_packets @@ -16,13 +14,59 @@ var bulk_packets = 200 setget set_bulk_packets var bulk_interval = 1 setget set_bulk_interval var full_interval = 5 setget set_full_interval -var custom_color_enabled = false setget set_custom_color_enabled +var custom_color_enabled = false var custom_color = Color("009cd0") setget set_custom_color +var custom_name_enabled = false +var custom_name = "" + +var allow_intrusive_bbcode = false setget set_allow_intrusive_bbcode var srv_allow_bbcode = false setget set_srv_bbcode var log_messages = false setget set_log_messages + +var allowed_tags = ["b", "i", "u", "s", "color"] +var escape_invalid = true +var bbcode_matcher = null + +# i know this sucks +# but i have things to do +func bbcode_recurse(text, data): + var m = bbcode_matcher.search(text) + if m == null: + var escaped = text.replace('[lb]','[').replace('[','[lb]') if escape_invalid else text + data.fin += escaped + data.stripped += escaped + else: + #print("Found ", m.strings, " in '", text, "'") + bbcode_recurse(m.get_string(1), data) + var tag = m.get_string(2) + var junk = m.get_string(3) + var allowed = tag in allowed_tags + if allowed: + data.fin += "[" + tag + junk + "]" + else: + data.fin += "[lb]" + tag + junk + "]" + data.stripped += "[lb]" + tag + junk + "]" + #print("TAG ", m.get_string(2), " JUNK ", m.get_string(3)) + data.tags.append([tag, junk]) + bbcode_recurse(m.get_string(4), data) + if allowed: + data.fin += "[/" + tag + "]" + else: + data.fin += "[lb]/" + tag + "]" + data.stripped += "[lb]/" + tag + "]" + bbcode_recurse(m.get_string(5), data) + +func bbcode_process(text): + bbcode_matcher = RegEx.new() + bbcode_matcher.compile("^(.*?)\\[(\\w+?)([^\\]]*)\\](.+?)\\[/\\2\\](.*?)$") + #print("processing '", text, "'") + var data = {"fin": "", "tags": [], "stripped": ""} + bbcode_recurse(text, data) + return data + # Patched Network vars # var LUCY_PACKETS_READ = 0 # var LUCY_BULK_FULL_TIMER = 0 @@ -30,30 +74,62 @@ var log_messages = false setget set_log_messages # var LUCY_BULK_PACKETS = 128 # var LUCY_BULK_INTERVAL = 0.8 # var LUCY_BULK_FULL_INTERVAL = 6.4 -# var LUCY_CHAT_BBCODE # var LUCY_SRV_NAME # var LUCY_PUNCHED_ME # var LUCY_INSTANCE_SENDER -# var LUCY_CUSTOM_COLOR_B -# var LUCY_CUSTOM_COLOR # var LUCY_LOG_MESSAGES var ingame = false +func process_message(lit_text, final_text, prefix, suffix, endcap, username, final_color, spoken_text): + var thing = { + "lit_text": lit_text, "final_text": final_text, "prefix": prefix, "suffix": suffix, + "endcap": endcap, "username": username, "final_color": final_color, + "srv_allow_bbcode": srv_allow_bbcode, "custom_color_enabled": custom_color_enabled, + "custom_name_enabled": custom_name_enabled, "allow_bbcode": allow_bbcode, + "allowed_tags": allowed_tags + } + #print("FUCK ", thing) + if srv_allow_bbcode and lit_text.begins_with("%"): + return [lit_text.trim_prefix('%'), spoken_text] + + var name = custom_name if custom_name_enabled else username + var color = custom_color if custom_color_enabled else final_color + var msg = final_text + var speak = spoken_text + if allow_bbcode: + var p = bbcode_process(lit_text) + if not p.tags.empty(): + msg = p.fin + speak = p.stripped + return [ + prefix + "[color=#" + str(color.to_html()) + "]" + name + endcap + msg + suffix, + speak + ] + +func bbcode_changes(): + if srv_allow_bbcode and allow_intrusive_bbcode: + allowed_tags = [ + "b", "i", "u", "s", "color", + "wave", "rainbow", "shake", "tornado", "font"] + else: + allowed_tags = [ + "b", "i", "u", "s", "color"] + if lucys_menu != null: lucys_menu.update() + func set_log_messages(val): log_messages = val Network.LUCY_LOG_MESSAGES = val -func set_punchback(punchback): - do_punchback = punchback -func set_bbcode(bbcode): - allow_bbcode = bbcode - if Network.GAME_MASTER or not host_required: self.srv_allow_bbcode = bbcode +func set_allow_intrusive_bbcode(bbcode): + allow_intrusive_bbcode = bbcode + if Network.GAME_MASTER or not ingame: + self.srv_allow_bbcode = bbcode + else: bbcode_changes() func set_srv_bbcode(bbcode): if Network.GAME_MASTER and not Network.PLAYING_OFFLINE: send_server_sync_actor() srv_allow_bbcode = bbcode - Network.LUCY_CHAT_BBCODE = bbcode if host_required else allow_bbcode - if lucys_menu != null: lucys_menu.update() + bbcode_changes() func set_server_name(name): custom_server_name = name Network.LUCY_SRV_NAME = name @@ -73,13 +149,9 @@ func set_full_interval(val): full_interval = val Network.LUCY_BULK_FULL_INTERVAL = val Network.LUCY_BULK_FULL_TIMER = 0 -func set_custom_color_enabled(val): - custom_color_enabled = val - Network.LUCY_CUSTOM_COLOR_B = val func set_custom_color(val): - custom_color = Color(val) + custom_color = Color(val) if Color(val) != Color("d5aa73") else Color("739ed5") custom_color.a = 1 - Network.LUCY_CUSTOM_COLOR = Color(custom_color) if Color(custom_color) != Color("d5aa73") else Color("739ed5") func _ready(): print("[LUCY] Loaded LucysTools") @@ -88,7 +160,6 @@ func _ready(): Network.connect("_new_player_join", self, "new_player") PlayerData.connect("_punched", self, "punched") Network.connect("_instance_actor", self, "_instance_actor") - func send_server_sync_actor(to = "peers"): if not Network.GAME_MASTER: return @@ -135,17 +206,19 @@ func new_player(id): func _on_enter(node: Node): if node.name == "main_menu": lucys_menu = LUCYS_MENU_SCENE.instance() + lucys_menu.MANAGER = self node.add_child(lucys_menu) ingame = false - lucys_menu.setup(self) + lucys_menu.setup() if node.name == "playerhud": lucys_menu = LUCYS_MENU_SCENE.instance() + lucys_menu.MANAGER = self node.add_child(lucys_menu) ingame = true # retrigger setter self.srv_allow_bbcode = false - self.allow_bbcode = allow_bbcode - lucys_menu.setup(self) + self.allow_intrusive_bbcode = allow_intrusive_bbcode + lucys_menu.setup() const save_keys = [ "do_punchback", "allow_bbcode", @@ -153,7 +226,8 @@ const save_keys = [ "frame_packets", "bulk_packets", "bulk_interval", "full_interval", "custom_color_enabled", "custom_color", - "log_messages" + "log_messages", "custom_name", + "allow_intrusive_bbcode" ] func load_settings(): diff --git a/LucysTools/Mod.cs b/LucysTools/Mod.cs index 9dd40ec..17b707d 100644 --- a/LucysTools/Mod.cs +++ b/LucysTools/Mod.cs @@ -31,65 +31,9 @@ public class LucysChatChanges : IScriptMod CodeChange[] changes = { new CodeChange { - name = "_send_message literal input", - // func _send_message(text): - // END - multitoken_prefix = new Func[] { - t => t.Type == TokenType.PrFunction, - t => t is IdentifierToken {Name: "_send_message"}, - t => t.Type == TokenType.ParenthesisOpen, - t => t.Type == TokenType.Identifier, - t => t.Type == TokenType.ParenthesisClose, - t => t.Type == TokenType.Colon, - t => t.Type == TokenType.Newline, - }, - // if text.begins_with('%') and Network.LUCY_CHAT_BBCODE): - // text = text.trim_prefix('%') - // Network._send_message(text, chat_local) - // return - // END - code_to_add = new Token[] { - new Token(TokenType.CfIf), - new IdentifierToken("text"), - new Token(TokenType.Period), - new IdentifierToken("begins_with"), - new Token(TokenType.ParenthesisOpen), - new ConstantToken(new StringVariant("%")), - new Token(TokenType.ParenthesisClose), - new Token(TokenType.OpAnd), - new IdentifierToken("Network"), - new Token(TokenType.Period), - new IdentifierToken("LUCY_CHAT_BBCODE"), - new Token(TokenType.Colon), - new Token(TokenType.Newline,2), - new IdentifierToken("text"), - new Token(TokenType.OpAssign), - new IdentifierToken("text"), - new Token(TokenType.Period), - new IdentifierToken("trim_prefix"), - new Token(TokenType.ParenthesisOpen), - new ConstantToken(new StringVariant("%")), - new Token(TokenType.ParenthesisClose), - new Token(TokenType.Newline,2), - new IdentifierToken("Network"), - new Token(TokenType.Period), - new IdentifierToken("_send_message"), - new Token(TokenType.ParenthesisOpen), - new IdentifierToken("text"), - new Token(TokenType.Comma), - new IdentifierToken("chat_local"), - new Token(TokenType.ParenthesisClose), - new Token(TokenType.Newline,2), - new Token(TokenType.CfReturn), - new Token(TokenType.Newline,1), - } - }, - - new CodeChange { - name = "[ filter", + name = "save lit text", // color.to_html() // - // // END multitoken_prefix = new Func[] { t => t is IdentifierToken {Name: "color"}, @@ -99,102 +43,81 @@ public class LucysChatChanges : IScriptMod t => t.Type == TokenType.ParenthesisClose, t => t.Type == TokenType.Newline, t => t.Type == TokenType.Newline, - t => t.Type == TokenType.Newline, }, - // if not Network.LUCY_CHAT_BBCODE: END + // var lit_text = text code_to_add = new Token[] { - new Token(TokenType.CfIf), - new Token(TokenType.OpNot), - new IdentifierToken("Network"), - new Token(TokenType.Period), - new IdentifierToken("LUCY_CHAT_BBCODE"), - new Token(TokenType.Colon), - } - }, - - new CodeChange { - name = "] filter", - // text = text.replace('[','') - // END - multitoken_prefix = new Func[] { - t => t is IdentifierToken {Name: "text"}, - t => t.Type == TokenType.OpAssign, - t => t is IdentifierToken {Name: "text"}, - t => t.Type == TokenType.Period, - t => t is IdentifierToken {Name: "replace"}, - t => t.Type == TokenType.ParenthesisOpen, - t => t is ConstantToken {Value:StringVariant{Value: "["}}, - t => t.Type == TokenType.Comma, - t => t.Type == TokenType.Constant, - t => t.Type == TokenType.ParenthesisClose, - t => t.Type == TokenType.Newline, - }, - // if not Network.LUCY_CHAT_BBCODE: END - code_to_add = new Token[] { - new Token(TokenType.CfIf), - new Token(TokenType.OpNot), - new IdentifierToken("Network"), - new Token(TokenType.Period), - new IdentifierToken("LUCY_CHAT_BBCODE"), - new Token(TokenType.Colon), - } - }, - - new CodeChange { - name = "breakdown [ filter", - // elif line.begins_with('[') END - multitoken_prefix = new Func[] { - t => t.Type == TokenType.CfElif, - t => t is IdentifierToken {Name: "line"}, - t => t.Type == TokenType.Period, - t => t is IdentifierToken {Name: "begins_with"}, - t => t.Type == TokenType.ParenthesisOpen, - t => t is ConstantToken {Value:StringVariant{Value: "["}}, - t => t.Type == TokenType.ParenthesisClose, - }, - // and false END - code_to_add = new Token[] { - new Token(TokenType.OpAnd), - new ConstantToken(new BoolVariant(false)), - } - }, - - new CodeChange { - name = "custom chat color support", - // var final_color = Color(color) * Color(0.95, 0.9, 0.9) - // END - multitoken_prefix = new Func[] { - t => t.Type == TokenType.PrVar, - t => t is IdentifierToken {Name: "final_color"}, - t => t.Type == TokenType.OpAssign, - t => t.Type == TokenType.BuiltInType && t.AssociatedData == (uint)VariantType.Color, - t => t.Type == TokenType.ParenthesisOpen, - t => t is IdentifierToken {Name: "color"}, - t => t.Type == TokenType.ParenthesisClose, - t => t.Type == TokenType.OpMul, - t => t.Type == TokenType.BuiltInType && t.AssociatedData == (uint)VariantType.Color, - t => t.Type == TokenType.ParenthesisOpen, - t => t is ConstantToken, - t => t.Type == TokenType.Comma, - t => t is ConstantToken, - t => t.Type == TokenType.Comma, - t => t is ConstantToken, - t => t.Type == TokenType.ParenthesisClose, - t => t.Type == TokenType.Newline, - }, - // if Network.LUCY_CUSTOM_COLOR_B: final_color = LUCY_CUSTOM_COLOR - // END - code_to_add = new Token[] { - new Token(TokenType.CfIf), - new IdentifierToken("Network"), - new Token(TokenType.Period), - new IdentifierToken("LUCY_CUSTOM_COLOR_B"), - new Token(TokenType.Colon), - new IdentifierToken("final_color"), + new Token(TokenType.PrVar), + new IdentifierToken("lit_text"), new Token(TokenType.OpAssign), - new IdentifierToken("Network"), + new IdentifierToken("text"), + new Token(TokenType.Newline, 1), + } + }, + + new CodeChange { + name = "chat bbcode", + // endcap + final_text + suffix + // END + multitoken_prefix = new Func[] { + t => t is IdentifierToken {Name: "endcap"}, + t => t.Type == TokenType.OpAdd, + t => t is IdentifierToken {Name: "final_text"}, + t => t.Type == TokenType.OpAdd, + t => t is IdentifierToken {Name: "suffix"}, + t => t.Type == TokenType.Newline, + }, + // if $"/root/LucyLucysTools": + // var tmp = $"/root/LucyLucysTools".process_message(lit_text, final_text, prefix, suffix, endcap, username, spoken_text) + // final = tmp[0] + // spoken_text = tmp[1] + // END + code_to_add = new Token[] { + new Token(TokenType.CfIf), + new Token(TokenType.Dollar), + new ConstantToken(new StringVariant("/root/LucyLucysTools")), + new Token(TokenType.Colon), + new Token(TokenType.Newline, 2), + + new Token(TokenType.PrVar), + new IdentifierToken("tmp"), + new Token(TokenType.OpAssign), + new Token(TokenType.Dollar), + new ConstantToken(new StringVariant("/root/LucyLucysTools")), new Token(TokenType.Period), - new IdentifierToken("LUCY_CUSTOM_COLOR"), + new IdentifierToken("process_message"), + new Token(TokenType.ParenthesisOpen), + new IdentifierToken("lit_text"), + new Token(TokenType.Comma), + new IdentifierToken("final_text"), + new Token(TokenType.Comma), + new IdentifierToken("prefix"), + new Token(TokenType.Comma), + new IdentifierToken("suffix"), + new Token(TokenType.Comma), + new IdentifierToken("endcap"), + new Token(TokenType.Comma), + new IdentifierToken("username"), + new Token(TokenType.Comma), + new IdentifierToken("final_color"), + new Token(TokenType.Comma), + new IdentifierToken("spoken_text"), + new Token(TokenType.ParenthesisClose), + new Token(TokenType.Newline, 2), + + new IdentifierToken("final"), + new Token(TokenType.OpAssign), + new IdentifierToken("tmp"), + new Token(TokenType.BracketOpen), + new ConstantToken(new IntVariant(0)), + new Token(TokenType.BracketClose), + new Token(TokenType.Newline, 2), + + new IdentifierToken("spoken_text"), + new Token(TokenType.OpAssign), + new IdentifierToken("tmp"), + new Token(TokenType.BracketOpen), + new ConstantToken(new IntVariant(1)), + new Token(TokenType.BracketClose), new Token(TokenType.Newline, 1), } }, @@ -758,12 +681,9 @@ public class LucysNetFixes : IScriptMod { // var LUCY_BULK_PACKETS = 128 // var LUCY_BULK_INTERVAL = 0.8 // var LUCY_BULK_FULL_INTERVAL = 6.4 - // var LUCY_CHAT_BBCODE = false // var LUCY_SRV_NAME = "" // var LUCY_PUNCHED_ME = 0 // var LUCY_INSTANCE_SENDER = 0 - // var LUCY_CUSTOM_COLOR_B = false - // var LUCY_CUSTOM_COLOR = 0 // var LUCY_LOG_MESSAGES = false // END code_to_add = new Token[] { @@ -803,12 +723,6 @@ public class LucysNetFixes : IScriptMod { new ConstantToken(new RealVariant(6.4)), new Token(TokenType.Newline, 0), - new Token(TokenType.PrVar), - new IdentifierToken("LUCY_CHAT_BBCODE"), - new Token(TokenType.OpAssign), - new ConstantToken(new BoolVariant(false)), - new Token(TokenType.Newline, 0), - new Token(TokenType.PrVar), new IdentifierToken("LUCY_SRV_NAME"), new Token(TokenType.OpAssign), @@ -827,18 +741,6 @@ public class LucysNetFixes : IScriptMod { new ConstantToken(new IntVariant(0)), new Token(TokenType.Newline, 0), - new Token(TokenType.PrVar), - new IdentifierToken("LUCY_CUSTOM_COLOR_B"), - new Token(TokenType.OpAssign), - new ConstantToken(new BoolVariant(false)), - new Token(TokenType.Newline, 0), - - new Token(TokenType.PrVar), - new IdentifierToken("LUCY_CUSTOM_COLOR"), - new Token(TokenType.OpAssign), - new ConstantToken(new IntVariant(0)), - new Token(TokenType.Newline, 0), - new Token(TokenType.PrVar), new IdentifierToken("LUCY_LOG_MESSAGES"), new Token(TokenType.OpAssign),