Okay so I'm saving ent:GetPos() to a table and saving the table using TableToJSON and that all works fine however when I'm loading the table back in and trying to convert the saved vector strings back into vectors it just returns as 0 0 0
[code]
Ents4Mission = util.JSONToTable(file.Read("missions/mission1.txt"))
for i=1, #Ents4Mission.ents do
print(Ents4Mission.pos[i]) -- Prints the vector in string format
local vec = util.StringToType("1 -1 1.00", "Vector" ) -- Just a debug thing
local vec = util.StringToType(Ents4Mission.pos[i], "Vector" ) -- Right here the vector is turned into 0 0 0
print(vec)
end
[/code]
Im fairly certain that the Vector() function can take a 3 number string as a valid argument, so you could do this:
[code]local vec = Vector( Ents4Mission.pos[i] ) --This should work[/code]
If it was my files to mess around with, I would've set a string for a x, and a y, and z.
[code] Ent:GetPos().x // It extracts just the X value.[/code]
[code] Ent:GetPos().y // It extracts just the Y value.[/code]
[code] Ent:GetPos().z // It extracts just the Z value. [/code]
[code] Ent:GetAngles().x // It extracts just the Rotation X value. [/code]
[code] Ent:GetAngles().y // It extracts just the Rotation Y value. [/code]
[code] Ent:GetAngles().z // It extracts just the Rotation Z value.[/code]
I have no clue, what your going to do with these examples. Hopefully, it helps.
TableToJSON and JSONToTable automatically turn vectors into strings and the strings back into Vectors.
You shouldn't need to convert it manually
[code]
] lua_run print(util.TableToJSON({Vector(15,30,12)}))
> print(util.TableToJSON({Vector(15,30,12)}))...
{"1":"[15 30 12]"}
] lua_run PrintTable(util.JSONToTable(util.TableToJSON({Vector(15,30,12)})))
> PrintTable(util.JSONToTable(util.TableToJSON({Vector(15,30,12)})))...
1 = 15.000000 30.000000 12.000000
[/code]
The value is already a Vector which is why its coming out as 0 0 0
[code]> print(util.StringToType(Vector(), "Vector"))
0.000000 0.000000 0.000000[/code]
Sorry, you need to Log In to post a reply to this thread.