PlugIn - Merge Channels and Sequencer Tabs?

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

Moderators: Víctor Paredes, Belgarath, slowtiger

Rudiger
Posts: 786
Joined: Sun Dec 18, 2005 2:25 am

Post by Rudiger »

If it was only going to be that simple then it really wouldn't offer much advantage over my existing nudge key tools. Surely you will still want to have the feature where you expand the channels in each layer. Then you've got to have vertical and horizontal scrolling, the timeline marker, key selection and manipulation, etc. If you are still ultra-keen to make it happen, why don't you have a crack yourself. Lua scripting is a lot easier than you think. You can check out some Lua gui examples here... http://wxlua.sourceforge.net/

By the way, if you come up with a working gui in lua, I'd be more than happy to help you integrate it into AnimeStudio.
stefman
Posts: 75
Joined: Mon Jul 20, 2009 6:46 pm

Post by stefman »

Argh, now I've my back to the wall.

Mmhh, I never did any programming in my life. But this tool would really help me. So I'll go and say hello to LUA. :roll:

Thank you for the link Rudiger. And thanks for your proposition.

Surely you will still want to have the feature where you expand the channels in each layer
I think that I really could live without expanded channels. Because my main interest is having a general view on the keys of all the existing layers, allowing easy general timing modifications and creation and control of hold keys.

stefman
User avatar
heyvern
Posts: 7042
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

There is a built in ability with lua to "draw" interface elements on the screen. For example when you use the lasso tool to select points that "line" is in the script interface. When the add point or translate point tool draws those red and green markers they are created using the scripting interface. I did something similar with a bone colorizing tool. I drew bone shapes using the script interface over the bones that colorized them.

It is conceivable that possibly... maybe... a sort of "fake" time line could be displayed in the same way. Key frames of multiple layers could be "drawn" on the screen simulating a view of the time line. Clicking on and dragging "drawn" elements on the screen would change key frames of multiple layers.

My thought is this could be based on the time line view or the key frame you are on. As you "scroll" the time line this scripted view would "update".

This is not a simple thing to do but is possible. Fazek created a "fake" bezier curve "tool" that did something very similar. You could grab points and drag curve handles that behaved exactly like bezier curves. This was only a "fake" display "trick" and couldn't be rendered or used functionally but the idea would work for a fake "time line overlay" tool.

-vern
Rudiger
Posts: 786
Joined: Sun Dec 18, 2005 2:25 am

Post by Rudiger »

Yeah, I had a similar idea as a way to extend my nudge keys tools, which was to basically autodraw the current timeline interface in the consolidated timeline layer. You really wouldn't need to use any of the extended interface elements as you could simply use points for keyframes and text for labels. You could then have a custom tool that only shifts points horizontally and can expand layers and channels. I just thought it would be too clunky for the amount of work involved to be that useful though.
stefman
Posts: 75
Joined: Mon Jul 20, 2009 6:46 pm

Post by stefman »

Ok, one thing is sure. I won't become an instant programmer. I even think that I never will.:?

But, I read some documentation to get more familiar to LUA.
And if I understood well, it is a programming language which allows C or C++ applications to cummunicate with each other. Is that right?

If this was right one could theoretically have an external timeline which is written in C or C++ and make it communicate with AS, isn't it?

I ask this question because I think that there are propably more people who know C or C++ than people who know LUA.

Again, I'm not a programmer. I'm just trying to check out all the possibilities.

stefman
User avatar
heyvern
Posts: 7042
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

No, the C++ "connection" is "built in" to the application that supports Lua. The C++ connectivity is used to link lua to your application when it's compiled. Since they are two different languages "inside" the same program they need to have a way to send and receive application data.

-vern
Rudiger
Posts: 786
Joined: Sun Dec 18, 2005 2:25 am

Post by Rudiger »

Actually, in a way Stefman is right. You would be using lua to communicate between AnimeStudio and wxWidgets, which are both presumably written in C++. Luckily, wxWidgets is a standard gui library so you don't have to write it or even compile it yourself.

