MSG_BASE?

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:

MSG_BASE?

Post by Peteroid »

The document says this about MSG_BASE:
The following constants are used when setting up messages for user interface elements. Any messages you use in your custom controls should be greater than or equal to the MSG_BASE constant so as not to interfere with other GUI elements in Moho. For example you could use the following messages in a dialog you create: MSG_BASE, MSG_BASE + 1, MSG_BASE + 2, etc.


MSG_BASE - The starting message code for use by Moho scripts
Great. I see, as an example, the following from Zoom Camera Script that:

LM_ZoomCamera.BASE_STR = 2380


Well, gee, the number 2380 is so obvious from the above description! (sarcasm off)

It seems to imply setting this up as a constant is a bad thing to do. Yet, that's the only way I've ever seen it used. Nobody uses the MSG_BASE = MSG_BASE + offset form. They establish a CONSTANT.

And look! Translate Layer does not use MSG_BASE at all! So its not very clear why its needed, or what it's for...

You know, studying other people's scripts really is a TERRIBLE way to HAVE TO get familiar with this stuff. This is not a language conducive to that kind of study, since variables are not declared and so their use and type are never clear. And apparently everyone has formed a pact, vowing to never comment anything! LOL

And this is a very poor way to FORCE everyone to learn. Imagine learning cooking by just being given a cookbook, and no description of the ingredients. Anything not in the recipes will NEVER be learned, and you are reduced to using only those components that previous people used, and only know how to use them EXACTLY as the previous people used them.

And in this case, the 'cookbook' has to be found page by page in many places, many leads ending in dead links, no way of knowing if a particular script is going to help your situation without studying it COMPLETELY, and no guarantee ANYONE has a script that illustrated what you need. This is really BAD if you want to try to do stuff nobody else has before.

The lack of a COMPLETE formal document.... is EXTREMELY frustrating! That and nobody responding here except to always say:

- study other scripts
- look at the sticky topics

ARGHHHHHHHHHHHHHHH! I AM, I HAVE, and I WILL.

I'm trying to create a tool I think a lot of people will enjoy. PLEASE help me make that possible!

NOTE: I have written this same plea a number of times recently in various posts.

PLEASE DO NOT POINT ME TO THE STICKY TOPICS FOR INFORMATION, THAT IS WHAT I HAVE BEEN STUDYING, AND THOSE STICKY DOCUMENTS DO NOT ANSWER THE QUESTIONS I NEED ANSWERING.

But I appreciate your sentiment anyway! :)
[==Peter==]
ponysmasher
Posts: 370
Joined: Thu Aug 05, 2004 2:23 am
Location: Los Angeles
Contact:

Post by ponysmasher »

As someone who learned to script not too long ago I know it can be very frustrating to get stuck but looking at other scripts and testing to make changes in them really is the best way to learn.

As far as message base it's for messages sent by buttons and stuff.
And the whole +1, +2 thing is so that each button can send a unique message.

So the first button might be DS_InstantLimbTool.NameOfFirstButton= MOHO.MSG_BASE
The second DS_InstantLimbTool.NameOfSecondButton= MOHO.MSG_BASE+1
The third DS_InstantLimbTool.NameOfFirstButton= MOHO.MSG_BASE+2

And so on...

Not a very in depth explanation but it's something I guess.
ponysmasher
Posts: 370
Joined: Thu Aug 05, 2004 2:23 am
Location: Los Angeles
Contact:

Post by ponysmasher »

Oh, and I'm still not sure what the whole BASE_STR = 2380 is, but it's not the same thing as message base.

All Lost Marble tools have a BASE_STR number but it's not something you need in your script.
User avatar
Peteroid
Posts: 162
Joined: Thu Aug 12, 2010 3:57 am
Location: las vegas, NV
Contact:

Post by Peteroid »

ponysmasher wrote:Oh, and I'm still not sure what the whole BASE_STR = 2380 is, but it's not the same thing as message base.

All Lost Marble tools have a BASE_STR number but it's not something you need in your script.
Thanks!

Yeah, I'm slowly getting it. It is basically copy code from other scripts, modify it, see how it changes things, rinse lather, repeat. Backwards engineering. So, what would have taken me half a day with proper documentation, is taking me more than a week. Oh joy. At least once I've learned it it will be learned! :)

I have figured out how to build the interface in the toolbar, how to change the icon, create the description, establish the tool-tip rollover text, how to install the script, and I've seen it react to a key press.

I now need to figure out how to create a new keyframe at a given position and change the tilt and pan angles of the camera (CHANNEL_CAMERA_PANTILT), read the position of a Layer at a particular frame (even if in the middle of two keyframes and is tweening), and the same thing for the camera position. I also need to figure out how to read those parameter tables in the toolbar, but I think that shouldn't be too hard if I just look for appropriate functions in sample scripts that establish fields.

