parent
9c507263f8
commit
fad3fa7d06
1 changed files with 40 additions and 14 deletions
@ -1,23 +1,49 @@ |
|||||||
extends Mod_Base |
extends Mod_Base |
||||||
|
|
||||||
@export var headpats_scene: PackedScene |
@export var headpats_scene: PackedScene |
||||||
@export var triggers: Array[String] = ["copyPat", "pats copygirl"] |
|
||||||
@export var countdown: float = 12.0 |
@export var countdown: float = 12.0 |
||||||
|
|
||||||
|
var triggers = { |
||||||
|
"": ["\\bcopyPat\\b", "pats copygirl\\b"], |
||||||
|
"Kuerb1": ["\\bkuerb1Pats\\b", "\\bkuerb1PatPat\\b", "pats [kK]uerb[1y]\\b"], |
||||||
|
} |
||||||
|
|
||||||
|
func _ready() -> void: |
||||||
|
add_tracked_setting("countdown", "Seconds active", { "min": 0.0, "max": 3600.0 }) |
||||||
|
|
||||||
func handle_channel_chat_message(_cheerer_username: String, _cheerer_display_name: String, message: String, _bits_count: int) -> void: |
func handle_channel_chat_message(_cheerer_username: String, _cheerer_display_name: String, message: String, _bits_count: int) -> void: |
||||||
for trigger in triggers: |
for nickname in triggers: |
||||||
if message.contains(trigger): |
for regex in triggers[nickname]: |
||||||
var skel = get_skeleton() |
if RegEx.create_from_string(regex).search(message): |
||||||
if not skel: return |
var skeleton = find_skeleton(nickname) |
||||||
|
if not skeleton: return |
||||||
|
play_headpat_anim(skeleton) |
||||||
|
|
||||||
var node = skel.get_node("copyPat_BoneAttachment"); |
|
||||||
if not node: |
|
||||||
node = headpats_scene.instantiate() |
|
||||||
skel.add_child(node) |
|
||||||
add_autodelete_object(node) |
|
||||||
|
|
||||||
node.lifetime = countdown |
# Returns the skeleton of the avatar with the specified nickname. An empty |
||||||
|
# string will refer to the current user. Otherwise will try to find a player |
||||||
|
# with that nickname, assuming the copyMultiplayer mod is active. |
||||||
|
func find_skeleton(nickname: String) -> Skeleton3D: |
||||||
|
if nickname: |
||||||
|
var copyMP = $"../copyMultiplayer" |
||||||
|
if not copyMP: return null |
||||||
|
|
||||||
func _ready() -> void: |
for controller in copyMP.get_all_sync_controllers(): |
||||||
add_tracked_setting("triggers", "Trigger phrases", { }) |
if controller.nickname == nickname: |
||||||
add_tracked_setting("countdown", "Seconds active", { "min": 0.0, "max": 3600.0 }) |
return controller.skeleton |
||||||
|
return null |
||||||
|
|
||||||
|
else: |
||||||
|
return get_skeleton() |
||||||
|
|
||||||
|
func play_headpat_anim(skeleton: Skeleton3D) -> void: |
||||||
|
var existing = skeleton.get_node_or_null("copyPat_BoneAttachment"); |
||||||
|
if existing: |
||||||
|
existing.queue_free() |
||||||
|
skeleton.remove_child(existing) |
||||||
|
|
||||||
|
var node = headpats_scene.instantiate() |
||||||
|
skeleton.add_child(node) |
||||||
|
add_autodelete_object(node) |
||||||
|
|
||||||
|
node.lifetime = countdown |
||||||
|
Loading…
Reference in new issue