Solved Function always execute else

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

    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.

Inferno

Member
Feb 2, 2017
20
0
0
Skript Version: 2.2-dev30b
Skript Author: Bensku
Minecraft Version: 1.11.2
---
Full Code:

code_language.skript:
function test(arg1: text, player: player):
    send "%{_arg1}%" to {_player}
    if {_arg1} is "wow":
        format slot 10 of {_player} with ("20" parsed as item) named "Wow!" to be unstealable
        send "1" to {_player}
    else if {_arg1} is "hello":
        format slot 11 of {_player} with ("95:3" parsed as item) named "Hello." to be unstealable
        send "2" to {_player}
    else if {_arg1} is "third":
        format slot 12 of {_player} with ("95:4" parsed as item) named "Third" to be unstealable
        send "3" to {_player}
    else:
        format slot 13 of {_player} with ("95:5" parsed as item) named "Forth" to be unstealable
        send "4" to {_player}
   

command /test2 [<text>]:
    trigger:
        open virtual chest inventory named "Test" with size 6 to player
        set {_slot} to 0
        set {_loop::*} to "hello" and "wow" and "third" and "forth"
        loop {_loop::*}:
            format slot {_slot} of player with ("54" parsed as item) named "%{_slot}%" to run [test("%loop-value%", player)]
            add 1 to {_slot}

Errors on Reload:

code_language.skript:
None.

Other Useful Info:

Addons using (including versions):
SkQuery 3.6.0-Lime, ExertSK 0.1.3b, skUtilities 0.9.0, skRayFall 1.9.10, Skellett 1.9.6b, TuSKe 1.8.2

Troubleshooting:

Have you tried searching the docs? Yes
Have you tried searching the forums? Yes
What other methods have you tried to fix it? Used debugging messages & tried various different methods. Basically, the function always executes the 'else' statement no matter what item is clicked in the inventory.
 
Skript Version: 2.2-dev30b
Skript Author: Bensku
Minecraft Version: 1.11.2
---
Full Code:

code_language.skript:
function test(arg1: text, player: player):
    send "%{_arg1}%" to {_player}
    if {_arg1} is "wow":
        format slot 10 of {_player} with ("20" parsed as item) named "Wow!" to be unstealable
        send "1" to {_player}
    else if {_arg1} is "hello":
        format slot 11 of {_player} with ("95:3" parsed as item) named "Hello." to be unstealable
        send "2" to {_player}
    else if {_arg1} is "third":
        format slot 12 of {_player} with ("95:4" parsed as item) named "Third" to be unstealable
        send "3" to {_player}
    else:
        format slot 13 of {_player} with ("95:5" parsed as item) named "Forth" to be unstealable
        send "4" to {_player}
  

command /test2 [<text>]:
    trigger:
        open virtual chest inventory named "Test" with size 6 to player
        set {_slot} to 0
        set {_loop::*} to "hello" and "wow" and "third" and "forth"
        loop {_loop::*}:
            format slot {_slot} of player with ("54" parsed as item) named "%{_slot}%" to run [test("%loop-value%", player)]
            add 1 to {_slot}

Errors on Reload:

code_language.skript:
None.

Other Useful Info:

Addons using (including versions):
SkQuery 3.6.0-Lime, ExertSK 0.1.3b, skUtilities 0.9.0, skRayFall 1.9.10, Skellett 1.9.6b, TuSKe 1.8.2

Troubleshooting:

Have you tried searching the docs? Yes
Have you tried searching the forums? Yes
What other methods have you tried to fix it? Used debugging messages & tried various different methods. Basically, the function always executes the 'else' statement no matter what item is clicked in the inventory.
Change arg1 to string
[doublepost=1511259300,1511259055][/doublepost]
Change arg1 to string
code_language.skript:
Command /test [<text>]:
    Trigger:
        Test("%arg-1%", player)
 
What would you suggest I use?
I recommend tuske advanced guis, from there you have to set a variable to the loop-value and then use the variable instead. It's just a quirk of how skript handles that expression.
 
  • Like
Reactions: Inferno
Status
Not open for further replies.