1. 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!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

JustADev's Snippits

Discussion in 'Snippets' started by JustADev, Apr 23, 2018.

Tags:
  1. JustADev

    JustADev Well-Known Member

    Joined:
    Apr 8, 2017
    Messages:
    380
    Likes Received:
    9
    Lines of Lore:
    Determines the number of lines of lore on an item
    Code:
    Code (Skript):
    1. function GetLoreSize(Item: item) :: integer :
    2.     set {_Lore::*} to lines of lore of {_Item} split at "||"
    3.     return size of {_Lore::*}
    4.    
    Usage:
    Code (Skript):
    1. 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 (Skript):
    1. function GetEmptySlots(player: player, num1: integer, num2: integer):: integer :
    2.     set {_EmptySlots} to 0
    3.     loop integers between {_num1} and {_num2}:
    4.         if slot loop-value of {_player}'s inventory is air:
    5.             add 1 to {_EmptySlots}
    6.     return {_EmptySlots}
    Usage:
    Code (Skript):
    1. 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 (Skript):
    1. function GetSetSlots(player: player, num1: integer, num2: integer):: integer :
    2.     set {_SetSlots} to 0
    3.     loop integers between {_num1} and {_num2}:
    4.         if slot loop-value of {_player}'s inventory isn't air:
    5.             add 1 to {_SetSlots}
    6.     return {_SetSlots}
    Usage:
    Code (Skript):
    1. GetSetSlots(player, 0, 36)

    Simple Replacement:
    Replaces specified blocks in given radius to any block
    Code:
    Code (Skript):
    1. Function Replace(Player: player, Radius: integer, Replace: block, With: block):
    2.     loop blocks in radius {_Radius} of {_Player}:
    3.         if loop-block = {_Replace}:
    4.             set loop-block to {_With}
    5.  
    Usage:
    Code (Skript):
    1. Replace(player, 5, sand, dirt)
    Replaces all sand blocks in a radius 5 to Dirt
     
    #1 JustADev, Apr 23, 2018
    Last edited: Apr 23, 2018
    • Like Like x 1

Share This Page

Loading...