What you really need to understand about lua is that it is an interpreted language. This means that the lua code, often called a script, is executed on the fly by a lua interpreter. In our case, the lua interpreter is embedded in AnimeStudio, but you can download a standalone interpreter off the web. What makes interpreted languages so cool is that they can be quite high-level, which can let mere mortals like you and I make believe we are programming gods for a little while.

I've been doing a little more digging around myself, and I came across something called wxGlade (http://wxglade.sourceforge.net), which you might be interested in, as it lets you build up your gui graphically. You can then export your gui as xml code which wxLua can use to generate the gui when you run it.
stefman
Posts: 75
Joined: Mon Jul 20, 2009 6:46 pm

Post by stefman »

Rudiger,
Yeah, I had a similar idea as a way to extend my nudge keys tools, which was to basically autodraw the current timeline interface in the consolidated timeline layer. You really wouldn't need to use any of the extended interface elements as you could simply use points for keyframes and text for labels. You could then have a custom tool that only shifts points horizontally and can expand layers and channels. I just thought it would be too clunky for the amount of work involved to be that useful though.
Did you really create this to give it a try?

If yes, I would like to try it even if you find it too clunky.
(Actually, I can not really imagine what this thing could look like?)
stefman
Posts: 75
Joined: Mon Jul 20, 2009 6:46 pm

Post by stefman »

Hello, everybody.

I have a question to improve my comprehension of lua scripting.

Commands like:

LM.GUI.ALIGN_TOP
LM.GUI.CheckBox
LM.GUI.TextList
LM.GUI....., and so on.

Are these things, something that could be called Anime Studio widgets?

And secondly, does someone know if there is a list of all the existing commands of that kind?

Many thanks in advance,

stefman
stefman
Posts: 75
Joined: Mon Jul 20, 2009 6:46 pm

Post by stefman »

I FOUUUUND IT!!!!

viewtopic.php?t=1031

And, it contains instructions about creating GUI with lua in Anime Studio.
User avatar
heyvern
Posts: 7042
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

Here's a tip for creating pop up windows and organizing all the elements using "push" and "pop:.

If you can find any of the "Macton" or "Crashcore" scripts that use pop ups look at how they create the "layeout". It's in the beginning of the code. You may need to have some more lua experience to understand it but it truly is an easier way to organize the layout.

What they do is create a "function" that "builds" the layout. So instead of a huge long chunk of code you call a function that is easier to see and read. The formatting of the "push/pop" layout is the same each time you call that function. It makes designing pop up lay outs easier.

Here's is a snippet showing the function from one of those scripts:

Code: Select all

function CC_PASTE_CURVE_TO_CAMERA_TRACK_Dialog:add_col_e4( l, el_0, el_1, el_2, el_3 )
    l:PushV()
            l:AddChild( el_0, LM.GUI.ALIGN_LEFT )
            l:AddChild( el_1, LM.GUI.ALIGN_LEFT )
            l:AddChild( el_2, LM.GUI.ALIGN_LEFT )
            l:AddChild( el_3, LM.GUI.ALIGN_LEFT )
    l:Pop()
end
If all the code to create those elements were INSIDE the "push/pop" it would be much longer and harder to read. Using a function with arguments and variables and sending the element data to the function keeps the code more compact and easy to read.

-vern
stefman
Posts: 75
Joined: Mon Jul 20, 2009 6:46 pm

Post by stefman »

Thank you very much, Vern.

Hehe, it's like you say. I think I would need even a lot of more lua experience.

That is why, I will ask some more general questions.

Actually, I managed to create a window in AS. But, as I am really a beginner and I had to watch how it works I "amputated" one of your scripts (the hv_copybones.lua script. Sorry :oops:)

And, with the Lost Marble tutorial I will be able to integrate standard widges know.

But, what I'm wondering about is, if:

