Solved Adding 2 variables into 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 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.

verycoolguy123

Active Member
Jul 31, 2017
70
2
0
I remember seeing a skript which once utilized adding 2 variables responsible for location into 1 variable. I was wondering how that could be done?
 
Might you be referring to a list variable? like {locations::*} potentially adding the value of other variables to that? A bit more context would be helpful if that's not the case:emoji_slight_smile:
 
Might you be referring to a list variable? like {locations::*} potentially adding the value of other variables to that? A bit more context would be helpful if that's not the case:emoji_slight_smile:
I am not sure what a list variable is, all I am sure of is that I grabbed x, y and z and then combined them into 1 variable. Only reason I want to use this instead of grabbing their locations is because I don't want to use yaw and pitch.
 
I am not sure what a list variable is, all I am sure of is that I grabbed x, y and z and then combined them into 1 variable. Only reason I want to use this instead of grabbing their locations is because I don't want to use yaw and pitch.
Okay so maybe like this then?
code_language.skript:
set {_x} to player's x-coordinate
set {_y} to player's y-coordinate
set {_z} to player's z-coordinate
# then when wanting to reference this coords as a location do so by making the new variable
set {_location} to "%{_x}% %{_y}% %{_z}%"
# so now the variable {_location} is equal to X Y Z.  You could also set it to "%{_x}%, %{_y}%, %{_z}%"
# if you need commas for the location format
[doublepost=1501611427,1501611313][/doublepost]Oh also, just for information purposes, a list variable contains more than one value. You can add numbers, text etc to it and then loop the list to get all or select values out of it. Very useful, there's a great tutorial on it in the tutorial section.
 
Okay so maybe like this then?
code_language.skript:
set {_x} to player's x-coordinate
set {_y} to player's y-coordinate
set {_z} to player's z-coordinate
# then when wanting to reference this coords as a location do so by making the new variable
set {_location} to "%{_x}% %{_y}% %{_z}%"
# so now the variable {_location} is equal to X Y Z.  You could also set it to "%{_x}%, %{_y}%, %{_z}%"
# if you need commas for the location format
[doublepost=1501611427,1501611313][/doublepost]Oh also, just for information purposes, a list variable contains more than one value. You can add numbers, text etc to it and then loop the list to get all or select values out of it. Very useful, there's a great tutorial on it in the tutorial section.
Yes, but it does not seem to work for me. The variable seems to be fine but it does not teleport me.
 
