trying to modify linewidth tool but...

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
spasmodic_cheese
Posts: 330
Joined: Wed Aug 04, 2004 2:02 am

trying to modify linewidth tool but...

Post by spasmodic_cheese »

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 :P *

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.
User avatar
7feet
Posts: 840
Joined: Wed Aug 04, 2004 5:45 am
Location: L.I., New Yawk.
Contact:

Post by 7feet »

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
User avatar
spasmodic_cheese
Posts: 330
Joined: Wed Aug 04, 2004 2:02 am

Post by spasmodic_cheese »

the script is in your scripts/tool/ :roll:

lm_line_width.lua

i still can't get it to have smaller increments

im guessing offset is declared right since LM did it, and he reference it as just offset further down in the code.
User avatar
7feet
Posts: 840
Joined: Wed Aug 04, 2004 5:45 am
Location: L.I., New Yawk.
Contact:

Post by 7feet »

Yeah, but what did you write? Can't debug code unlesss I've seen it.

And I've used the Line Width script before to figure out other bits,
User avatar
spasmodic_cheese
Posts: 330
Joined: Wed Aug 04, 2004 2:02 am

Post by spasmodic_cheese »

i didnt write anything -_- i was trying to see what offset was so i can get a better idea on how it works, doesnt seem like anythign i touch changes it.

Wish i know how LM.Clamp worked
User avatar
Lost Marble
Site Admin
Posts: 2347
Joined: Tue Aug 03, 2004 6:02 pm
Location: Scotts Valley, California, USA
Contact:

Post by Lost Marble »

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
User avatar
spasmodic_cheese
Posts: 330
Joined: Wed Aug 04, 2004 2:02 am

Post by spasmodic_cheese »

thanks...
:(

i thought that might be the problem, moho's alg.

I guess i can get more accurate lines using fills, but its hard to select complex points...

Hopefully with the lua api the drawing tools will sort themselves out.
User avatar
cribble
Posts: 899
Joined: Wed Aug 04, 2004 12:42 pm
Location: London, UK
Contact:

Post by cribble »

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
Post Reply