diff --git a/docs/libraries/beet.yaml b/docs/libraries/beet.yaml index 8dd1292..7daa839 100644 --- a/docs/libraries/beet.yaml +++ b/docs/libraries/beet.yaml @@ -8,6 +8,7 @@ data_pack: - "@smithed_libraries/packs/damage" - "@smithed_libraries/packs/item" - "@smithed_libraries/packs/prevent-aggression" + - "@smithed_libraries/packs/title" pipeline: - smithed_libraries.plugins.documentation diff --git a/docs/libraries/index.md b/docs/libraries/index.md index edf2fb3..e0f1e5a 100644 --- a/docs/libraries/index.md +++ b/docs/libraries/index.md @@ -184,6 +184,17 @@ Item ・ {{ item_version }} *TODO* ::: +:::{grid-item-card} +:link: title +:link-type: doc +:img-bottom: https://raw.githubusercontent.com/Smithed-MC/Libraries/main/smithed_libraries/packs/title/pack.png + +Title ・ v{{ title_version }} +^^^ + +**Required** for packs that use the title & subtitle as it coordinates title & subtitle usage across data packs. +::: + :::: --- @@ -214,4 +225,5 @@ custom-block damage prevent-aggression item +title ``` diff --git a/docs/libraries/title.md b/docs/libraries/title.md new file mode 100644 index 0000000..6944cdd --- /dev/null +++ b/docs/libraries/title.md @@ -0,0 +1,30 @@ +# Title (v{{ title_version }}) +> A small library that helps to coordinate title & subtitles usage across various data packs + +::::{grid} 2 + +:::{grid-item} +```{button-link} https://api.smithed.dev/v2/download?pack=title +:color: primary +:outline: +:expand: +{octicon}`download;1em` Download +``` +::: + +:::{grid-item} +```{button-link} https://github.com/Smithed-MC/Libraries/tree/main/smithed_libraries/packs/title/ +:color: primary +:outline: +:expand: +{octicon}`mark-github;1em` Source +``` +::: + +:::: + +### `#smithed.title:message` + +```{include} title/message.md +``` + diff --git a/docs/libraries/title/message.md b/docs/libraries/title/message.md new file mode 100644 index 0000000..bf082ca --- /dev/null +++ b/docs/libraries/title/message.md @@ -0,0 +1,63 @@ +| Input Name | Input Type | Input Source | Input Objective/Path | +| --- | --- | --- | --- | +| 'Raw Title' | storage | message.title_raw | smithed.title:input | +| 'JSON Title' | storage | message.title_json | smithed.title:input | +| 'Raw Subtitle' | storage | message.subtitle_raw | smithed.title:input | +| 'JSON Subtitle' | storage | message.subtitle_json | smithed.title:input | +| 'Priority Level' | storage | message.priority | smithed.title:input | +| 'Message Duration' | storage | message.freeze | smithed.title:input | + + + +Instead of using `/title` to display the message, set up the input storage and run the following command: +```mcfunction +function #smithed.title:message +``` +## Message +Messages can be set as strings or as json objects. To set a string, use `raw`, and to +set a JSON object, use `json`. Below are examples for both types of messages. +If both fields are set, the json object is shown. + +Be sure to override the data in the storage to not have a subtitle from an other datapack. + +### **Example of Raw Message** +```mcfunction +data modify storage smithed.title:input message set value { + title_raw: 'hello world', + subtitle_raw: 'this is a subtitle', + priority: 'persistent' +} +``` +### **Example of JSON Message** +```mcfunction +data modify storage smithed.title:input message set value { + title_json: '{"text": "Warning!", "color": "red"}', + subtitle_json: '{"text": "You cannot complete this action!", "color": "red"}', + priority: 'notification' +} +``` +## Priority +Priorities are set via specific strings. The list below shows the priority in descending order, +so for example notifications will show over conditional messages. +* `override`: This is the highest priority and will always override the current message, no matter what. +* `notification`: This is for brief, non-repeating, notification type messages, + such as the vanilla "You can't sleep now" message. +* `conditional`: This should be used for any message which will display constantly on a condition. + A good example is displaying a compass HUD while you hold a compass or showcasing the amount of XP + in a nearby tank. This doesn't include any persistent messages which toggle via a config option! +* `persistent`: This is the lowest priority message and is designated for messages which always displays + (or displays continously if a config value is set). You can think of this as a custom ui display + such as in Manic or even the Vanilla Tweaks coordinate HUD which always displays. +## Message Duration +Additionally, you can also set a `freeze` field in the storage space. +This will deteremine how many ticks your message should be protected against other messages with the same priority. +By default, this field is set to 20, which corresponds to 1 second. +```mcfunction +data modify storage smithed.title:message input set value { + title_raw: 'Random Event!', + subtitle_raw: '', + priority: 'notification', + freeze: 30 +} +``` +The freeze value has a minimum value of 0 and a maximum value of 50. \ No newline at end of file diff --git a/docs/libraries/title/reset.md b/docs/libraries/title/reset.md new file mode 100644 index 0000000..f629d2a --- /dev/null +++ b/docs/libraries/title/reset.md @@ -0,0 +1,9 @@ +## Reset + +This function resets the current freeze and priority allowing you to display another message + +```{admonition} ⚠️ Caution ⚠️ +:class: warning +This api **will** disrupt other packs as it blatently resets the actionbar state. +Do not use this in any normal circumstances, as it will break compatibility in most cases. +``` diff --git a/pyproject.toml b/pyproject.toml index f36f86e..6690c02 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -53,6 +53,7 @@ damage_version = "0.2.0" enchanter_version = "0.1.0" item_version = "0.2.1" prevent_aggression_version = "0.2.0" +title_version = "0.0.1" convention_header = """ ::::{grid} 2 2 2 2