Setting a variable to a bone fPos... issue solved

Moho allows users to write new tools and plugins. Discuss scripting ideas and problems here.

Moderators: Víctor Paredes, Belgarath, slowtiger

Post Reply
User avatar
heyvern
Posts: 7035
Joined: Fri Sep 02, 2005 4:49 am

Setting a variable to a bone fPos... issue solved

Post by heyvern »

I was having trouble with the following code:

Code: Select all

local pBone1 = skel:Bone(mstr2.fParent)
local vec2 = LM.Vector2:new_local()
vec2:Set(mstr2.fPos)
pBone1.fMovedMatrix:Transform(vec2)
It caused a big problem with the bones fPos and how it moved the vector points.

I could not get around this. It seems that copying the bone position to a variable in conjunction with transforming the variable from the parent bone was effecting the bones fPos.

I finally found an alternate way to "copy" the bone fPos to a variable:

Code: Select all

local pBone1 = skel:Bone(mstr2.fParent)
local vec2 = LM.Vector2:new_local()
vec2.x = mstr2.fPos.x
vec2.y = mstr2.fPos.y
pBone1.fMovedMatrix:Transform(vec2)
By setting the variable vec2 individual x and y attributes separately it works.

There are several scripts that are effected by this. The TransRotate and RotateTrans that Rasheed and I have been working on. I plan to update those so they work properly.

This is a major breakthrough for me. I'm very happy.

I hope this might help others doing lua scripting.

-vern
Post Reply