I am soooo close to getting a basic tp home mod up but stuck on what I hope is the last hurdle.
error
- I can retrieve the users co-ordinates
- I can add values to datafile for users
- I can pull values from datafile for users
- fail when trying to put the co-ordinates back
[Oxide] 4:30 PM [Error] tphome: [string "tphome.lua"]:97: attempt to index field
'transform' (a nil value)
The line failing is;
the following script is retrieving the x,y,z and putting into a single variable (target)Code:ply.transform.position = target.transform.position
The original value looks like this when captured;Code:x = tonumber(datatable.entries[steamID][tmplocation][1]) y = tonumber(datatable.entries[steamID][tmplocation][2]) z = tonumber(datatable.entries[steamID][tmplocation][3]) target = "(" .. x .. ", " .. y .. ", " .. z .. ")"
(-840.5, 10.2, 2012.2)
the value I am pushing back looks like this;
(-840.52667236328, 10.184094429016, 2012.1553955078)
What a pain in the *&^%
Solved Vector3 - transform.position
Discussion in 'Rust Development' started by Taffy, Oct 18, 2014.
-
Wulf Community Admin
Did you look at the teleportation plugin that @Mughisi put together? http://oxidemod.org/resources/teleportation-system.660/
-
-
Your target is a string and not of the type Vector3. At this time you can't create your own Vector3 yet. You want to grab the player position first and then modify the x, y & z values. If it won't work just message me and I'll give you a hand or wait until I finish my update for my tp system since it actually holds code for sethome & tphome already.
-
I didn't try but I think Vector3 look like this
Vector3 = { x=0 ,y=0 ,z=0 } -
That would result in a table with the keys x, y and z. And not a Vector3 type.
-
Code:target = "(" .. x .. ", " .. y .. ", " .. z .. ")"
Code:ply.transform.position.x = x ply.transform.position.y = y ply.transform.position.z = z
-
-
Worked a treat thanks chaps. Code in tp home plugin
Thanks for the assistance
Cheers
Dave