1: with these LM.GUI.XXX limatation I would be able to integrate grafic elements like circles or squares to my window. I have the same question for bitmaps, pngs, ...

2: it is possible to move thes elements inside of this window. (very important question as I want to recreate a timeline window where I want to move keys)

stefman
Rudiger
Posts: 786
Joined: Sun Dec 18, 2005 2:25 am

Post by Rudiger »

stefman wrote:Thank you very much, Vern.

Hehe, it's like you say. I think I would need even a lot of more lua experience.

That is why, I will ask some more general questions.

Actually, I managed to create a window in AS. But, as I am really a beginner and I had to watch how it works I "amputated" one of your scripts (the hv_copybones.lua script. Sorry :oops:)

And, with the Lost Marble tutorial I will be able to integrate standard widges know.

But, what I'm wondering about is, if:

1: with these LM.GUI.XXX limatation I would be able to integrate grafic elements like circles or squares to my window. I have the same question for bitmaps, pngs, ...

2: it is possible to move thes elements inside of this window. (very important question as I want to recreate a timeline window where I want to move keys)

stefman
I think it's great that your giving Lua scripting a crack, Stefman. It'll change your life, I promise. The widgets available in LM.Gui are very limited and, as far as I know, there aren't any graphical ones at all. This is why I suggested using an external widgets library like wxLua. I don't know if anyone has successfully done this in AnimeStudio before, but as long as ASP's Lua interpreter accepts the require command, I can't see why it wouldn't work.
If not, you could always generate your timeline in ASCII. :wink:
stefman
Posts: 75
Joined: Mon Jul 20, 2009 6:46 pm

Post by stefman »

Hehe,

hi, Rudiger.

At the moment lua is occupying my life. :cry:
But, I'm trying hard to find something.

The problem with wxLua is that I don't manage to integrate to AS any grafic external element from wxLua or somewhere else.
(And it's the same problem in the other direction.
Wxlua doesn't compile any AS gui lua script.)

I saw that Fazek integrated a png for the button in his fa_switch_xsh.lua script without channging anything in the _tool_list.txt.

(Vern, could this be a question for you?)

He used commands like this:
function FA_Commander:LoadPrefs(prefs)
self.insertMode= prefs:GetBool("FA_Commander.insertMode", false)
self.stepFrame= prefs:GetInt("FA_Commander.stepFrame", 2)
self.imageFileName= prefs:GetString("FA_Commander.imageFileName", "")
self.imageDirName= prefs:GetString("FA_Commander.imageDirName", "")

self.listFileName= prefs:GetString("FA_Commander.listFileName", "")
self.listLoadImages= prefs:GetBool("FA_Commander.listLoadImages", false)
self.listAddExtension= prefs:GetBool("FA_Commander.listAddExtension", false)
self.listExtension= prefs:GetString("FA_Commander.listExtension", ".png")
self.xshColumns= prefs:GetInt("FA_Commander.xshColumns", 3)
self.importInsert= prefs:GetBool("FA_Commander.importInsert", true)
self.importKeepExtension= prefs:GetBool("FA_Commander.importKeepExtension", true)
self.importMissing= prefs:GetInt("FA_Commander.importMissing", 2)
But at the moment I'm unable to isolate the function and to integrate it to my nearly empty pop up window.

But could this be the right direction to digg?
If not, you could always generate your timeline in ASCII. Wink
Yes, I'm seriously thinking about that. That the keys could be represented by an "*" and the grid or at least the line will be drawn by a divider. This was on my program for today. :)

But, I still need to know if then, technically, it would be possible to click on the "*" and to change their x position. (to move the key from frame 0 to frame 5, e.g.). And, of course, if a real key could really be linked to it and follow it.


stefman
stefman
Posts: 75
Joined: Mon Jul 20, 2009 6:46 pm

Post by stefman »

By the way,

I found an interesting web site where someone programed a pacman game entirely in LUA.

stefman
Post Reply