# The author of this file is Baezor. # SkLib # Version: 1.1.0 # Configuration options: # The prefix option allows you to change the prefix of all messages. prefix: &6SkLib &8» # Configure message colors. color-1: &7 color-2: &e color-3: &6 error-color: &c # Hologram Stuff hologram-radius: 20 # The permission message is the message that shows when a player does not have # permission for a command. permission-message: &c&lError! &7You do not have permission to use this command! # The version of SkLib you have. version: 1.1.0 # This is the storage prefix for the entire script. DO NOT ever change this unless # the variables conflict with another script! storage: sklib # After this point, please do not edit anything. The rest is code to register the # configuration in the rest of the script! # Filter Holograms function sklib_filterHologramLine(text: text) :: text: set {_dev1} to playerDatabase_getPlayerCount("dev-1") set {_dev2} to playerDatabase_getPlayerCount("dev-2") replace all "{dev-1.players}" in {_text} with "%{_dev1}%" replace all "{dev-2.players}" in {_text} with "%{_dev2}%" replace all "{dev-1.online}" in {_text} with playerDatabase_getOnlineMode("dev-1") replace all "{dev-2.online}" in {_text} with playerDatabase_getOnlineMode("dev-2") return {_text} # SkLib Main Command command /sklib [] []: aliases: /skriptlib permission: sklib.admin permission message: {@permission-message} executable by: player usage: {@prefix} {@error-color}Invalid arguments! Try /sklib help for help! trigger: if arg-1 is not set: send "{@color-2}You are currently running version {@color-1}{@version}{@color-2} of {@color-1}SkLib{@color-2} by {@color-1}Baezor{@color-2}." to player else if arg-1 is "ver" or "version": send "{@color-2}You are currently running version {@color-1}{@version}{@color-2} of {@color-1}SkLib{@color-2} by {@color-1}Baezor{@color-2}." to player else if arg-1 is "help": send "&8&m &r {@color-3}&lSkLib&r &8&m &r" to player send "&8• {@color-2}/sklib help" to player send "&8• {@color-2}/sklib ver" to player send "&8• {@color-2}/sklib reload" to player send "&8• {@color-2}/sklib (docs|documentation)" to player send "&8• {@color-2}/sklib ani[mation] (animation)" to player send "&8&m " to player else if arg-1 is "reload": set {_time} to now send "{@prefix} {@color-1}Reloading {@color-2}%script%{@color-1}." to player sklib_playButtonClick(player) reload script script set {_time} to difference between {_time} and now sklib_playExperienceOrb(player) send "{@prefix} {@color-1}Reloaded {@color-2}%script%{@color-1}! &8(&f%{_time}%&8)" to player else if arg-1 is "documentation", "docs" or "doc": send "&8&m &r {@color-3}&lSkLib Documentation&r &8&m &r" to player send "{@color-1}You can view the {@color-2}SkLib{@color-1} documentation by" to player send "{@color-1}clicking {@color-2}&nhere{@color-1}. You can get support by" to player send "{@color-1}joining our {@color-2}&ndiscord{@color-1}." to player send "&8&m " to player else if arg-1 is "ani" or "animation": if arg-2 is "scroll": loop sklib_animationScroll("Testing Text", "&f", "&a", "&2", true): send title "&f%loop-value%" to player for 1 seconds with fadein 0 second and fade out 1 second wait 2 ticks else if arg-2 is "flash": loop sklib_animationFlash("Testing Text", "&f", "&a", "&2", true): send title "&f%loop-value%" to player for 1 seconds with fadein 0 second and fade out 1 second wait 5 ticks else: send "{@prefix} {@error-color}That is not a valid animation! Try ""scroll"" or ""flash""." to player else: send "{@prefix} {@error-color}Invalid arguments! Try /sklib help for help!" to player # Tab Completions on tab complete of "/sklib" or "/skriptlib": set tab completions for position 1 to "help", "reload", "docs", "animation" and "version" #{{@storage}::maxPages::*} if tab arg-1 = "animation": set tab completions for position 2 to "scroll" and "flash" on tab complete of "/sk" or "/skript": set tab completions for position 1 to "reload", "enable", "disable", "update" and "help" if tab arg-1 = "reload" or "disable": set tab completions for position 2 to enabled scripts if tab arg-1 = "enable": set tab completions for position 2 to disabled scripts # Sign Editor on right click on any sign: player has permission "sklib.sign.edit" player is sneaking open sign gui of target block to player # Location API function sklib_locationToText(loc: location, world: world) :: text: set {_x} to the x coordinate of {_loc} set {_y} to the y coordinate of {_loc} set {_z} to the z coordinate of {_loc} set {_locText} to "%{_x}%^%{_y}%^%{_z}%^%{_world}%" return {_locText} function sklib_textToLocation(text: text) :: location: set {_text::*} to {_text} split at "^" set {_x} to {_text::1} parsed as a number set {_y} to {_text::2} parsed as a number set {_z} to {_text::3} parsed as a number set {_world} to {_text::4} return location({_x}, {_y}, {_z}, world({_world})) # Hologram API on unload: loop {{@storage}::holo::global::*}: sklib_unloadGlobalHologram(loop-value) every second: loop {{@storage}::holo::global::*}: set {_pl} to false loop all players in radius {@hologram-radius} of sklib_textToLocation({{@storage}::holo::global::%loop-value%::loc}): set {_pl} to true exit loop if {_pl} is true: if {{@storage}::holo::global::%loop-value%::loaded} is not true: sklib_loadGlobalHologram(loop-value) else: sklib_refreshGlobalHologramLines(loop-value) else: {{@storage}::holo::global::%loop-value%::loaded} is not false #set block at sklib_textToLocation({{@storage}::holo::global::%loop-value%::loc}) to air sklib_unloadGlobalHologram(loop-value) function sklib_createGlobalHologram(id: text, loc: location, lines: texts, inverse: boolean = false): {{@storage}::holo::global::*} does not contain {_id} # Register Hologram add {_id} to {{@storage}::holo::global::*} set {{@storage}::holo::global::%{_id}%::lines::*} to {_lines::*} set {{@storage}::holo::global::%{_id}%::inverse} to {_inverse} set {{@storage}::holo::global::%{_id}%::loaded} to false set {{@storage}::holo::global::%{_id}%::loc} to sklib_locationToText((location 1 below {_loc}), (world of {_loc})) function sklib_deleteGlobalHologram(id: text): {{@storage}::holo::global::*} contains {_id} sklib_unloadGlobalHologram({_id}) # Register Hologram delete {{@storage}::holo::global::%{_id}%::lines::*} delete {{@storage}::holo::global::%{_id}%::inverse} delete {{@storage}::holo::global::%{_id}%::loc} delete {{@storage}::holo::global::%{_id}%::loaded} remove {_id} from {{@storage}::holo::global::*} function sklib_loadGlobalHologram(id: text): {{@storage}::holo::global::%{_id}%::loaded} is false set {_loc} to sklib_textToLocation({{@storage}::holo::global::%{_id}%::loc}) if {{@storage}::holo::global::%{_id}%::inverse} is true: set {_loc} to location ((amount of {{@storage}::holo::global::%{_id}%::lines::*})*.25)-.25 above {_loc} loop {{@storage}::holo::global::%{_id}%::lines::*}: if loop-value is "{skip}" or "{empty}": add 0.25 to {_offset} else: set {_name} to sklib_filterHologramLine(colored loop-value) spawn 1 armor stand at (location {_offset} below {_loc}) with nbt "{Small:1,Invisible:1,Invulnerable:1,NoGravity:1}" set {_stand} to the last spawned armor stand set the display name of {_stand} to {_name} set nbt of last spawned armor stand to "{CustomNameVisible:1,Small:1,Invisible:1,Invulnerable:1,NoGravity:1}" add 0.25 to {_offset} add {_stand} to {_stands::*} set {{@storage}::holo::global::%{_id}%::stands::*} to {_stands::*} set {{@storage}::holo::global::%{_id}%::loaded} to true function sklib_refreshGlobalHologramLines(id: text): loop {{@storage}::holo::global::%{_id}%::stands::*}: add display name of loop-value to {_names::*} loop {{@storage}::holo::global::%{_id}%::lines::*}: loop-value is not "{skip}" or "{empty}" add sklib_filterHologramLine(colored loop-value) to {_new::*} loop {_names::*}: {_new::%loop-index%} is not loop-value set {_refresh} to true exit loop {_refresh} is true sklib_unloadGlobalHologram({_id}) sklib_loadGlobalHologram({_id}) function sklib_unloadGlobalHologram(id: text): {{@storage}::holo::global::%{_id}%::loaded} is true loop {{@storage}::holo::global::%{_id}%::stands::*}: kill loop-value delete {{@storage}::holo::global::%{_id}%::stands::*} set {{@storage}::holo::global::%{_id}%::loaded} to false # Sound API function sklib_playButtonClick(player: player): play sound "UI_BUTTON_CLICK" with volume 0.5 with pitch 1 at {_player}'s location for {_player} function sklib_playBass(player: player): play sound "block.note_block.bass" with volume 0.5 with pitch 1 at {_player}'s location for {_player} function sklib_playHarp(player: player): play sound "block.note_block.harp" with volume 0.5 with pitch 1 at {_player}'s location for {_player} function sklib_playPling(player: player): play sound "block.note_block.pling" with volume 0.5 with pitch 1 at {_player}'s location for {_player} function sklib_playBit(player: player): play sound "block.note_block.bit" with volume 0.5 with pitch 1 at {_player}'s location for {_player} function sklib_playPageTurn(player: player): play sound "item.book.page_turn" with volume 0.5 with pitch 1 at {_player}'s location for {_player} function sklib_playExperienceOrb(player: player): play sound "entity.experience_orb.pickup" with volume 0.5 with pitch 1 at {_player}'s location for {_player} function sklib_playLevelUp(player: player): play sound "entity.player.levelup" with volume 0.5 with pitch 1 at {_player}'s location for {_player} function sklib_playChallengeComplete(player: player): play sound "ui.toast.challenge_complete" with volume 0.5 with pitch 1 at {_player}'s location for {_player} # Text API function sklib_capitalizeFirstLetter(text: text) :: text: set {_char} to the first character of {_text} set {_char} to {letters::uppercase::%{_char}%} set {_char} to {_char} in uppercase set {_remaining} to "" set {_remaining} to the last (length of {_text} - 1) characters of {_text} return "%{_char}%%{_remaining}%" function sklib_capitalizeFirstSentence(text: text) :: text: set {_text::*} to {_text} split at " " loop {_text::*}: add sklib_capitalizeFirstLetter(loop-value) to {_newText::*} loop {_newText::*}: if {_return} is set: set {_return} to "%{_return}% %loop-value%" else: set {_return} to "%loop-value%" return {_return} function sklib_tooltip(text: text, lines: texts) :: text: loop {_lines::*}: if {_str} is not set: set {_str} to "%loop-value%" else: set {_str} to "%{_str}%%nl%%loop-value%" return "%{_text}%" function sklib_command(text: text, command: text) :: text: return "%{_text}%" # Animation API function sklib_animationScroll(text: text, color1: text, color2: text, color3: text, bold: boolean) :: texts: set {_text::*} to {_text} split at "" if {_bold} is true: set {_string} to "%{_color1}%&l%{_text}%" else: set {_string} to "%{_color1}%%{_text}%" add {_string} to {_return::*} loop {_text::*}: delete {_string} set {_index} to loop-index parsed as a number set {_pindex} to {_index}-1 loop {_text::*}: set {_cindex} to loop-index-2 parsed as a number if {_bold} is true: set {_color} to "&f&l" if {_cindex} is {_index}: set {_color} to "%{_color3}%&l" if {_cindex} is {_pindex}: set {_color} to "%{_color2}%&l" if {_string} is not set: set {_string} to "%{_color}%%loop-value-2%" else: set {_string} to "%{_string}%%{_color}%%loop-value-2%" else: set {_color} to "&f" if {_cindex} is {_index}: set {_color} to "%{_color3}%" if {_cindex} is {_pindex}: set {_color} to "%{_color2}%" if {_string} is not set: set {_string} to "%{_color}%%loop-value-2%" else: set {_string} to "%{_string}%%{_color}%%loop-value-2%" add {_string} to {_return::*} if {_bold} is true: set {_string} to "%{_color1}%&l%{_text}%" else: set {_string} to "%{_color1}%%{_text}%" add {_string} to {_return::*} return {_return::*} function sklib_animationFlash(text: text, color1: text, color2: text, color3: text, bold: boolean) :: texts: if {_bold} is true: set {_string} to "%{_color1}%&l%{_text}%" else: set {_string} to "%{_color1}%%{_text}%" add {_string} to {_return::*} loop 10 times: if {_bold} is true: set {_string} to "%{_color2}%&l%{_text}%" else: set {_string} to "%{_color2}%%{_text}%" add {_string} to {_return::*} if {_bold} is true: set {_string} to "%{_color3}%&l%{_text}%" else: set {_string} to "%{_color3}%%{_text}%" add {_string} to {_return::*} if {_bold} is true: set {_string} to "%{_color1}%&l%{_text}%" else: set {_string} to "%{_color1}%%{_text}%" add {_string} to {_return::*} return {_return::*}