Date: 2023/09/04 13:00:18 UTC-07:00
Type: Denizen Script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
##########################################################################################
# #
# SpeechBubbles #
# Spawns SpeechBubbles above players #
# Version: 1.0.0 Author: Icecapade #
# #
# Documentation: #
# https://docs.icecapa.de/ #
# #
##########################################################################################
## <--[task]
## @name speech_bubble_spawn
## @input text:<ElementTag> recipients:<ListTag(PlayerTag)>
## @description
## Spawns a speech bubble
## @Usage
## # Use to spawn a speech bubble above the linked player.
## - run speech_bubble_spawn def.text:<context.message.parse_color> def.recipients:<context.recipients>
## @Script SpeechBubbles
## -->
speech_bubble_handler:
type: world
debug: false
events:
after player chats:
- run speech_bubble_spawn def.text:<context.message.parse_color> def.recipients:<context.recipients>
speech_bubble_spawn:
type: task
debug: false
definitions: text|recipients
script:
- if !<player.exists>:
- debug error "<&[error]>The task requires a linked player!"
- stop
- if !<[text].exists>:
- debug error "<&[error]>You must specify a text!"
- stop
- foreach <[recipients].if_null[<list>]> as:player:
- if !<[player].as[PlayerTag].exists>:
- debug error "<&[error]>Recipients do contain a non-player entity, ignoring them."
- define recipients[<[loop_index]>]:<-
- fakespawn speech_bubble[text=<[text]>] <player.location> players:<[recipients]> duration:9s save:bubble
- run speech_bubble_fade_out def.entity:<entry[bubble].faked_entity>
- define bubble_count <player.flag[chat_bubbles.bubble_count].if_null[0]>
- flag <player> chat_bubbles.bubble_map.<[bubble_count]>:<entry[bubble].faked_entity> expire:9s
- flag <player> chat_bubbles.bubble_count:++
- foreach <player.flag[chat_bubbles.bubble_map].values.reverse> as:text_display:
- if !<[text_display].is_spawned>:
- foreach next
- define height <[height].exists.if_true[<[height].add[<[last_lines].mul[0.25]>]>].if_false[0.75]>
- define last_lines <[text_display].text.text_width.div[200].round_up>
- adjust <[text_display]> translation:0,<[height]>,0
- narrate "<[text_display].translation>"
- mount <[text_display]>|<player>
speech_bubble:
type: entity
debug: false
entity_type: text_display
mechanisms:
pivot: CENTER
opacity: 255
translation: 0,0.75,0
speech_bubble_fade_out:
type: task
debug: false
definitions: entity
script:
- wait 121t
- repeat 62:
- adjust <[entity]> opacity:<element[252].sub[<[value].mul[4]>]>
- wait 1t