This does all suggest to me that I'm correct... there is some Script class that isn't mentioned since it seems the Script IS the instance of the class.

So I still would like to know where the description is of the Script class. It is obvious that it is impossible to do a Script without this knowledge, how hard would it be for SM or LM to write up this class and put it in the forum?

I refer to the class that, for example, has the member ScriptName...

And yeah, you can see how this has gotten me all flustered... I read MSG_BASE and saw BASE_STR and read them as the same thing... I guess I was desperate to find ANYTHING that looked remotely like it! LOL
[==Peter==]
ponysmasher
Posts: 370
Joined: Thu Aug 05, 2004 2:23 am
Location: Los Angeles
Contact:

Post by ponysmasher »

Peteroid wrote:It is obvious that it is impossible to do a Script without this knowledge, how hard would it be for SM or LM to write up this class and put it in the forum?

I refer to the class that, for example, has the member ScriptName...
Well, I've managed to create a few scripts and I have no idea what you're even talking about so I wouldn't say it's impossible... :)
ponysmasher
Posts: 370
Joined: Thu Aug 05, 2004 2:23 am
Location: Los Angeles
Contact:

Post by ponysmasher »

And here are two examples before bedtime that may or may not help:

This is for bones but you can see the basic structure

To get the scale value of say frame 16 and put it in the variable newScale:

Code: Select all

newScale=bone.fAnimScale:GetValue(newFrame)
This gets the value from the frame 16, doesn't matter if frame 16 has a keyframe or not.

To set the scale value to 15 at frame 66

Code: Select all

bone.fAnimScale:SetValue(66, 15)
Good night!
User avatar
Peteroid
Posts: 162
Joined: Thu Aug 12, 2010 3:57 am
Location: las vegas, NV
Contact:

Post by Peteroid »

ponysmasher wrote:
Peteroid wrote:It is obvious that it is impossible to do a Script without this knowledge, how hard would it be for SM or LM to write up this class and put it in the forum?

I refer to the class that, for example, has the member ScriptName...
Well, I've managed to create a few scripts and I have no idea what you're even talking about so I wouldn't say it's impossible... :)
OK.. touche... impossible is a bit too strong of a word... ;)

But is it so unreasonable for me to want to UNDERSTAND what and why I'm doing what I do in code, in contrast to just mimicking and hoping it works? :)

Would I be off base to assume you use 'ScriptName' only because others use it, not because you have any idea where it comes from?

I'm both a technical person and a creative person. Animation is therefore perfect for me! But my technical side seems to keep being told by others it is 'wrong' to want to be precise (I can show you a post in these forums that said almost exactly that, in fact, the guy told me being precise was akin to being anal retentive... I'm not kidding).

So I want to do it the best I can. I just invested $2000 in this hobby (I also bought a faster computer, a big monitor, other software like video and audio editing tools, other drawing programs, and a nice microphone that I've built a cage for isolating sounds to do voice recordings).

Don't you think I deserve to have the ability to use the tools I purchased to their best ability? And Anime Studio is the cornerstone I bought all this stuff to support...

If you bought, say, a cell phone that had a cool feature you wanted to use, but there were no instructions on how to access the feature, and the company that made the cell phone policy was they wouldn't provide the instructions, but to 'just ask our other customers how they access it', wouldn't that annoy you? :)
[==Peter==]
User avatar
Peteroid
Posts: 162
Joined: Thu Aug 12, 2010 3:57 am
Location: las vegas, NV
Contact:

Post by Peteroid »

ponysmasher wrote:And here are two examples before bedtime that may or may not help:

This is for bones but you can see the basic structure

To get the scale value of say frame 16 and put it in the variable newScale:

Code: Select all

newScale=bone.fAnimScale:GetValue(newFrame)
This gets the value from the frame 16, doesn't matter if frame 16 has a keyframe or not.

To set the scale value to 15 at frame 66

Code: Select all

bone.fAnimScale:SetValue(66, 15)
Good night!
That helps BIG TIME! Thank you! :))))
[==Peter==]
ponysmasher
Posts: 370
Joined: Thu Aug 05, 2004 2:23 am
Location: Los Angeles
Contact:

Post by ponysmasher »

Yep, there's some stuff I do/use without exactly knowing why.
But I think I know what script name does.
Every function and recurring value starts with the script name so you have to declare that. And two scripts cannot have the exact same name because one script can access functions/values in other scripts.

I have a tool for animating bones that combines several bone tools, but instead of copying/pasting the code from the other scripts I just call their functions where I need them.

I guess the script name is like a table/array storing all the functions and values.
DELETED

Post by DELETED »

DELETED
Post Reply