Solved Local variable error

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

PatoFrango

Active Member
Jul 12, 2017
240
14
18
Hi,

I'm not sure why this happened, but after updating to dev37b, one of my scripts, water.sk, started giving errors apparentely about the use of a specific local variable in a specific function event.

Here's part of the code:

code_language.skript:
function cjwVictoryHandler(player: player):
    set {_match} to {cjw::onGoing}
    "%{_player}%" is not "Sensei"
    set {_uuid} to uuid of {_player}
    if {cjw::onGoing} is not "sensei":
        add 1 to {WinsWater::%{_uuid}%}
    wait 1 second
    if {_match} is "sensei":
        "%{masteredElements::%{_uuid}%::*}%" does not contain "water"
        amuletHandler({_player}, "water")
        add "water" to {masteredElements::%{_uuid}%::*}
        execute console command "/execute %{_player}% ~ ~ ~ /playsound minecraft:entity.player.levelup ambient %{_player}% ~ ~ ~ 10 0.6"
        send "" to {_player}
        send "&6&m-----------------------------------------" to {_player}
        send "&9&lParabéns, pupilo ninja. É agora Ninja da Água." to {_player}
        send "&6&m-----------------------------------------" to {_player}
        send "" to {_player}
    if {WinsWater::%{_uuid}%} is 10:
        give unbreakable leather boots with nbt "{display:{color:4488894},HideFlags:6}" named "Sandálias Correnteza" with lore "Card-Jitsu Água" to {_player}
        console command "/execute %{_player}% ~ ~ ~ /playsound entity.player.levelup voice %{_player}%"
        send "" to {_player}
        send "&7&l[Sensei] &fMuito bem pupilo!" to {_player}
        send "&7&l[Sensei] &fPinguim recebe &9&lSandálias Correnteza." to {_player}
        send "&7&l[Sensei] &fSensei espera que pinguim continue assim." to {_player}
        send "" to {_player}

And this is the error:

upload_2018-9-1_11-55-5.png


Apparentely Skript thinks the variable {_player} is an itemstack and not a player as how it's clearly declared in the function declaration. Another thing that's curious is that the error is only given when the variable is used in send effects, as for example when I was trying to set the variable {_uuid} to the UUID of {_player} it worked just fine.

I'm pretty sure this is something they've messed up on Skript's most recent update, dev37, as its changelog contained something along the lines of "added local variable type hints". I could be sounding completely stupid, I have no idea what they mean with "hints" and may not be related to this at all.

Any thoughts?

EDIT: And yes, before I updated to dev37 the entire script was 100% error/warning free.
 
Last edited:
Hi,

I'm not sure why this happened, but after updating to dev37b, one of my scripts, water.sk, started giving errors apparentely about the use of a specific local variable in a specific function event.

Here's part of the code:

code_language.skript:
function cjwVictoryHandler(player: player):
    set {_match} to {cjw::onGoing}
    "%{_player}%" is not "Sensei"
    set {_uuid} to uuid of {_player}
    if {cjw::onGoing} is not "sensei":
        add 1 to {WinsWater::%{_uuid}%}
    wait 1 second
    if {_match} is "sensei":
        "%{masteredElements::%{_uuid}%::*}%" does not contain "water"
        amuletHandler({_player}, "water")
        add "water" to {masteredElements::%{_uuid}%::*}
        execute console command "/execute %{_player}% ~ ~ ~ /playsound minecraft:entity.player.levelup ambient %{_player}% ~ ~ ~ 10 0.6"
        send "" to {_player}
        send "&6&m-----------------------------------------" to {_player}
        send "&9&lParabéns, pupilo ninja. É agora Ninja da Água." to {_player}
        send "&6&m-----------------------------------------" to {_player}
        send "" to {_player}
    if {WinsWater::%{_uuid}%} is 10:
        give unbreakable leather boots with nbt "{display:{color:4488894},HideFlags:6}" named "Sandálias Correnteza" with lore "Card-Jitsu Água" to {_player}
        console command "/execute %{_player}% ~ ~ ~ /playsound entity.player.levelup voice %{_player}%"
        send "" to {_player}
        send "&7&l[Sensei] &fMuito bem pupilo!" to {_player}
        send "&7&l[Sensei] &fPinguim recebe &9&lSandálias Correnteza." to {_player}
        send "&7&l[Sensei] &fSensei espera que pinguim continue assim." to {_player}
        send "" to {_player}

And this is the error:

View attachment 2667

Apparentely Skript thinks the variable {_player} is an itemstack and not a player as how it's clearly declared in the function declaration. Another thing that's curious is that the error is only given when the variable is used in send effects, as for example when I was trying to set the variable {_uuid} to the UUID of {_player} it worked just fine.

I'm pretty sure this is something they've messed up on Skript's most recent update, dev37, as its changelog contained something along the lines of "added local variable type hints". I could be sounding completely stupid, I have no idea what they mean with "hints" and may not be related to this at all.

Any thoughts?

EDIT: And yes, before I updated to dev37 the entire script was 100% error/warning free.
Use dev36 or dev37c lol
 
Status
Not open for further replies.