hello can you help me on a script

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

mynameisjosep

Member
Apr 25, 2020
29
0
0
23
i recorded a video this video explains my problem
So guys i breaking coal with level 1 pickaxe and if i break coal with another level 1 pickaxe it shows last pickaxe breaked coal amount
so i dont want this
code is
Code:
on break of coal ore:
    if tool's name is "&alevel 1":
        add 1 to {coal::%player%}
        set lore of player's tool to "&7breaked coal &2%{coal::%player%}%"
 
Here's what happens with your current code:
  1. You break coal with pickaxe 1
  2. The variable {coal::%player%} has 1 added to it (now equal to 1)
  3. The lore of your tool displays the variable {coal::%player%} (equal to 1)
  4. You switch tools and break another piece of coal with pickaxe 2
  5. The variable {coal::%player%} has 1 added to it (now equal to 2)
  6. The lore of your tool displays the variable {coal::%player%} (equal to 2)
What you want is to display the amount of coal broken with a particular pickaxe not the total amount of coal the player has broken.

To do this you could either use nbt or get the value out of the lore.

NBT (Requires skBee):
Code:
on break of coal ore:
  if tool's name is "&alevel 1":
    set {_coalBroken} to "coal.broken" tag of nbt of tool
    add "{coal.broken:%{_coalBroken} + 1%}" to nbt of tool
    set lore of player's tool to "&7breaked coal &2%{_coalBroken} +1%"

Lore (not recommended):
Code:
on break of coal ore:
  if tool's name is "&alevel 1":
    set {_coalBroken} to uncoloured line 1 of lore of player's tool
    replace all "breaked coal " with "" in {_coalBroken}
    set lore of player's tool to "&7breaked coal &2%({_coalBroken} parsed as number) + 1%"
 
Here's what happens with your current code:
  1. You break coal with pickaxe 1
  2. The variable {coal::%player%} has 1 added to it (now equal to 1)
  3. The lore of your tool displays the variable {coal::%player%} (equal to 1)
  4. You switch tools and break another piece of coal with pickaxe 2
  5. The variable {coal::%player%} has 1 added to it (now equal to 2)
  6. The lore of your tool displays the variable {coal::%player%} (equal to 2)
What you want is to display the amount of coal broken with a particular pickaxe not the total amount of coal the player has broken.

To do this you could either use nbt or get the value out of the lore.

NBT (Requires skBee):
Code:
on break of coal ore:
  if tool's name is "&alevel 1":
    set {_coalBroken} to "coal.broken" tag of nbt of tool
    add "{coal.broken:%{_coalBroken} + 1%}" to nbt of tool
    set lore of player's tool to "&7breaked coal &2%{_coalBroken} +1%"

Lore (not recommended):
Code:
on break of coal ore:
  if tool's name is "&alevel 1":
    set {_coalBroken} to uncoloured line 1 of lore of player's tool
    replace all "breaked coal " with "" in {_coalBroken}
    set lore of player's tool to "&7breaked coal &2%({_coalBroken} parsed as number) + 1%"
sir its working but i need upgrade this pickaxe example
Code:
on break of coal ore:
    if tool's name is "&6Level 1":
        set {_coalBroken} to uncoloured line 1 of lore of player's tool
        replace all "breaked coal " with "" in {_coalBroken}
        set lore of player's tool to "&7breaked coal &2%({_coalBroken} parsed as number) + 1%"
        set {_item} to player's tool
        if {_coalBroken} is greater than or equal to 5:
            remove {_item} from player
            give a diamond pickaxe of efficiency 2 named "&6Level 2" with lore "" to player
i did this but not working i tried to use nbt but not working even i download skBee its giving problem cuz i using craftbukkit
 
This should fix your problem of upgrading
Code:
on break of coal ore:
    if tool's name is "&6Level 1":
        set {_coalBroken} to uncoloured line 1 of lore of player's tool
        replace all "breaked coal " with "" in {_coalBroken}
        set {_coalBroken} to ({_coalBroken} parsed as number) + 1
        set lore of player's tool to "&7breaked coal &2%{_coalBroken}%"
        set {_item} to player's tool
        if {_coalBroken} is greater than or equal to 5:
            remove {_item} from player
            give a diamond pickaxe of efficiency 2 named "&6Level 2" with lore "" to player
 
This should fix your problem of upgrading
Code:
on break of coal ore:
    if tool's name is "&6Level 1":
        set {_coalBroken} to uncoloured line 1 of lore of player's tool
        replace all "breaked coal " with "" in {_coalBroken}
        set {_coalBroken} to ({_coalBroken} parsed as number) + 1
        set lore of player's tool to "&7breaked coal &2%{_coalBroken}%"
        set {_item} to player's tool
        if {_coalBroken} is greater than or equal to 5:
            remove {_item} from player
            give a diamond pickaxe of efficiency 2 named "&6Level 2" with lore "" to player
i will try now
[doublepost=1590506778,1590487373][/doublepost]
This should fix your problem of upgrading
Code:
on break of coal ore:
    if tool's name is "&6Level 1":
        set {_coalBroken} to uncoloured line 1 of lore of player's tool
        replace all "breaked coal " with "" in {_coalBroken}
        set {_coalBroken} to ({_coalBroken} parsed as number) + 1
        set lore of player's tool to "&7breaked coal &2%{_coalBroken}%"
        set {_item} to player's tool
        if {_coalBroken} is greater than or equal to 5:
            remove {_item} from player
            give a diamond pickaxe of efficiency 2 named "&6Level 2" with lore "" to player
can you explain me this code i trying to edit but not working
[doublepost=1590510071][/doublepost]
This should fix your problem of upgrading
Code:
on break of coal ore:
    if tool's name is "&6Level 1":
        set {_coalBroken} to uncoloured line 1 of lore of player's tool
        replace all "breaked coal " with "" in {_coalBroken}
        set {_coalBroken} to ({_coalBroken} parsed as number) + 1
        set lore of player's tool to "&7breaked coal &2%{_coalBroken}%"
        set {_item} to player's tool
        if {_coalBroken} is greater than or equal to 5:
            remove {_item} from player
            give a diamond pickaxe of efficiency 2 named "&6Level 2" with lore "" to player
when i try to edit it not working
 
Status
Not open for further replies.