Can you post your code?
code_language.skript:
command /ssm [<player>]:
    permission: ss.m
    permission message: &cYou do not have access to this command!
    executable by: console
    trigger:
        if arg 1 is not set:
            stop trigger
        if arg 1 is set:
            if {%arg-1%.ss} is true:
                set {%arg-1%.ss} to false
                delete {_ss.coords.%arg-1%}
                wait 5 ticks
                execute command "/mv tp %arg-1% spawn"
                set the arg-1's walk speed to 0.2
                stop trigger
            if {%arg-1%.ss} is not set:
                stop trigger
            if {%arg-1%.ss} is false:
                set {%arg-1%.ss} to true
                if arg-1 is in "ProPracticeArenas":
                    execute command "/cancel %arg-1% A player in your match has been frozen"
                    execute command "/mv tp %arg-1% freeze"
                    wait 10 ticks
                    set the arg-1's walk speed to 0
                    set {_ss.coords.x.%arg-1%} to x coordinate of arg-1
                    set {_ss.coords.y.%arg-1%} to y coordinate of arg-1
                    set {_ss.coords.z.%arg-1%} to z coordinate of arg-1
                    set {_ss.coords.%arg-1%} to "%{_ss.coords.x.%arg-1%}% %{_ss.coords.y.%arg-1%}% %{_ss.coords.z.%arg-1%}%"
                    while {%arg-1%.ss} is true:
                        set {_ss.coordscheck.x.%arg-1%} to x coordinate of arg-1
                        set {_ss.coordscheck.y.%arg-1%} to y coordinate of arg-1
                        set {_ss.coordscheck.z.%arg-1%} to z coordinate of arg-1
                        set {_ss.coordscheck.%arg-1%} to "%{_ss.coordscheck.x.%arg-1%}% %{_ss.coordscheck.y.%arg-1%}% %{_ss.coordscheck.z.%arg-1%}%"
                        if {_ss.coordscheck.%arg-1%} is not {_ss.coords.%arg-1%}:
                            teleport arg-1 to {_ss.coords.%arg-1%}
                            wait 20 ticks
                        
                        if {_ss.coordscheck.%arg-1%} is {_ss.coords.%arg-1%}:
                            set {_ss.coordscheck.x.%arg-1%} to x coordinate of arg-1
                            set {_ss.coordscheck.y.%arg-1%} to y coordinate of arg-1
                            set {_ss.coordscheck.z.%arg-1%} to z coordinate of arg-1
                            set {_ss.coordscheck.%arg-1%} to "%{_ss.coordscheck.x.%arg-1%}% %{_ss.coordscheck.y.%arg-1%}% %{_ss.coordscheck.z.%arg-1%}%"
                            wait 20 ticks
                else:
                    execute command "/mv tp %arg-1% freeze"
                    wait 10 ticks
                    set the arg-1's walk speed to 0
                    set {_ss.coords.x.%arg-1%} to x coordinate of arg-1
                    set {_ss.coords.y.%arg-1%} to y coordinate of arg-1
                    set {_ss.coords.z.%arg-1%} to z coordinate of arg-1
                    set {_ss.coords.%arg-1%} to "%{_ss.coords.x.%arg-1%}% %{_ss.coords.y.%arg-1%}% %{_ss.coords.z.%arg-1%}%"
                    while {%arg-1%.ss} is true:
                        set {_ss.coordscheck.x.%arg-1%} to x coordinate of arg-1
                        set {_ss.coordscheck.y.%arg-1%} to y coordinate of arg-1
                        set {_ss.coordscheck.z.%arg-1%} to z coordinate of arg-1
                        set {_ss.coordscheck.%arg-1%} to "%{_ss.coordscheck.x.%arg-1%}% %{_ss.coordscheck.y.%arg-1%}% %{_ss.coordscheck.z.%arg-1%}%"
                        if {_ss.coordscheck.%arg-1%} is not {_ss.coords.%arg-1%}:
                            teleport arg-1 to {_ss.coords.%arg-1%}
                            wait 20 ticks
                        
                        if {_ss.coordscheck.%arg-1%} is {_ss.coords.%arg-1%}:
                            set {_ss.coordscheck.x.%arg-1%} to x coordinate of arg-1
                            set {_ss.coordscheck.y.%arg-1%} to y coordinate of arg-1
                            set {_ss.coordscheck.z.%arg-1%} to z coordinate of arg-1
                            set {_ss.coordscheck.%arg-1%} to "%{_ss.coordscheck.x.%arg-1%}% %{_ss.coordscheck.y.%arg-1%}% %{_ss.coordscheck.z.%arg-1%}%"
                            wait 20 ticks
on join:
    set {%arg-1%.ss} to true
on quit:
    wait 1 tick
    if {%arg-1%.ss} is false:
        execute command "/ban %player% Logged out whilst frozen"
    clear {%arg-1%.ss}
    delete {_ss.coords.%arg-1%}
 
