Numerical Text Script

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

Moderators: Fahim, Distinct Sun, Víctor Paredes, erey, Belgarath, slowtiger

Post Reply
User avatar
DK
Posts: 2498
Joined: Mon Aug 09, 2004 6:06 am
Location: Australia

Numerical Text Script

Post by DK » Mon Feb 17, 2020 1:51 am

Hi.
Is it possible to write a script that increases a numerical text value by 1 each time it is pasted from the clip board?
Trying to create several dot to dot puzzles for my nephew and it is extremely time consuming typing the numbers
each time. I thought someone on the forum might know a quicker way to do this via a script?

Cheers
D.K
hayasidist
Posts: 2201
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: Numerical Text Script

Post by hayasidist » Mon Feb 17, 2020 10:37 am

I'm assuming you're creating a still image? there's a function "InsertText" http://mohoscripting.com/methods/85 -- what you might consider is to use that in a loop along with CreateNewLayer(layerType) and param.Text:Set(n) where n is (text) number incremented each loop to create as many text layers as you need …

getting even more cute - if you draw just the path of the target dot to dot, adding control points in the right order, that same script could add "dots" at each control point and place the number ...
User avatar
DK
Posts: 2498
Joined: Mon Aug 09, 2004 6:06 am
Location: Australia

Re: Numerical Text Script

Post by DK » Mon Feb 17, 2020 9:05 pm

Great ideas there Hayasidist. I ended up writing an external html5 app that increments a variable by pressing a button and copies it to clipboard for pasting into Moho. Wish I knew a bit more about Moho Scripting to be able to pull off what you suggest though.
Cheers
D.K
User avatar
slowtiger
Posts: 5497
Joined: Thu Feb 16, 2006 6:53 pm
Location: Berlin, Germany
Contact:

Re: Numerical Text Script

Post by slowtiger » Mon Feb 17, 2020 10:31 pm

In TVPaint, I'd import any counter GIF, make it a brush, and just click through ...
AS 9.5 MacPro Quadcore 3GHz 16GB RAM OS 10.6.8 Quicktime 7.6.6
AS 11 MacPro 12core 3GHz 32GB RAM OS 10.11 Quicktime 10.7.3
User avatar
DK
Posts: 2498
Joined: Mon Aug 09, 2004 6:06 am
Location: Australia

Re: Numerical Text Script

Post by DK » Mon Feb 17, 2020 10:46 pm

Wow slow! I would never had put those together in a million years. Nice thinking outside the box there :D !
Cheers
D.K
User avatar
slowtiger
Posts: 5497
Joined: Thu Feb 16, 2006 6:53 pm
Location: Berlin, Germany
Contact:

Re: Numerical Text Script

Post by slowtiger » Tue Feb 18, 2020 9:44 am

Comes from decade-long working in Flash (and Director before that), I must admit. I was so used to program a little thing like this. And TVPaint has this custom brush thing which has it in-built to step through a sequence of images. Much like one of those numbering stamps which increase the numbers with each punch, does anyone remember those?

(And I grew up with these connect-the-numbers-books by Hans Jürgen Press, one of my favourite illustrators.)
AS 9.5 MacPro Quadcore 3GHz 16GB RAM OS 10.6.8 Quicktime 7.6.6
AS 11 MacPro 12core 3GHz 32GB RAM OS 10.11 Quicktime 10.7.3
hayasidist
Posts: 2201
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: Numerical Text Script

Post by hayasidist » Sat Feb 22, 2020 2:20 pm

too late for this time, but as I had a couple of hours free …

a tool that will put one number, in sequence at each mouse click (or generate the whole sequence) …

https://www.mediafire.com/file/leo0kiyp ... s.zip/file

that .zip has s folder for the script installation tool and a readme.


A word of warning: generating a whole sequence or more than (say) 50 can take what feels like a very LONG time so be patient if you do choose that option.

This tool runs on Moho 12 or later.
There are no known issues, but please let me know of errors or if there are enhancements you'd like ...
User avatar
Penny
Posts: 44
Joined: Sun Dec 02, 2018 3:56 pm
Location: Italy

Re: Numerical Text Script

Post by Penny » Sat Feb 22, 2020 11:20 pm

hayasidist wrote:
Sat Feb 22, 2020 2:20 pm
too late for this time, but as I had a couple of hours free …

a tool that will put one number, in sequence at each mouse click (or generate the whole sequence) …

https://www.mediafire.com/file/leo0kiyp ... s.zip/file

that .zip has s folder for the script installation tool and a readme.


A word of warning: generating a whole sequence or more than (say) 50 can take what feels like a very LONG time so be patient if you do choose that option.

This tool runs on Moho 12 or later.
There are no known issues, but please let me know of errors or if there are enhancements you'd like ...
Wow! It's a really useful script! I tried it right now and I'm sure i'll be using it a lot! Thanks for developing!
Even with the head in the clouds You can touch the ground

https://www.facebook.com/santiago.penny
https://www.behance.net/pennysantiago
User avatar
DK
Posts: 2498
Joined: Mon Aug 09, 2004 6:06 am
Location: Australia

Re: Numerical Text Script

Post by DK » Fri Feb 28, 2020 1:00 am

Hayasidist.
So sorry for the late reply. I never received a notification that there was a response.
I am about to look at your script now and report back.

Cheers
D.K
User avatar
DK
Posts: 2498
Joined: Mon Aug 09, 2004 6:06 am
Location: Australia

Re: Numerical Text Script

Post by DK » Fri Feb 28, 2020 1:10 am

Hayasidist! That script is amazing!
It would be even better if you could lick and drag a line then the number appears but as it is it's extremely useful.
Much faster than my "Copy number to clipboard" html5 app.

Many thanks
Cheers
D.K
User avatar
DK
Posts: 2498
Joined: Mon Aug 09, 2004 6:06 am
Location: Australia

Re: Numerical Text Script

Post by DK » Fri Feb 28, 2020 4:34 am

I created a SpotFont to go with the script using the numbers 1 -10 on the keyboard as spots. It works great till you get to 10 then it starts putting double dots down...LOL. I clearly didn't think this through :oops:

www.creativetvandmedia.com/Forum/DKSpotFont.ttf

Cheers
D.K
hayasidist
Posts: 2201
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: Numerical Text Script

Post by hayasidist » Fri Feb 28, 2020 9:09 am

DK wrote:
Fri Feb 28, 2020 1:10 am
Hayasidist! That script is amazing!
It would be even better if you could lick and drag a line then the number appears ...
Thanks for the positive comment!!

I did think about adding the "path" and dots, but I got stuck in a brain loop thinking about placement wrt the number - in the "simple case" there's a choice of 4 relative orientations: number left / above / right / below the dot -- then, looking at the dot-to-dot's my son (he's 6!) has, there are the "lines that are pre-drawn" and .. and ...

in the end I decided that it was something that I couldn't reliably automate (possibly ever, but certainly not in the time I had to put the rest of it together) and so left it out ... BUT … given a path, it is feasible to add dots (on the path at control points where the segment is hidden) and numbers on the "outside" (i.e. on the imaginary vector that extends from shape centre through the control point) … if that's helpful, I'll stick on the list for "next time".
User avatar
DK
Posts: 2498
Joined: Mon Aug 09, 2004 6:06 am
Location: Australia

Re: Numerical Text Script

Post by DK » Mon Mar 02, 2020 12:13 am

Yes....I noticed that when I started placing the numbers around a line. It was something you couldn't really automate especially when you reach a sharp corner or a line that goes back on itself and you need to drag the number around so it's outside the line path. It's a great script anyhow hayasidist!!!
Cheers
D.K
Post Reply