Jump to content

Easy Programming question


Slastraf
 Share

Recommended Posts

i hope i understand it correctly what you are trying to do.

 

you can do the following:

function Script:CreateNewParent(pName,x,y,z)
--self.parent[pName]=nil
self.parent[pName] = Model:Box()
self.parent[pName]:SetPosition(x,y,z)
end

 

after a

self:CreateNewParent('yourchoosenname', 0, 0, 0)

you should be able to access it with self.parent.yourchoosenname

 

//Edit:

if you want to make the current entity a parent of the new one you would have to add

self.entity:SetParent(self.parent[pName])

after you created it.

Edited by beo6
  • Upvote 1
Link to comment
Share on other sites

i hope i understand it correctly what you are trying to do.

 

you can do the following:

function Script:CreateNewParent(pName,x,y,z)
--self.parent[pName]=nil
self.parent[pName] = Model:Box()
self.parent[pName]:SetPosition(x,y,z)
end

 

after a

self:CreateNewParent('yourchoosenname', 0, 0, 0)

you should be able to access it with self.parent.yourchoosenname

 

//Edit:

if you want to make the current entity a parent of the new one you would have to add

self.entity:SetParent(self.parent[pName])

after you created it.

I want to make a joint, I already have implemented CreateNewJoint,

the joints dont need different names but the parts of the thing that I want to make do.

But thank you for answering

Link to comment
Share on other sites

Looks like you might want to make linked lists....

 

But for named lists use [] around a string

So now I have the error that self.parent is a nil value,

but since I want to create a self.parent inside the function, it is not very usable.

So how do I make sure that I create an entity inside the function and not inside the start() function?

I also tried to put it in an array table.insert(a,self.parent[pName]) (If theres an other way that would be better)

Link to comment
Share on other sites

It might help if you asked the question in the other thread so people can see exactly what you are trying to do. So let me try to understand. You want to specify a start and end point. Then you want to have joints automatically generated in between?

 

So wouldn't you specify the start point and then end point, then divide the distance between them by the number of ball joints you need. The first ball joint would be the child of the start point, the second would be the child of the first and parent of the third and so on. when you get to the last one you assign that to be the parent of the end point.

 

I would do some pseudo -code, but I haven't slept in a while....

  • Upvote 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...