you probably just need to parse it as a location since rn its a text
code_language.skript:
set {_location} to "%{_x}% %{_y}% %{_z}%" parsed as location
or if that doesnt work use the location at expression http://bensku.github.io/Skript/expressions.html#ExprLocationAt
I get the exception "Text cannot be parsed as a location". I will try your other suggestion.
EDIT: Nope, that doesn't seem to work either. I get the exception "{_loc} can only be set to one object, not more"
[doublepost=1501615093][/doublepost]
I did this but it returns "'the world "Freeze"' is not an item stack". Here's my code
code_language.skript:
command /ssm [<player>]:
    permission: ss.m
    permission message: &cYou do not have access to this command!
    executable by: console
    trigger:
        if arg-1 is not set:
            stop trigger
        if arg-1 is set:
            if {%arg-1%.ss} is true:
                set {%arg-1%.ss} to false
                delete {_ss.coords.%arg-1%}
                wait 5 ticks
                execute command "/mv tp %arg-1% spawn"
                set the arg-1's walk speed to 0.2
                stop trigger
            if {%arg-1%.ss} is not set:
                stop trigger
            if {%arg-1%.ss} is false:
                set {%arg-1%.ss} to true
                if arg-1 is in "ProPracticeArenas":
                    execute command "/cancel %arg-1% A player in your match has been frozen"
                    execute command "/mv tp %arg-1% freeze"
                    wait 10 ticks
                    set the arg-1's walk speed to 0
                    set {_ss.coords.%arg-1%} to arg-1's x-coordinate, arg-1's y-coordinate, arg-1's z-coordinate of the world Freeze
                    while {%arg-1%.ss} is true:
                        set {_ss.coordscheck.%arg-1%} to arg-1's x-coordinate, arg-1's y-coordinate, arg-1's z-coordinate of the world Freeze
                        if {_ss.coordscheck.%arg-1%} is not {_ss.coords.%arg-1%}:
                            teleport arg-1 to {_ss.coords.%arg-1%}
                            wait 20 ticks
                        if {_ss.coordscheck.%arg-1%} is {_ss.coords.%arg-1%}:
                            set {_ss.coordscheck.%arg-1%} to arg-1's x-coordinate, arg-1's y-coordinate, arg-1's z-coordinate of the world Freeze
                            wait 20 ticks
                else:
                    execute command "/mv tp %arg-1% freeze"
                    wait 10 ticks
                    set the arg-1's walk speed to 0
                    set {_ss.coords.%arg-1%} to arg-1's x-coordinate, arg-1's y-coordinate, arg-1's z-coordinate of the world Freeze
                    while {%arg-1%.ss} is true:
                        set {_ss.coordscheck.%arg-1%} to arg-1's x-coordinate, arg-1's y-coordinate, arg-1's z-coordinate of the world Freeze
                        if {_ss.coordscheck.%arg-1%} is not {_ss.coords.%arg-1%}:
                            teleport arg-1 to {_ss.coords.%arg-1%}
                            wait 20 ticks
                        if {_ss.coordscheck.%arg-1%} is {_ss.coords.%arg-1%}:
                            set {_ss.coordscheck.%arg-1%} to arg-1's x-coordinate, arg-1's y-coordinate, arg-1's z-coordinate of the world Freeze
                            wait 20 ticks
on join:
    set {%arg-1%.ss} to true
on quit:
    wait 1 tick
    if {%arg-1%.ss} is false:
        execute command "/ban %player% Logged out whilst frozen"
    clear {%arg-1%.ss}
    delete {_ss.coords.%arg-1%}
 
@verycoolguy123 What @Wynnevir said is quite correct , but you can do it using just:

code_language.skript:
set {_location} to location at x-coords of player , y-coords of player, z-coords of player in world "world"
 
@verycoolguy123 What @Wynnevir said is quite correct , but you can do it using just:

code_language.skript:
set {_location} to location at x-coords of player , y-coords of player, z-coords of player in world "world"
It does not work for me. It doesn't teleport me. Here is my code:
code_language.skript:
                    set the arg-1's walk speed to 0
                    set {_ss.coords.%arg-1%} to location at x-coords of arg-1 , y-coords of arg-1, z-coords of arg-1 in world "Freeze"
                    while {%arg-1%.ss} is true:
                        set {_ss.coordscheck.%arg-1%} to location at x-coords of arg-1 , y-coords of arg-1, z-coords of arg-1 in world "Freeze"
                        if {_ss.coordscheck.%arg-1%} is not {_ss.coords.%arg-1%}:
                            teleport arg-1 to {_ss.coords.%arg-1%}
                            wait 20 ticks
                        if {_ss.coordscheck.%arg-1%} is {_ss.coords.%arg-1%}:
                            set {_ss.coordscheck.%arg-1%} to location at x-coords of arg-1 , y-coords of arg-1, z-coords of arg-1 in world "Freeze"
                            wait 20 ticks
 
That's just an example.

code_language.skript:
set {_loc} to location of arg-1
while {%arg-1%.ss} is true:
    set {_loc.check} to location of arg-1
    if {_loc} isn't {_loc.check}:
#CODE
    wait 5 ticks
 
That's just an example.

