How do we help with scripting docs and examples?

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

Moderators: Víctor Paredes, Belgarath, slowtiger

User avatar
strider2000
Posts: 506
Joined: Sat Mar 07, 2015 5:14 pm
Contact:

How do we help with scripting docs and examples?

Post by strider2000 »

How do we contribute to the Scripting doc and
http://mohoscripting.com/introduction
and
http://mohoscripts.com/

I've registered on the sites, but I don't see ways to help. For example, when looking for information on deleting keys, I saw DeleteKeysAtFrame
http://mohoscripting.com/methods/741
It referenced ae_mix_smartbones.lua. I actually have that installed. However, there were 2 issues
  1. The code is actually commented out in ae_mix_smartbones. Not really a problem, because it is an example, but it's not an active example.
  2. The code is sending 2 arguments, not one.
That was confusing to me. So I thought that the documentation was wrong. However, there are actually 2 methods named DeleteKeysAtFrame.
The code is actually using the one defined on MohoLayer, not MohoDoc
http://mohoscripting.com/methods/545
I didn't notice that at first. I just wanted to suggest that the documentation for each just say, "see also". I would have been willing to
contribute a change, under change management, but I don't know if that's how the team wants to do things.

Also, I have some scripts that I think people might find useful, like renaming styles and reassigning styles etc.

I really love the documentation and scripts. I don't want to change anything, just saying I'm willing to help a little if needed/desired.

Also, I clicked on the questions link in the doc site. It took me to the Animators Forum :) However, it looks like people aren't contributing to that
any more. Looks like August of 2020 is about the last post. I used to be registered there, but my login didn't work (maybe I've forgotten it :0)

When I do a search I only see on entry at a time (ie not the thread) and I see the following error message.


Microsoft JET Database Engine error '80004005'

Operation must use an updateable query.

/forum/animators/topic.asp, line 483
User avatar
hayasidist
Posts: 3528
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: How do we help with scripting docs and examples?

Post by hayasidist »

AF is in a state of disrepair. Mike Kelley looks after it, but he has moved on from 2d animation, so fixing the problem isn't high on his list...

Stan (http://www.lostmarble.com/forum/memberl ... le&u=13032) is custodian of mohoscripting.. maybe drop him a note about contributing...
User avatar
strider2000
Posts: 506
Joined: Sat Mar 07, 2015 5:14 pm
Contact:

Re: How do we help with scripting docs and examples?

Post by strider2000 »

Thanks hayasidist.
User avatar
synthsin75
Posts: 9981
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: How do we help with scripting docs and examples?

Post by synthsin75 »

Yeah, I think the script cross-reference is automatic by method, instead of also looking at class. Since scripts can assign a class to any variable, any automated cross-reference would also have to resolve those. Probably doable, but Stan has already done such wonderful work that I don't want to nitpick.

And I took the AF out of my signature, since it's been unusable for quite some time.
User avatar
Greenlaw
Posts: 9270
Joined: Mon Jun 19, 2006 5:45 pm
Location: Los Angeles
Contact:

Re: How do we help with scripting docs and examples?

Post by Greenlaw »

So, is mohoscripting.com the most complete reference guide currently available? Just wondering since it's labeled 'unofficial'.

Now that it appears Moho will continue to exist and thrive, I'm making a new effort to learn Moho LUA. Right now, I'm just tinkering with existing scripts, trying to understand how they work, but that's only going to take me so far. Are there any formal Moho scripting lessons? If not, I would like to see that.
Stan
Posts: 199
Joined: Sun Apr 19, 2009 3:22 pm

Re: How do we help with scripting docs and examples?

Post by Stan »

strider2000 wrote: Sat Jan 16, 2021 5:07 pm So I thought that the documentation was wrong. However, there are actually 2 methods named DeleteKeysAtFrame.
The code is actually using the one defined on MohoLayer, not MohoDoc
The search is simple text-to-text matching, nothing fancy. There's no way the search can identify if the matching method belongs to a particular class or if it is encountered in a comment. In some cases it may do a good job, in others it may be useless. To avoid the confusion, I just changed the text on the page from "Scripts that use ..." to "String ... is found in the following scripts". Unfortunately, there's nothing else that can be done with that.
I just wanted to suggest that the documentation for each just say, "see also".
I added that. Thank you!

How do we contribute to the Scripting doc
I think it makes sense to provide Administrator access only to someone who is well-known for their scripts. And I don't remember seeing you sharing any of your scripts with the community. I don't want to sound pompous, but if you show your level of knowledge then the existing administrators can vote for granting you the access. It won't give you anything though, neither money, nor fame. Keep that in mind. :)

I have some scripts that I think people might find useful, like renaming styles and reassigning styles etc.
Mohoscripts.com is already functional, but it's still WIP. If you'd like to post your scripts there (and also to help me testing the functionality), I can give you posting rights.

Also, I clicked on the questions link in the doc site. It took me to the Animators Forum :) However, it looks like people aren't contributing to that
any more. Looks like August of 2020 is about the last post. I used to be registered there, but my login didn't work (maybe I've forgotten it :0)
Yeah, the forum is being in that state of disrepair for a pretty long time now. I just removed the link. I'll put it back if Mike K will be able to fix the forum.
Last edited by Stan on Sun Jan 17, 2021 2:52 am, edited 1 time in total.
________________________________________________________________________
https://mohoscripting.com/ - Unofficial Moho Lua scripting documentation
https://mohoscripts.com/ - The best place to publish and download scripts for Moho
User avatar
synthsin75
Posts: 9981
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: How do we help with scripting docs and examples?

