Compare commits
No commits in common. 'fad3fa7d061d10f7a5939ce8587385415f7307f6' and '534e7ba44a22db8cb3808b25e43d51d49dae974d' have entirely different histories.
fad3fa7d06
...
534e7ba44a
11 changed files with 74 additions and 90 deletions
@ -1,49 +1,23 @@ |
|||||||
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 nickname in triggers: |
for trigger in triggers: |
||||||
for regex in triggers[nickname]: |
if message.contains(trigger): |
||||||
if RegEx.create_from_string(regex).search(message): |
var skel = get_skeleton() |
||||||
var skeleton = find_skeleton(nickname) |
if not skel: return |
||||||
if not skeleton: return |
|
||||||
play_headpat_anim(skeleton) |
|
||||||
|
|
||||||
|
|
||||||
# Returns the skeleton of the avatar with the specified nickname. An empty |
var node = skel.get_node("copyPat_BoneAttachment"); |
||||||
# string will refer to the current user. Otherwise will try to find a player |
if not node: |
||||||
# with that nickname, assuming the copyMultiplayer mod is active. |
node = headpats_scene.instantiate() |
||||||
func find_skeleton(nickname: String) -> Skeleton3D: |
skel.add_child(node) |
||||||
if nickname: |
add_autodelete_object(node) |
||||||
var copyMP = $"../copyMultiplayer" |
|
||||||
if not copyMP: return null |
|
||||||
|
|
||||||
for controller in copyMP.get_all_sync_controllers(): |
node.lifetime = countdown |
||||||
if controller.nickname == nickname: |
|
||||||
return controller.skeleton |
|
||||||
return null |
|
||||||
|
|
||||||
else: |
func _ready() -> void: |
||||||
return get_skeleton() |
add_tracked_setting("triggers", "Trigger phrases", { }) |
||||||
|
add_tracked_setting("countdown", "Seconds active", { "min": 0.0, "max": 3600.0 }) |
||||||
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