1. 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!

  2. LOOKING FOR A VERSION OF SKRIPT?

    You can always check out our Wiki for downloads and any other information about Skript!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Solved Unable to compare local variable to integer

Discussion in 'Skript' started by meowucme, Aug 1, 2020 at 6:20 AM.

  1. meowucme

    meowucme Member

    Joined:
    Saturday
    Messages:
    5
    Likes Received:
    0
    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 (Text):
    1. command /gui-fill <player> <integer> <item>:
    2.     permission: op
    3.     trigger:
    4.         set {_local _slot} to 0
    5.         while _slot is less than arg-2:
    6.             format slot arg-2 of arg-1 with arg-3 named " " to close
    7.             add 1 to _slot
    Whenever I reload the file, I am greeted with this error message:

    "Can't compare '_slot' with an integer"
     
    #1 meowucme, Aug 1, 2020 at 6:20 AM
    Last edited: Aug 1, 2020 at 3:35 PM
  2. Best Answer:
    Post #2 by Time4Games, Aug 1, 2020 at 9:59 AM
  3. Time4Games

    Time4Games Well-Known Member

    Joined:
    Jul 25, 2020
    Messages:
    59
    Likes Received:
    1
    Try changing it to {_slot}.
    Also next time you send a code pls use this:
    S00801-11560170.jpg
     
  4. meowucme

    meowucme Member

    Joined:
    Saturday
    Messages:
    5
    Likes Received:
    0
    Thank u it worked

    im so dumb

    wait, why does it always return false?

    Code (Text):
    1. set {_local _slot} to 0
    2. while {_slot} < (arg-2 * 9):
    3.     ...
     
    #3 meowucme, Aug 1, 2020 at 3:48 PM
    Last edited: Aug 1, 2020 at 4:12 PM
  5. Time4Games

    Time4Games Well-Known Member

    Joined:
    Jul 25, 2020
    Messages:
    59
    Likes Received:
    1
    Becuase at the starting of the code you set {_slot} to 0
     
  6. meowucme

    meowucme Member

    Joined:
    Saturday
    Messages:
    5
    Likes Received:
    0
    if arg-2 is 10 then it should return true because 0 < 1
     
  7. Time4Games

    Time4Games Well-Known Member

    Joined:
    Jul 25, 2020
    Messages:
    59
    Likes Received:
    1
    can you send the whole code please
     
  8. meowucme

    meowucme Member

    Joined:
    Saturday
    Messages:
    5
    Likes Received:
    0
    Code (Text):
    1. command /shop:
    2.     trigger:
    3.         wait 3 ticks
    4.         open chest with 3 rows named "&bShop" to player
    5.         execute server command "/gui-fill %player% 3"
    6.  
    7.         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%"]
    8.  
    9. command /blocks <player>:
    10.     permission: op
    11.     trigger:
    12.         wait 3 ticks
    13.         open chest with 6 rows named "&bBuy/sell items" to arg-1
    14.         execute server command "/gui-fill %arg-1% 5"
    15.  
    16.         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"]
    17.  
    18. command /shopselect <player> <text>:
    19.     permission: op
    20.     trigger:
    21.         wait 3 ticks
    22.         open chest with 6 rows named "&bBuy/sell items" to arg-1
    23.         execute server command "/gui-fill %arg-1% 6"
    24.  
    25.         if arg-2 is "dirt":
    26.             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"]
    27.  
    28.  
    29. command /buy <player> <text>:
    30.     permission: op
    31.     trigger:
    32.         wait 3 ticks
    33.         if arg-2 is "dirt":
    34.             if arg-1's money >= 5:
    35.                 set arg-1's money to arg-1's money - 5
    36.                 send "&3Successfully bought dirt for $5!" to arg-1
    37.                 give arg-1 1 dirt
    38.             else:
    39.                 send "&cYou cannot afford this!" to arg-1
    40.  
    41. on death:
    42.     attacker is a player:
    43.         victim is a living entity:
    44.             if victim is an ender dragon:
    45.                 add 10000 to attacker's money
    46.                 send "&2You beat the ender dragon and gained $10000!"
    47.  
    48.             add (random integer between 10 and 15) to attacker's money
    49.  
    50. command /gui-fill <player> <integer>:
    51.     permission: op
    52.     trigger:
    53.         set {_local _slot} to 0
    54.         while {_slot} < (arg-2 * 9):
    55.             format slot {_slot} of arg-1 with black glass pane named " " to close
    56.             add 1 to {_slot}
    57.             send "looping" # how i know its not working
    sorry im rly bad at this
     
  9. Time4Games

    Time4Games Well-Known Member

    Joined:
    Jul 25, 2020
    Messages:
    59
    Likes Received:
    1
    where is the problem? what line?
    also instead of
    Code (Text):
    1. to run [execute server command "/buy %arg-1% dirt"]
    you can do
    Code (Text):
    1. to run server command "/buy %arg-1% dirt"
    --- Double Post Merged, Aug 2, 2020 at 4:35 PM, Original Post Date: Aug 2, 2020 at 4:29 PM ---
    Oh i see the problem. i will write a new /gui fill code and send you
    --- Double Post Merged, Aug 2, 2020 at 4:46 PM ---
    Here:
    Code (Text):
    1. command /gui-fill [<player>] [<integer>]:
    2.     permission: op
    3.     trigger:
    4.         set {_slot} to 0
    5.         while {_slot} < arg-2*9:
    6.             format gui slot {_slot} of arg-1 with black glass pane named " " to close
    7.             add 1 to {_slot}
    --- Double Post Merged, Aug 2, 2020 at 6:59 PM ---
    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.
     
  10. meowucme

    meowucme Member

    Joined:
    Saturday
    Messages:
    5
    Likes Received:
    0
    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.
     
  11. Time4Games

    Time4Games Well-Known Member

    Joined:
    Jul 25, 2020
    Messages:
    59
    Likes Received:
    1
    you can use 1 tab or 2/4 spaces
    --- Double Post Merged, Aug 4, 2020 at 11:43 AM, Original Post Date: Aug 4, 2020 at 11:41 AM ---
    also does it work now?
     
  12. Runakai

    Runakai Well-Known Member

    Joined:
    Apr 27, 2018
    Messages:
    468
    Likes Received:
    27
  13. Time4Games

    Time4Games Well-Known Member

    Joined:
    Jul 25, 2020
    Messages:
    59
    Likes Received:
    1
    But sometimes TuSke gui is better
     
  14. Runakai

    Runakai Well-Known Member

    Joined:
    Apr 27, 2018
    Messages:
    468
    Likes Received:
    27
    No.
     
  15. TPGamesNL

    Supporter Addon Developer Dev Programme

    Joined:
    Jan 20, 2018
    Messages:
    1,483
    Likes Received:
    93
    Medals:
    But it is usually easier
     
  16. Runakai

    Runakai Well-Known Member

    Joined:
    Apr 27, 2018
    Messages:
    468
    Likes Received:
    27
    Easier != Better
     
  17. Time4Games

    Time4Games Well-Known Member

    Joined:
    Jul 25, 2020
    Messages:
    59
    Likes Received:
    1
    Runakai everyone has his own thoughts.
     
  18. Runakai

    Runakai Well-Known Member

    Joined:
    Apr 27, 2018
    Messages:
    468
    Likes Received:
    27
    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.
     
Loading...