Post by synthsin75 »

Greenlaw wrote: Sat Jan 16, 2021 7:50 pm So, is mohoscripting.com the most complete reference guide currently available? Just wondering since it's labeled 'unofficial'.
Yeah, that's the best scripting reference, hands down. It's just not officially funded/endorsed.
Now that it appears Moho will continue to exist and thrive, I'm making a new effort to learn Moho LUA. Right now, I'm just tinkering with existing scripts, trying to understand how they work, but that's only going to take me so far. Are there any formal Moho scripting lessons? If not, I would like to see that.
Ah, if time only grew on trees.
User avatar
hayasidist
Posts: 3528
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: How do we help with scripting docs and examples?

Post by hayasidist »

Greenlaw wrote: Sat Jan 16, 2021 7:50 pm Now that it appears Moho will continue to exist and thrive, I'm making a new effort to learn Moho LUA. Right now, I'm just tinkering with existing scripts, trying to understand how they work, but that's only going to take me so far. Are there any formal Moho scripting lessons? If not, I would like to see that.
if you're already familiar with block-structured languages then you shouldn't have any real problems with LUA.

(just an aside here .. IIRC Moho uses LUA 5.2 -- the current version is 5.4 -- make sure you use the right LUA language reference docs: http://www.lua.org/manual/5.2/ things can change between versions that break scripts designed for older LUA versions -- e.g. the LUA 5.1 to 5.2 change ((was that around AS10???)) is a good case in point)

That's the easy bit ...

Now on to the "dark arts" of getting Moho and your scripts talking to each other...

Here's my own view on how I'd do that -- plenty of other ways - up to you to choose the one that make you feel comfortable..

A good place to start is to take a quick look (don't try to learn them!!) at the "core" classes in Moho : AnimChannel, M_Bone, M_Curve, M_Mesh, M_Point, M_Shape, M_Skeleton, MohoDoc, MohoLayer, ScriptInterface and get a feel for what's in them and how they fit together.

The scripting documentation has a "script structure" page that sets out the fundamental elements for menu, tool and layer scripts. There's a great template generator (courtesy of Stan) accessible from the "tools" button.

If you fancy trying something before starting on a "serious" script, you might like to set yourself a simple challenge - e.g. draw a circle - centre is mouse click, radius is where the "drag" ends. (you could use the LM_Shape tool as a crib sheet for that if you get stuck) Then build on that to get the circle to glide across the screen ... etc

and, ofc, the scripters on this forum are usually only too happy to answer questions ...
User avatar
SimplSam
Posts: 1048
Joined: Thu Mar 13, 2014 5:09 pm
Location: London, UK
Contact:

Re: How do we help with scripting docs and examples?

Post by SimplSam »

For a scripting newbies - I would suggest to start really really simply - by reviewing/copying & modifying the Menu scripts - they are typically simpler to understand. Then progress to some simple dialog based scripts. Then .. The World!

And @stan - I was thinking that it might be an idea to have some type of feedback form/section on the mohoscripting site, which may alleviate the need for additional admin access. So... maybe if you are logged in as non-admin - you would be allowed to post feedback to the admins (not visible on the site).
Moho 14.1 » Win 11 Pro 64GB » NVIDIA GTX 1080ti 11GB
Moho 14.1 » Mac mini 2012 8GB » macOS 10.15 Catalina
Tube: SimplSam


Sam
Stan
Posts: 199
Joined: Sun Apr 19, 2009 3:22 pm

Re: How do we help with scripting docs and examples?

Post by Stan »

SimplSam wrote: Sun Jan 17, 2021 12:49 am And @stan - I was thinking that it might be an idea to have some type of feedback form/section on the mohoscripting site, which may alleviate the need for additional admin access. So... maybe if you are logged in as non-admin - you would be allowed to post feedback to the admins (not visible on the site).
Good idea, Sam. I'll try to come up with something like that as soon as I can. Thank you!
________________________________________________________________________
https://mohoscripting.com/ - Unofficial Moho Lua scripting documentation
https://mohoscripts.com/ - The best place to publish and download scripts for Moho
User avatar
Greenlaw
Posts: 9270
Joined: Mon Jun 19, 2006 5:45 pm
Location: Los Angeles
Contact:

Re: How do we help with scripting docs and examples?

Post by Greenlaw »

Thanks for the tips guys! This is all very helpful.
hayasidist wrote: Sat Jan 16, 2021 11:35 pm if you're already familiar with block-structured languages then you shouldn't have any real problems with LUA.
At work I've done some scripting for After Effects using ActionScript (an extension of JavaScript,) and dabbled a little with Python and AutoHotkey, but I still consider myself just a hair above 'newbie'. I tried to learn Moho scripting before, and I recognize some structural similarities.

Actually, the hard part has been making the time to learn and sticking to it. To repeat Wes, "If time only grew on trees."

But right now I'm so jazzed about Moho's return, my New Years resolution is to make a stronger effort to learn Moho scripting. My problem before was that the project I attempted, which I thought was going be easy, was actually way too ambitious for my skill level, and I got discouraged. I'll keep it even simpler this time. :)
User avatar
strider2000
Posts: 506
Joined: Sat Mar 07, 2015 5:14 pm
Contact:

Re: How do we help with scripting docs and examples?

Post by strider2000 »

Stan wrote: Sat Jan 16, 2021 8:22 pm I think it makes sense to provide Administrator access only to someone who is well-known for their scripts. And I don't remember seeing you sharing any of your scripts with the community. I don't want to sound pompous, but if you show your level of knowledge then the existing administrators can vote for granting you the access. It won't give you anything though, neither money, nor fame. Keep that in mind. :)
Understood. I'm a computer programmer and just do Moho for fun. Making things available to the community is actually the harder part for me, since there's no gerrit or github type of access, as far as I know of.

I've actually posted stuff way back 2015, like the Frame by Frame reordering script
http://www.lostmarble.com/forum/viewtop ... 52#p157352

I put that up on github, but, at least at the time, there didn't seem to be much of a community there, so I haven't really kept that up to date.

My lipsync script is probably the biggest one I've made available, but again since there wasn't really a way I understood about making it available, I put it up on the now defunct sellfy.
http://www.lostmarble.com/forum/viewtop ... 12&t=28346

I think that one might be helpful.

In my scripts, it's true that I've mainly focused on things I need/want, so most of them aren't localized and I do have utility files that I use. For example, here are some simple processing functions I'm using. That allows me to use the same overall processing for any number of operations (freeze, delete move etc).

Code: Select all

function msProcessing:ForEachBoneOnCurrentLayer(moho, callback)
  if(moho ~= nil) then
    local skeleton = msProcessing:GetSkeleton(moho)
    self:ForEachBone(skeleton, callback)
  end
end

function msProcessing:ForEachBone(skeleton, callback)
  if(skeleton == nil) then
    return
  end

  for i = 0, skeleton:CountBones()-1 do
    local bone = skeleton:Bone(i)
    callback(bone)
  end
end

function msProcessing:GetSkeleton(moho)
  if (moho == nil) then
    print("Moho is undefined on call to GetSkeleton")
    return nil
  end

  if (moho.layer:LayerType() ~= MOHO.LT_BONE) then
    print("Layer must be a bone layer to clear the keys")
    return nil
  end

  local skeleton = moho:Skeleton()
  if(skeleton == nil) then
    print("A bone skeleton was not found on the selected layer")
  end
  return skeleton
end


In any case, I'm just saying I'm willing to help and provide things I have, but I don't really know the best way to do it. Having an easy way to share things has been the biggest barrier, for me, in terms of sharing things with the community. I don't have tons of time, and I'm not trying to lead anything. I'm just hoping to see ways that the community can help with the new efforts to support Moho. But even if I don't contribute, I've found mohoscripting helpful. Great job! Even if there was just a way to submit feedback if we don't understand something, that might be an easy way the community can help.
User avatar
hayasidist
Posts: 3528
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: How do we help with scripting docs and examples?

Post by hayasidist »

Greenlaw wrote: Sun Jan 17, 2021 2:52 am At work I've done some scripting for After Effects using ActionScript (an extension of JavaScript,) and dabbled a little with Python and AutoHotkey, but I still consider myself just a hair above 'newbie'. I tried to learn Moho scripting before, and I recognize some structural similarities.
try this to take a walk through the basics of LUA: https://www.lua.org/pil/contents.html

that talks briefly about Global variables.
Rule 1 in the Moho context; if you MUST use a global, then prefix it with some unique to you identifier ... see http://mohoscripting.com/script_structure for some ideas - e.g. Moho uses LM_; I use HS_ ; Wes uses syn_ ... there's no formal policing of this although if the scripting community expands and expands I guess there will need to be a "naming authority". But better not to (i.e. expressly use local variables) except where necessary -- such as all your script functions that Moho expects to find (e.g. function HS_Myscript:Name() ).


When you get to "userdata" (scantily described in the text) that's what most of the Moho data objects will be: e.g. as in http://mohoscripting.com/introduction the code local vec = LM.Vector2:new_local() - this creates "vec" as a LUA userdata type. You can then use the "methods" and access the "attributes" of that userdata as described in its "Class" e.g. http://mohoscripting.com/classes/LM_Vector2

most Moho data objects don't need to be explicitly created -- calling something that "returns" a class gives you the userdata object: (e.g.) an M_Point class is returned by M_Mesh:Point(n) so:

Code: Select all

local x = 5 -- https://www.lua.org/pil/4.1.html
local vec = LM.Vector2:new_local() -- http://mohoscripting.com/classes/LM_Vector2
local mesh = moho:Mesh() -- http://mohoscripting.com/methods/78
local pt = mesh:Point(x)    -- http://mohoscripting.com/methods/836
vec:Set(pt.fPos) -- http://mohoscripting.com/methods/155 (http://mohoscripting.com/classes/M_Point)
sets vec to be the position of point "5"

hope that starts you on your journey with a strong first step ... ask as often as you like on the way (PM if you prefer...)
Daxel
Posts: 996
Joined: Wed Mar 27, 2019 8:34 pm

Re: How do we help with scripting docs and examples?

Post by Daxel »

An honest question for the programmers here:

You guys are very talented and generous sharing those scripts for free. And I see that sometimes you help other scripters, sometimes one of you don't have time to fix or update something, some scripts are in one website and others in a different one, and like Stan said, is understandable that you guys don't trust everyone to upload or edit your scripts. I see a lot of limitations in the way the scripts are shared.

So why not GitHub? An official open source Moho Community Scripts repository, controled by those of you that we all know and trust as talented Moho scripters, but where everyone can find the latest updated scripts, everyone can report bugs in a way that is easier for the maintainers to read, everyone can contribute to each other making pull requests to share their own scripts, to fix other scripts or to add functionality to other scripts, and you can freely choose to merge those pull requests or not. Everyone would benefit. Wouldn't that be awesome?
User avatar
strider2000
Posts: 506
Joined: Sat Mar 07, 2015 5:14 pm
Contact:

Re: How do we help with scripting docs and examples?

Post by strider2000 »

Yes, I'd be a definite fan of github. I don't know if you know about gerrit, but that allows code review and would be a great way for to control quality as well as allowing newer, less experienced developers to contribute and get feedback.

I guess the new directions for Moho has everyone dreaming of what the future could look like. At least it does for me. To me one of the most interesting questions is how to allow the community to contribute, while maintaining quality. And how do you account for style? I think that question could be asked for
  • assets - including scripts
  • documentation
  • tutorials
  • animation example
In my mind I can imagine several things that might make it work
  • officially approved tag - some way to filter everything to see only officially approved stuff
  • rating system - the community can rate the value of each thing, making it easy to find the best of stuff, without discouraging new, less experience contributions.
  • github/gerrit type of system - definitely for code, maybe also for doc and assets. There could be a branch for the official stuff and a branch for unofficial, no real policing.
Just my thoughts. What do others think?
Post Reply