Solved How to cut this?

  • 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!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

slxshxr

Member
Jul 28, 2018
11
0
0
24
I already have a script for a custom enchantments, but its really long after 30 custom enchantments.
I have a code like this:
code_language.skript:
on rightclick:
    if player's tool is {@gem} with lore "{@toxic3}":
        if {gem:toxic3:%player%} is true:
            send "&aYou have already activated enchantment"
        if {gem:toxic3:%player%} is false:
            set {gem:toxic3:%player%} to true
            send "&aYou activated your enchantment" to player   
    if player's tool is {@gem} with lore "{@toxic2}":
        if {gem:toxic2:%player%} is true:
            send "&aYou have already activated enchantment"
        if {gem:toxic2:%player%} is false:
            set {gem:toxic2:%player%} to true
            send "&aYou activated your enchantment" to player   
    if player's tool is {@gem} with lore "{@toxic1}":
        if {gem:toxic1:%player%} is true:
            send "&aYou have already activated enchantment"
        if {gem:toxic1:%player%} is false:
            set {gem:toxic1:%player%} to true
            send "&aYou activated your enchantment" to player       
    if player's tool is any sword or any axe or any pickaxe or any hoe or stick or any shovel:
        if {gem:toxic3:%player%} is true:
            if lore of player's tool contains "{@toxic2}" or "{@toxic3}" or "{@toxic1}":
                send "&4Toxic is already in this item"
            else:
                set item's lore to "%coloured lore of item% || &8-&7=&f&l{&2&lʘ&f&l}&7=&8- || {@toxic3}"
                set {gem:toxic3:%player%} to false
                remove 1 {@gem} with lore "{@toxic3}" from player
        if {gem:toxic2:%player%} is true:
            if lore of player's tool contains "{@toxic2}" or "{@toxic3}" or "{@toxic1}":
                send "&4Toxic is already in this item"
            else:
                set item's lore to "%coloured lore of item% || &8-&7=&f&l{&2&lʘ&f&l}&7=&8- || {@toxic2}"
                set {gem:toxic2:%player%} to false
                remove 1 {@gem} with lore "{@toxic2}" from player
        if {gem:toxic1:%player%} is true:
            if lore of player's tool contains "{@toxic2}" or "{@toxic3}" or "{@toxic1}":
                send "&4Toxic is already in this item"
            else:
                set item's lore to "%coloured lore of item% || &8-&7=&f&l{&2&lʘ&f&l}&7=&8- || {@toxic1}"
                set {gem:toxic1:%player%} to false
                remove 1 {@gem} with lore "{@toxic1}" from player


Can i cut this to something like (i dont know its good, but i wanna give example):
code_language.skript:
function addEnchantment(t: text):
    if player's tool is {@gem} with lore "{@%{_t}%}":
        if {gem:%{_t}%:%player%} is true:
            send "&aYou have already activated enchantment"
        if {gem:%{_t}%:%player%} is false:
            set {gem:%{_t}%:%player%} to true
            send "&aYou activated your enchantment" to player

^- i write addEnchantment(text) example:
addEnchantment(toxic3)
So every %{_t}% change for a toxic3?
 
I don't recommend using this way for custom enchant. You should use TUSKE's custom enchant features.

code_language.skript:
function addEnchantment(p: player, ench: text):
    if {_p}'s held tool is set:
        if lore of {_p}'s tool doesn't contain {_ench}:
            set lore of {_p}'s held tool to "%lore of {_p}'s tool%||%{_ench}%"
        else:
            send "You already have this enchant" to {_p}
    else:
        send "Hold something other than air." to {_p}
       
       
on attack:
    if lore of attacker's tool contains "&7Toxic I":
        apply posion to victim for 1 second
 
Status
Not open for further replies.