code_language.skript:
set {_loc} to location of arg-1
while {%arg-1%.ss} is true:
    set {_loc.check} to location of arg-1
    if {_loc} isn't {_loc.check}:
#CODE
    wait 5 ticks
The reason I'm not using location is because I don't want yaw and pitch.
 
code_language.skript:
set {_x} to x-coords of arg-1
set {_y} to y-coords of arg-1
set {_z} to z-coords of arg-1
while {%arg-1%.ss} is true:
    set {_x.check} to x-coords of arg-1
    set {_y.check} to y-coords of arg-1
    set {_z.check} to z-coords of arg-1
    if {_x} isn't {_x.check}:
        set {_next} to true
    if {_y} isn't {_y.check}:
        set {_next} to true
    if {_z} isn't {_z.check}:
        set {_next} to true
    if {_next} is true:
#CODE
    wait 5 ticks
 
code_language.skript:
set {_x} to x-coords of arg-1
set {_y} to y-coords of arg-1
set {_z} to z-coords of arg-1
while {%arg-1%.ss} is true:
    set {_x.check} to x-coords of arg-1
    set {_y.check} to y-coords of arg-1
    set {_z.check} to z-coords of arg-1
    if {_x} isn't {_x.check}:
        set {_next} to true
    if {_y} isn't {_y.check}:
        set {_next} to true
    if {_z} isn't {_z.check}:
        set {_next} to true
    if {_next} is true:
#CODE
    wait 5 ticks
I did this and it does not work
code_language.skript:
                    set {_ss.coords.x.%arg-1%} to x-coords of arg-1
                    set {_ss.coords.y.%arg-1%} to y-coords of arg-1
                    set {_ss.coords.z.%arg-1%} to z-coords of arg-1
                    set {_ss.coords.%arg-1%} to arg-1's location
                    while {%arg-1%.ss} is true:
                        set {_ss.coordscheck.x.%arg-1%} to x-coords of arg-1
                        set {_ss.coordscheck.y.%arg-1%} to y-coords of arg-1
                        set {_ss.coordscheck.z.%arg-1%} to z-coords of arg-1
                        if {_ss.coordscheck.x.%arg-1%} is not {_ss.coords.x.%arg-1%}:
                            set {_next} to true
                        if {_ss.coordscheck.y.%arg-1%} is not {_ss.coords.y.%arg-1%}:
                            set {_next} to true
                        if {_ss.coordscheck.z.%arg-1%} is not {_ss.coords.z.%arg-1%}:
                            set {_next} to true
                        if {_next} is true:
                            teleport arg-1 to {_ss.coords.%arg-1%}
[doublepost=1501684056,1501679107][/doublepost]I wasn't able to do this and at this point I'm drifting off the main topic. I found a workaround which doesn't involve doing this, but it works for me. Marked as solved.
 
Okay so maybe like this then?
code_language.skript:
set {_x} to player's x-coordinate
set {_y} to player's y-coordinate
set {_z} to player's z-coordinate
# then when wanting to reference this coords as a location do so by making the new variable
set {_location} to "%{_x}% %{_y}% %{_z}%"
# so now the variable {_location} is equal to X Y Z.  You could also set it to "%{_x}%, %{_y}%, %{_z}%"
# if you need commas for the location format
[doublepost=1501611427,1501611313][/doublepost]Oh also, just for information purposes, a list variable contains more than one value. You can add numbers, text etc to it and then loop the list to get all or select values out of it. Very useful, there's a great tutorial on it in the tutorial section.
code_language.skript:
set {_x} to x-coords of arg-1
set {_y} to y-coords of arg-1
set {_z} to z-coords of arg-1
while {%arg-1%.ss} is true:
    set {_x.check} to x-coords of arg-1
    set {_y.check} to y-coords of arg-1
    set {_z.check} to z-coords of arg-1
    if {_x} isn't {_x.check}:
        set {_next} to true
    if {_y} isn't {_y.check}:
        set {_next} to true
    if {_z} isn't {_z.check}:
        set {_next} to true
    if {_next} is true:
#CODE
    wait 5 ticks
It can have more than one, but it can also only have one value
 
  • Like
Reactions: Wynnevir
Status
Not open for further replies.