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 variables

Discussion in 'Skript' started by Marc, Dec 18, 2020.

Thread Status:
Not open for further replies.
  1. Marc

    Marc Active Member

    Joined:
    Nov 27, 2020
    Messages:
    94
    Likes Received:
    0
    If theres any possible way you could set a variable to true/false using a inventory click in a gui?

    No code, just wondering
     
  2. MusicManSK

    MusicManSK Active Member

    Joined:
    Nov 30, 2017
    Messages:
    232
    Likes Received:
    11
    Code (Text):
    1. Create a variable with initial state
    2. Create GUI with item describing value of the variable
    3.  
    4. Handle on inventory click event
    5.    Use logical negation to change the value of variable to it's opposite
    6.    Update inventory item (e.g. a red wool will become a green one)
    In programming this is usually done as:
    Code (Text):
    1. variable = !variable
     
  3. acai

    acai Active Member

    Joined:
    Oct 23, 2020
    Messages:
    89
    Likes Received:
    1
    Sure you can! Just make it so, you set the variable to 0 when the skript is loaded.
    Code (Text):
    1. if {this} is 0:
    2.   set {this} to 1
    3. else:
    4.   if {this} is 1:
    5.     set {this} to 0
    Simple!
     
  4. MusicManSK

    MusicManSK Active Member

    Joined:
    Nov 30, 2017
    Messages:
    232
    Likes Received:
    11
    This can be done even simpler:
    Code (Text):
    1. set {_boolean} to not {_boolean}
     
Thread Status:
Not open for further replies.

Share This Page

Loading...