Solved Variable changing its value without input?

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

AwesomeGunGuy

New Member
Mar 5, 2018
5
0
0
29
Hello,

I am having problems with a variable changing its value, but I do not change it in the code:
Here is my code:

code_language.skript:
command /derp:
    trigger:
        set {helmet.%player%} to player's helmet
        message "%{helmet.%player%}%"
        enchant player's helmet with sharpness 1
        message "%{helmet.%player%}%"
        delete {helmet.%player%}

The result when wearing a leather helmet is:
leather_cap
leather_cap of Sharpness 1

But I never changed the variable {helmet.%player%} I only enchanted the players helmet, so the 2nd message should also have been leather_cap?

How do I fix this?

Thanks in advance.
 
I don't know for what you are using that variable for but you can fix by using:

code_language.skript:
set {helmet.%player%} to "%player's helmet%"
 
I want to set the variable as helmet again at a later time..
While the issue of the variable is solved, how would I set the variable as a helmet now?
[doublepost=1530395286,1530387090][/doublepost]I solved it, thanks for the input:
code_language.skript:
command /test1:
    trigger:
        loop all items in player's inventory:
            if loop-item is player's helmet:
                add loop-item to {%player%::equip::*}
        enchant player's helmet with curse of binding

command /test2:
    trigger:
        set player's helmet to index 0 of {%player%::equip::*}
        delete {%player%::equip::*}
 
You could've just set the variable to 1 of player's helmet instead of doing all those shenanigans.
 
Status
Not open for further replies.