Jump to content

Enchant api for Prison Server or other..


Sorbon

Recommended Posts

This skript is mainly for the Skript-Devs on Minehut

It gives you some function to edit Lores and get/add level to a pickaxe or other items!

It doesnt come with max values or premade Enchants, it just adds them and you can get the level for it

 

note:

This Skript works with and without SkQuery, so you don't have to worry about that

 

function addLore(i:item,e:string):
    set {_lores::*} to getLores({_i})
    add colored {_e} to {_lores::*}
    set {_i} to {_i} with lore {_lores::*}
function getLores(i:item) :: strings:
    set {_lores::*} to lore of {_i}
    if {_lores::1} contains "||":
        set {_lores::*} to {_lores::1} split at "||"
    return {_lores::*}
function getLine(i:item,e:string) :: integer:
    set {_lores::*} to getLores({_i})
    loop {_lores::*}:
        
        if loop-value starts with colored {_e}:
            return loop-index parsed as integer
    return 0
function getLore(i:item,e:string) :: string:
    return line getLine({_i},{_e}) of lore of {_i}
function setLore(i:item,n:integer,e:string):
    set line {_n} of lore of {_i} to colored {_e}
function updateLore(i:item,e:string,f:string):
    set {_n} to getLine({_i},{_e})
    setLore({_i},{_n},{_f})
function addLevel(i:item,e:string,n:integer):
    set {_y} to getLine({_i},{_e})
    if {_y} = 0:
        addLore({_i},{_e})
        set {_y} to getLine({_i},{_e})
    set {_lore::*} to getLore({_i},{_e}) split at " "
    set {_f} to colored "%{_lore::1}% %getLevel({_i},{_e})+ {_n}%"
    setLore({_i},{_y},{_f})

function getLevel(i:item,e:string) :: integer:
    set {_lore::*} to getLore({_i},{_e}) split at " "
    return {_lore::2} parsed as integer 

command enchant <string> <integer>:
    trigger:
        addLevel(player's tool,arg-1,arg-2)

        #example /enchant &cExplosive&7 1

        #Color codes are needed, if you want it simpler, you could create a list variable with the colored name as value and the alias as index;
        # set {enchant::explosive} to &cExplosive&7
        # addLevel(player's tool,{enchant::%arg-1%},arg-2) So you get the right one 
on break:
    #To test for the Level, you can follow this example:
    if getLevel(player's tool,"&cExplosive&7") > 0:
        send "you have Explosive enchanted, Bumm"

 

Link to comment
Share on other sites

  • 1 year later...

sorry for necropost this but i'am really need something like this to my custom enchant since i want make it upgrade able but this didnt work for me, any clue?


Server Version: git-Paper-787 (MC: 1.16.5)
Skript Version: 2.6-beta3
Installed Skript Addons:
Skellett v1.9.11 (https://forums.skunity.com/resources/skellett.24/)
skript-gui v1.3-beta1-nightly-d7e76a5 (https://github.com/APickledWalrus/skript-gui)
skRayFall v1.9.26 (https://sk.rayfall.net/)
SkQuery v4.1.5
 

Link to comment
Share on other sites

3 hours ago, Riiee said:

sorry for necropost this but i'am really need something like this to my custom enchant since i want make it upgrade able but this didnt work for me, any clue?


Server Version: git-Paper-787 (MC: 1.16.5)
Skript Version: 2.6-beta3
Installed Skript Addons:
Skellett v1.9.11 (https://forums.skunity.com/resources/skellett.24/)
skript-gui v1.3-beta1-nightly-d7e76a5 (https://github.com/APickledWalrus/skript-gui)
skRayFall v1.9.26 (https://sk.rayfall.net/)
SkQuery v4.1.5
 

Please don't comment on posts older than one month, could a mod lock this?

Developer

 

Joined Minecraft in 2010 on PC

Joined Minehut in August 2016

1 year Skript experience

2 months Java experience

5 months Javascript experience

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...