JustADev's Snippits

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

JustADev

Well-Known Member
Apr 8, 2017
379
9
18
23
Lines of Lore:
Determines the number of lines of lore on an item
Code:
code_language.skript:
function GetLoreSize(Item: item) :: integer :
    set {_Lore::*} to lines of lore of {_Item} split at "||"
    return size of {_Lore::*}
Usage:
code_language.skript:
GetLoreSize(player's tool)
Will return an integer value

Empty Slots:
Determines the number of empty slots for any given range of slots in a player's inventory
Code:
code_language.skript:
function GetEmptySlots(player: player, num1: integer, num2: integer):: integer :
    set {_EmptySlots} to 0
    loop integers between {_num1} and {_num2}:
        if slot loop-value of {_player}'s inventory is air:
            add 1 to {_EmptySlots}
    return {_EmptySlots}
Usage:
code_language.skript:
GetEmptySlots(player, 0, 36)
This checks the whole inventory of the player

Set Slots:
Determines the number of set slots for any given range of slots in a player's inventory
Code:
code_language.skript:
function GetSetSlots(player: player, num1: integer, num2: integer):: integer :
    set {_SetSlots} to 0
    loop integers between {_num1} and {_num2}:
        if slot loop-value of {_player}'s inventory isn't air:
            add 1 to {_SetSlots}
    return {_SetSlots}
Usage:
code_language.skript:
GetSetSlots(player, 0, 36)

Simple Replacement:
Replaces specified blocks in given radius to any block
Code:
code_language.skript:
Function Replace(Player: player, Radius: integer, Replace: block, With: block):
    loop blocks in radius {_Radius} of {_Player}:
        if loop-block = {_Replace}:
            set loop-block to {_With}
Usage:
code_language.skript:
Replace(player, 5, sand, dirt)
Replaces all sand blocks in a radius 5 to Dirt
 
Last edited:
  • Like
Reactions: jaylawl
Lines of Lore:
Determines the number of lines of lore on an item
Code:
code_language.skript:
function GetLoreSize(Item: item) :: integer :
    set {_Lore::*} to lines of lore of {_Item} split at "||"
    return size of {_Lore::*}
Usage:
code_language.skript:
GetLoreSize(player's tool)
Will return an integer value

Empty Slots:
Determines the number of empty slots for any given range of slots in a player's inventory
Code:
code_language.skript:
function GetEmptySlots(player: player, num1: integer, num2: integer):: integer :
    set {_EmptySlots} to 0
    loop integers between {_num1} and {_num2}:
        if slot loop-value of {_player}'s inventory is air:
            add 1 to {_EmptySlots}
    return {_EmptySlots}
Usage:
code_language.skript:
GetEmptySlots(player, 0, 36)
This checks the whole inventory of the player

Set Slots:
Determines the number of set slots for any given range of slots in a player's inventory
Code:
code_language.skript:
function GetSetSlots(player: player, num1: integer, num2: integer):: integer :
    set {_SetSlots} to 0
    loop integers between {_num1} and {_num2}:
        if slot loop-value of {_player}'s inventory isn't air:
            add 1 to {_SetSlots}
    return {_SetSlots}
Usage:
code_language.skript:
GetSetSlots(player, 0, 36)

Simple Replacement:
Replaces specified blocks in given radius to any block
Code:
code_language.skript:
Function Replace(Player: player, Radius: integer, Replace: block, With: block):
    loop blocks in radius {_Radius} of {_Player}:
        if loop-block = {_Replace}:
            set loop-block to {_With}
Usage:
code_language.skript:
Replace(player, 5, sand, dirt)
Replaces all sand blocks in a radius 5 to Dirt
I dont think the "Lines of Lore:" part works. I put it in the skunity parser, and it gave me errors.