Solved Location in YML

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

Jordan

Member
Jan 25, 2017
190
12
18
26
Scotland
Does anyone have a link to the tutorial or is able to let me know how to read a location from a YML file?

I can write a location easy enough however trying to read it and teleport a player to that location never works.

I remember on the old forums there was a tutorial on it but the old forums don't exist anymore.

Thanks :emoji_slight_smile:
 
Maybe use "parsed as location"

E.g:

code_language.skript:
Set {_a} to yaml value "location" from file "../../dir/file.yml"
Teleport player to ({_a} parsed as location)
 
  • Like
Reactions: Spirit1998HD
So what you can manually do is this:

code_language.skript:
command /test <text>:
    trigger:
        set {_location} to player's location
        set x-coordinates of {_location} to yaml value "location.x" from file "plugins/Skript/scripts/locations/%arg 1%.yml"
        set y-coordinates of {_location} to yaml value "location.y" from file "plugins/Skript/scripts/locations/%arg 1%.yml"
        set z-coordinates of {_location} to yaml value "location.z" from file "plugins/Skript/scripts/locations/%arg 1%.yml"
        teleport player to {_location}
        clear {_location}
        stop trigger

So the argument is the name of the file where the location is saved to. The yml file should look like this:

location:
x: 120
y: 70
z: 120

So this should work but i can't test it at the moment.
 
you can use this function if you want to do it in the way you were doing it:
code_language.skript:
function text2Loc(location: text, world: world) :: location:
    set {_loc::*} to {_location} parsed as "x: %num%, y: %num%, z: %num%"
    return location({_loc::1}, {_loc::2}, {_loc::3}, {_world})
Then you would do:
code_language.skript:
command /hello:
    trigger:
        set {_a} to yml value "test" of file "Test/test.yml"
        teleport sender to text2Loc("%{_a}%", event-world)
 
Status
Not open for further replies.