'moho' object

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
Peteroid
Posts: 162
Joined: Thu Aug 12, 2010 3:57 am
Location: las vegas, NV
Contact:

'moho' object

Post by Peteroid »

According to the doco:
The ScriptInterface class is a script's way of interacting with the Moho application itself. When a script is invoked (by a mouse click, a key press, or a menu command), it is provided with an object called "moho" - this object is an instance of the ScriptInterface class.
Well, if I put a variable in my LUA Script when ASP7pro loads it immediately says I have errors alog the lines of "I have attempted to access a null variable 'moho = nil'.

So what the heck does the documentation mean then about 'moho'? Before I even get to the tool it gives an error on loading ASP7...
[==Peter==]
User avatar
Peteroid
Posts: 162
Joined: Thu Aug 12, 2010 3:57 am
Location: las vegas, NV
Contact:

Post by Peteroid »

OK... I think I figured it out...

The script is run on entry. BUT... the 'moho' object is nil until the tool is evoked. I'm guessing this is so one can do a initialization upon entry tpo ASP7.

So, if I'm correct, then 'moho' is NOT nil when the tool is evoked. I guess this means 'moho' is like a 'flag' telling you if this is initialization or not (nil if it is)...

But I am still guessing, since apparently everyone who visits the Scripting area of the forum is on vacation today! lol ;)
[==Peter==]
User avatar
funksmaname
Posts: 3174
Joined: Tue May 29, 2007 11:31 am
Location: New Zealand

Post by funksmaname »

will you not make more sense of it if you download some other people's scripts and look at them? just a thought.

moho is what AS used to be called - i think it maybe being used as a prefix to other things? again, look at other people's scripts - i've no idea what i'm talking about but for the lack of anyone else being around i'm the best you got lol.
User avatar
Peteroid
Posts: 162
Joined: Thu Aug 12, 2010 3:57 am
Location: las vegas, NV
Contact:

Post by Peteroid »

funksmaname wrote:will you not make more sense of it if you download some other people's scripts and look at them? just a thought.

moho is what AS used to be called - i think it maybe being used as a prefix to other things? again, look at other people's scripts - i've no idea what i'm talking about but for the lack of anyone else being around i'm the best you got lol.
Well I appreciate that! lol :)

WHICH scripts should I look at? Do all scripts deal with all features? NO.. so if I want to figure out how to use a feature I have to find a LUA script that uses that feature, then hope I can figure out what in the code is using it.

It's like trying to use a dictionary to figure out how to spell a word... you have to know how to spell it to look it up! Only in this case the 'dictionary' is all over the place...
[==Peter==]
User avatar
Peteroid
Posts: 162
Joined: Thu Aug 12, 2010 3:57 am
Location: las vegas, NV
Contact:

Post by Peteroid »

Yeah! I found a link to a LUA script in the Scripts forum that isn't broken (every link has been broken till I finally found one that wasn't)...

Congratulations! You have reached Level 3 of LUA Documentation finding. Do you wish to share this with your friends?

UPDATE: Actually, not so great... All the example LUA scripts I could find were written by the same author, who apparently does not believe in comments.

You see, LUA is easy to write, but much harder to read. That's because its main strength is any variable can hold any value at any time of any type, and so never is declared. But that makes it impossible to know what a variable is suppose to be other than examining the context its in.

So, for example, in a function definition there is absolutely no way to know what the author intended the variables types to be. So, one must look for 'clues'. Hey, this variable has a method by that name, only objects of that type use that function call.

That's a NIGHTMARE. It means all code has to be backward engineered to read it! Of course its a good thing they let you provide comments so you can inform readers what is going on...

And the examples I have... have no comments... :(

So, basically I'm looking for a link to examples of LUA Script that uses MOHO (that isn't broken), and contains scripts that are simple and meant to instruct, such as actually commenting them for those of us who are just learning... ;)
[==Peter==]
User avatar
funksmaname
Posts: 3174
Joined: Tue May 29, 2007 11:31 am
Location: New Zealand

Post by funksmaname »

have you looked at all the core LUA tools that come with the program? they aren't broken - also fazeks tools look to have some commenting...
dunno where you're finding broken scripts :P
User avatar
Peteroid
Posts: 162
Joined: Thu Aug 12, 2010 3:57 am
Location: las vegas, NV
Contact:

Post by Peteroid »

funksmaname wrote:have you looked at all the core LUA tools that come with the program? they aren't broken - also fazeks tools look to have some commenting...
dunno where you're finding broken scripts :P
The idea of looking at the scripts that come with ASP7 is brilliant!

But to answer your question, every place I've looked their are broken links. Now, sure, there may be some that aren't... you have found one... but it gets frustrating when you're trying to learn something and you have to spend 99% of your time searching for an answer instead of spending the time studying it. I would have thought it would be in the best interest of Smith Micro to have tutorials...

And it didn't help that I got no responses today except from you, who was nice enough to keep me company (thanx!), but self-admittedly can't really answer my questions!

Hopefully people will be back tomorrow... but I was hoping to learn this by the end of the weekend... and that's not going to happen...
[==Peter==]
DELETED

Post by DELETED »

DELETED
Post Reply