1
0
Fork 0
Personalized headpat mod for SnekStudio.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

49 lines
1.5 KiB

extends Mod_Base
@export var headpats_scene: PackedScene
@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:
for nickname in triggers:
for regex in triggers[nickname]:
if RegEx.create_from_string(regex).search(message):
var skeleton = find_skeleton(nickname)
if not skeleton: return
play_headpat_anim(skeleton)
# 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
for controller in copyMP.get_all_sync_controllers():
if controller.nickname == nickname:
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