Ive been trying to make the increments smaller in the line width tool
so i can do some more detailed stuff (and get it closer to my original artwork) *evils LM *
i know it has something to do with
local offset = moho:PixelToDoc((mouseEvent.pt.x - mouseEvent.startPt.x)/16)
but it seems no matter what i change its stil lthe same, actually i even put
print(offset)
right below that line
and it doesnt print the number ... ???
ive saved, done ctrl+f5, restarted moho, still doesnt come up.
I know the script is updating becasue if i check About Scripts.. the info has changed.
Can someone please help me, as i lose my internet connection tomorrow and i'll be going into a hermit hole(moving house/cardboard box/bench ) to animate with no contact of outside world... i really need this.
trying to modify linewidth tool but...
Moderators: Víctor Paredes, Belgarath, slowtiger
- spasmodic_cheese
- Posts: 330
- Joined: Wed Aug 04, 2004 2:02 am
Lua wont't print anything if it's a nil value. Off the top of my head, I would say change the value fron "print(offset)" to "print(self. offset). Is this something you declared as a variable in the script? I've had problems in debugging scripts where I was trying to print out an improperly declared variable. Like I said, If you declare it as a script wide variable, but don;t Hope that helps. use the "self" bit, you might be getting odd results. That saio, are youn sure that you're API call is formatted properly? The
PixelToDoc method was one I was looking at but couldn't quite figure out.
But I would also think, If you're working it this way, that you would want to include both X and Y offsets at the same time. Because Lua is too damn flexible, I prefer to declare many of my variables at the beginning of the script. I localize them after, and maybe it's a lil' clunky, but I can surely determine where they are and what they are supposed to do.
If you can, Put Up The Script. I have fair confidence I can tell you what's up.
Ain't this scripting thang fun?
Just remember, you are never going to print out a "nil" value, and if you find you aren't getting any results, you're variable is probably wrongly named
--Brian
PixelToDoc method was one I was looking at but couldn't quite figure out.
But I would also think, If you're working it this way, that you would want to include both X and Y offsets at the same time. Because Lua is too damn flexible, I prefer to declare many of my variables at the beginning of the script. I localize them after, and maybe it's a lil' clunky, but I can surely determine where they are and what they are supposed to do.
If you can, Put Up The Script. I have fair confidence I can tell you what's up.
Ain't this scripting thang fun?
Just remember, you are never going to print out a "nil" value, and if you find you aren't getting any results, you're variable is probably wrongly named
--Brian
- spasmodic_cheese
- Posts: 330
- Joined: Wed Aug 04, 2004 2:02 am
- spasmodic_cheese
- Posts: 330
- Joined: Wed Aug 04, 2004 2:02 am
- Lost Marble
- Site Admin
- Posts: 2354
- Joined: Tue Aug 03, 2004 6:02 pm
- Location: Scotts Valley, California, USA
- Contact:
print(offset) works fine for me. Make sure that the Lua console window isn't hidden behind the timeline - maybe you just can't see that it's printing.
However, all of this will do you no good - the line is getting as thin as it can possibly get. The offset value is a measure of how far you dragged the mouse. It then gets translated into the actual width value.
Moho's algorithm for variable-width lines won't let the line go down to an actual zero-width line. This tool already lets you make it as narrow as it can go.
As far as the Clamp function, here's an example:
LM.Clamp(pt.fWidth, 0, maxWidth)
It makes sure that the pt.fWidth value is no less than 0, and no more that maxWidth, and returns a value within that range. In other words:
if (pt.fWidth < 0) then
return 0
elseif (pt.fWidth > maxWidth) then
return maxWidth
else
return pt.fWidth
end
However, all of this will do you no good - the line is getting as thin as it can possibly get. The offset value is a measure of how far you dragged the mouse. It then gets translated into the actual width value.
Moho's algorithm for variable-width lines won't let the line go down to an actual zero-width line. This tool already lets you make it as narrow as it can go.
As far as the Clamp function, here's an example:
LM.Clamp(pt.fWidth, 0, maxWidth)
It makes sure that the pt.fWidth value is no less than 0, and no more that maxWidth, and returns a value within that range. In other words:
if (pt.fWidth < 0) then
return 0
elseif (pt.fWidth > maxWidth) then
return maxWidth
else
return pt.fWidth
end
- spasmodic_cheese
- Posts: 330
- Joined: Wed Aug 04, 2004 2:02 am
You wouldn't mind sharing the tool when you've got it done? I'm very interested to see how it turned out *flips open Lua book* Now then....
--Scott
cribble.net
cribble.net