Paste #115038: Unnamed Denizen Script Paste

Date: 2023/09/10 03:28:51 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


# speaker:
#   title (string)
#   text (string)
# options:
#   - text (string)
#     click (task)
tickquests_create_dialogue_task:
    type: task
    definitions: d|loc
    script:
    - define title <[d.speaker.title]>
    - define text <[d.speaker.text]>
    - define lines <list>
    # TITLE
    - define lines:->:<[title]>
    - define lines:->:<empty>
    # TEXT
    - define lines:->:<&[base]><[text]>
    - define lines:->:<empty>

    # OPTIONS
    - foreach <[d.options]> as:opt:
        - define lines:->:<&[base]><[opt.text]>

    - define text <[lines].separated_by[<n>]>
    - spawn tickquests_text_display[text=<[text]>] <[loc]> save:text
    - define text_entity <entry[text].spawned_entity>
    - define line_width <[text_entity].line_width>
    - define lines_split <[text].split_lines_by_width[<[line_width]>]>
    - announce <[lines_split]>

tickquests_text_display:
    type: entity
    entity_type: text_display
    mechanisms:
        background_color: black
        pivot: center
        display: left
        scale: 0.7,0.7,0.7
        line_width: 150

tickquests_sample_dialogue:
    type: data
    d:
        speaker:
            title: James
            text: Hello, I'm <element[James].custom_color[emphasis]>. This is a sample dialogue.
        options: <list[<map[text=Opt 1]>].include_single[<map[text=Opt 2]>]>