Single variables to List variables

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

SoMuchWessel

Active Member
Apr 3, 2017
147
3
18
46
Hey guys,

I use a lot of single variables in my code, which is a bit unefficient. So I want to learn more about list variables and how they work.
But what i want more is how to convert some of my single variables into list variables, doing the same thing.

Like here i have some examples of single variables that i use a lot in my codes:

code_language.skript:
set {%player%.secondary} to true
set {%player%.count} to 1
if {%player%.team} = true:
add 1 to {%player%.team}
subtract 1 from {arena1.redteam}

Can you guys help me with list variables, and converting those single variable examples into list variables?
 
Maybe this will work:

code_language.skript:
command /variabletransform
  permission: skript.admin
  trigger:
    if {arena1.redteam} is set:
      set {arena::redteam} to {arena1.redteam}
    loop all offline players:
      if {%loop-player%.secondary} is set:
        set {secondary::%loop-player%::*} to {%loop-player%.secondary}
      if {%loop-player%.count} is set:
        set {count::%loop-player%::*} to {%loop-player%.count}
      if {%loop-player%.team} is set:
        set {team::%loop-player%::*} to {%loop-player%.team}

command /oldvariabledelete
  description: This will delete the old variables that you'll not need anymore. JUST USE THIS WHEN SURE EVERYTHING IS CORRECT WITH THE NEW VARIABLES!
  permission: skript.admin
  trigger:
    loop all offline players:
      clear {%loop-player%.secondary}
      clear {%loop-player%.count}
      clear {%loop-player%.team}
      clear {%loop-player%.team}
      clear {arena1.redteam}

Just use the second command after you test the values of the first one.
I don't know what this variables do, so you gotta see if this fits you, but I think the variables I set will work.

Now, for example, if you want to delete all players count, you just do:

code_language.skript:
clear {count::*}

And it will delete all count from all players at once, in one line of code.
 
Status
Not open for further replies.