Help please: moho a nil value?

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

Moderators: Víctor Paredes, Belgarath, slowtiger

Post Reply
Breinmeester
Posts: 303
Joined: Thu May 13, 2010 2:01 pm

Help please: moho a nil value?

Post by Breinmeester »

I get the error message:

Code: Select all

attempt to index local 'moho' (a nil value)
when i try to call moho.layer in HandleMessage(msg) or other sub functions. Since this is pretty fundamental stuff I'm guessing I'm doing something fundamentally wrong. Can someone please explain?
User avatar
hayasidist
Posts: 3514
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: Help please: moho a nil value?

Post by hayasidist »

If you're not in the main dialogue message handler (which is what it looks like) then you'll NOT have access to "core" data such as moho and view...

see http://www.kelleytown.com/forum/animato ... IC_ID=1375 for more about access to "moho" and "view" in pop-up menu routines (but you'll need a few more posts in the other place before you can get at the VIP section)



if you are in the main handler then the function needs to be:
function xxxx:HandleMessage(moho, view, msg) not HandleMessage(msg)
Breinmeester
Posts: 303
Joined: Thu May 13, 2010 2:01 pm

Re: Help please: moho a nil value?

Post by Breinmeester »

Hey thanks for that!

Could you please copy and paste or describe what's written on the other forum on this subject matter? I could realy use the info.

I wasn't an active member here when that forum was created, so maybe there's a reason for all the secrecy, but i just don't get why a moho community has to be so closed off. I'm very willing to particpate over there and share my scripts, but how can i participate if i dont have access? Do i really have to write 50 posts about random stuff first to prove myself??? :roll:
User avatar
hayasidist
Posts: 3514
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: Help please: moho a nil value?

Post by hayasidist »

I can't really comment on the AF "50 post" policy other than to say that it's a manual not automatic decision... take a look at some of the discussion on that subject over there.

Since the "can't get at moho" post was mine, I don't have a problem giving you the gist of the answer - which was (as you've seen) "you can't - and there's no real DIRECT work-around..."

And, since you've posted the same q over there, I'll give you the "how I work round this" over there too... :D
Breinmeester
Posts: 303
Joined: Thu May 13, 2010 2:01 pm

Re: Help please: moho a nil value?

Post by Breinmeester »

I've tried this:

Code: Select all

dv_MainScriptPopUp:HandleMessage(msg)
if (msg == self.CLICKBUTTON) then
  dv_OtherScript:Run(moho)
end
But if dv_OtherScript tries to access moho it returns the same error:

Code: Select all

attempt to index local 'moho' (a nil value)
Even though it works fine when you run it from the scripts menu.

This basicly means a modeless window is utterly useless. Someone at LostMarble/SmithMicro, please make it so moho is passed in a modeless dialog window.
Post Reply