Cepillado Posted May 5, 2014 Share Posted May 5, 2014 Hello, I'm having a problem loading a position from a player file into the script, I saved the position as a string and now I can't load it. Here's what I have The string goes like this: Position: 0.000000,0.000000,100.000000(I know that this will spawn me really high, that's not the point)I've tried splitting it like this: local x,y,z = fileRead(playerPos,28) split("x,y,z", ",") setElementPosition(player,x,y,z) And I just keep spawning at the same place, under the ground (As if the z coord equals to 0) Also, I would like to know, since the position length can vary, how can I tell the script to grab the exact amount of numbers that are in the string? For example: 0.000000,0.000000,100.000000 equals to 28 characters, but if it was 10.000000,0.000000,100.000000 it would equal to 29, how could I make the script know when is the end of the string? Because if I use fileRead(playerPos,29) and it's just 28 characters, it would grab the next thing on the file, making the Z coord unusable. Thanks Link to comment
cheez3d Posted May 5, 2014 Share Posted May 5, 2014 Why don't you use XML? As for the size problem you can use fileGetSize(). Link to comment
Moderators IIYAMA Posted May 5, 2014 Moderators Share Posted May 5, 2014 local thePosition = fileRead(playerPos, fileGetSize (playerPos)) local x,y,z = unpack(split(thePosition, ",")) if x and y and z then setElementPosition(player,x,y,z) end Link to comment
Tete omar Posted May 5, 2014 Share Posted May 5, 2014 Reminder: Note: The file functions should not be used to implement configuration files. It is encouraged to use the XML functions for this instead.) (fileCreate) Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now