Posted 04 March 2018 - 04:46 AM
I tried poking around the internet for a solution but came up flat. What I need is for an api function to affect a variable for the object. Here's what I want the program to do:
Here's the program as I have it:
There's more to the program I'm working on, but this is the piece I'm having trouble on. I'm working on understand tables and apis right now and this has gotten me quite stuck.
Also, I understand the code's not very efficient right now. You can nitpick it, but understand that I already see some of the glaring issues with it.
Spoiler
x=track
x.setPos(1,1,1)
print(x.x)
Here's the program as I have it:
track program
pos = {x=0,y=0,z=0}
rotation = 1
function setPos(x,y,z)
if typeCheck(x,y,z) then
pos.x = x
pos.y = y
pos.z =z
else
return false
end
return true
end
local function typeCheck(x,y,z)
if type(x) == type(y) and type(y) == type(z) and type(z) == "string" then
return true
else
return false
end
end
There's more to the program I'm working on, but this is the piece I'm having trouble on. I'm working on understand tables and apis right now and this has gotten me quite stuck.
Also, I understand the code's not very efficient right now. You can nitpick it, but understand that I already see some of the glaring issues with it.
Edited on 04 March 2018 - 05:21 AM