Solved Unable to compare local variable to integer

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

meowucme

New Member
Aug 1, 2020
5
0
0
24
I have search everywhere on the internet, and I can't figure out how to do it. I have tried making it a global variable, and many other things, but none of them worked.

Code:
command /gui-fill <player> <integer> <item>:
    permission: op
    trigger:
        set {_local _slot} to 0
        while _slot is less than arg-2:
            format slot arg-2 of arg-1 with arg-3 named " " to close
            add 1 to _slot

Whenever I reload the file, I am greeted with this error message:

"Can't compare '_slot' with an integer"
 
Last edited:
I have search everywhere on the internet, and I can't figure out how to do it. I have tried making it a global variable, and many other things, but none of them worked.

command /gui-fill <player> <integer> <item>:
permission: op
trigger:
set {_local _slot} to 0
while _slot is less than arg-2:
format slot arg-2 of arg-1 with arg-3 named " " to close
add 1 to _slot

Whenever I reload the file, I am greeted with this error message:

Can't compare '_slot' with an integer

Try changing it to {_slot}.
Also next time you send a code pls use this:
S00801-11560170.jpg
 
Thank u it worked

im so dumb

wait, why does it always return false?

Code:
set {_local _slot} to 0
while {_slot} < (arg-2 * 9):
    ...
 
Last edited:
Code:
command /shop:
    trigger:
        wait 3 ticks
        open chest with 3 rows named "&bShop" to player
        execute server command "/gui-fill %player% 3"

        format slot 10 of player with brick block named "&dBlocks" with lore "&bAll the blocks you will" and "&bever need for beautiful" and "&bbuildings to show off" to close then run [execute console command "/blocks %player%"]
 
command /blocks <player>:
    permission: op
    trigger:
        wait 3 ticks
        open chest with 6 rows named "&bBuy/sell items" to arg-1
        execute server command "/gui-fill %arg-1% 5"

        format slot 10 of arg-1 with dirt named "&7Dirt" with lore "&2Buy (Left Click): $5" to close then run [execute server command "/shopselect %arg-1% dirt"]

command /shopselect <player> <text>:
    permission: op
    trigger:
        wait 3 ticks
        open chest with 6 rows named "&bBuy/sell items" to arg-1
        execute server command "/gui-fill %arg-1% 6"

        if arg-2 is "dirt":
            format slot 13 of arg-1 with dirt named "&7Dirt" with lore "&2Buy (Left Click): $5" to run [execute server command "/buy %arg-1% dirt"]


command /buy <player> <text>:
    permission: op
    trigger:
        wait 3 ticks
        if arg-2 is "dirt":
            if arg-1's money >= 5:
                set arg-1's money to arg-1's money - 5
                send "&3Successfully bought dirt for $5!" to arg-1
                give arg-1 1 dirt
            else:
                send "&cYou cannot afford this!" to arg-1

on death:
    attacker is a player:
        victim is a living entity:
            if victim is an ender dragon:
                add 10000 to attacker's money
                send "&2You beat the ender dragon and gained $10000!"

            add (random integer between 10 and 15) to attacker's money

command /gui-fill <player> <integer>:
    permission: op
    trigger:
        set {_local _slot} to 0
        while {_slot} < (arg-2 * 9):
            format slot {_slot} of arg-1 with black glass pane named " " to close
            add 1 to {_slot}
            send "looping" # how i know its not working

sorry im rly bad at this
 
where is the problem? what line?
also instead of
Code:
to run [execute server command "/buy %arg-1% dirt"]
you can do
Code:
to run server command "/buy %arg-1% dirt"
[doublepost=1596382529,1596382169][/doublepost]Oh i see the problem. i will write a new /gui fill code and send you
[doublepost=1596383194][/doublepost]Here:
Code:
command /gui-fill [<player>] [<integer>]:
    permission: op
    trigger:
        set {_slot} to 0
        while {_slot} < arg-2*9:
            format gui slot {_slot} of arg-1 with black glass pane named " " to close
            add 1 to {_slot}
[doublepost=1596391180][/doublepost]Also I recommend you to use tabs because it's easier to fix problems with it. I also used spaces when I started but I changed to tabs and I write codes much faster now. If you won't switch to tabs you should use 2 spaces instead of 4.
Of course you don't have to and its just a recommendation.
 
where is the problem? what line?
also instead of
Code:
to run [execute server command "/buy %arg-1% dirt"]
you can do
Code:
to run server command "/buy %arg-1% dirt"
[doublepost=1596382529,1596382169][/doublepost]Oh i see the problem. i will write a new /gui fill code and send you
[doublepost=1596383194][/doublepost]Here:
Code:
command /gui-fill [<player>] [<integer>]:
    permission: op
    trigger:
        set {_slot} to 0
        while {_slot} < arg-2*9:
            format gui slot {_slot} of arg-1 with black glass pane named " " to close
            add 1 to {_slot}
[doublepost=1596391180][/doublepost]Also I recommend you to use tabs because it's easier to fix problems with it. I also used spaces when I started but I changed to tabs and I write codes much faster now. If you won't switch to tabs you should use 2 spaces instead of 4.
Of course you don't have to and its just a recommendation.

what do the brackets do around the parameters? is that what my error was? or was it that i put _local and thats not a part of skript? or something else?

also i use tabs but Visual Studio Code turns it into spaces but makes them behave the same way as tabs.
 
Last edited:
what do the brackets do around the parameters? is that what my error was? or was it that i put _local and thats not a part of skript? or something else?

also i use tabs but Visual Studios Code turns it into spaces but makes them behave the same way as tabs.

you can use 1 tab or 2/4 spaces
[doublepost=1596537780,1596537695][/doublepost]also does it work now?
 
Runakai everyone has his own thoughts.
Yes, and I want to share mine .TuSkE is an add-on and needed a fork from a different developer to even work. Vanilla GUIs approach a different way of doing guis which are better and faster. I don't care if you use TuSke but vanilla is better. And yes, they are vanilla. They don't require any addons. People get scared for asking help with TuSKe, but to be honest it's just ridiculous to use tuske when there are better options.
 
Yes, and I want to share mine .TuSkE is an add-on and needed a fork from a different developer to even work. Vanilla GUIs approach a different way of doing guis which are better and faster. I don't care if you use TuSke but vanilla is better. And yes, they are vanilla. They don't require any addons. People get scared for asking help with TuSKe, but to be honest it's just ridiculous to use tuske when there are better options.

I used vanilla guis but then they changed it to something more difficult. But i thought they removed it so i used TuSke and then my friend told me that they just changed it. If they wouldn't change it maybe i was using vanilla guis now but "learning" a new gui system is useless if i already know one.
sorry if there is bad grammar
 
I used vanilla guis but then they changed it to something more difficult. But i thought they removed it so i used TuSke and then my friend told me that they just changed it. If they wouldn't change it maybe i was using vanilla guis now but "learning" a new gui system is useless if i already know one.
sorry if there is bad grammar
How did they change? I changed it to metadata but you can use inventory names on 1.16 again. Metarata is the same concept and it's really easy
 
Status
Not open for further replies.