...Some Advices to begin Learn LUA?

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
Rai López
Posts: 2297
Joined: Sun Aug 08, 2004 5:41 am
Location: Spain
Contact:

...Some Advices to begin Learn LUA?

Post by Rai López »

HELLO! :D I've try to learn something about LUA in several occasions (you know...) but now I really think that I must do it... Well I have visited the pages and download guides, tutorials and applicatinos, but guy... there are a lot of info and resources there and I'm now TOTALY lost... I've NO idea of programing (NOTHING) and I don't know if learn is possible for me, but for now I'd only want to know enought to can write "simple" Moho scripts (like some for I've asked in the past: http://www.lostmarble.com/forum/viewtopic.php?t=2233 (the most importan for me actually) or this other http://www.lostmarble.com/forum/viewtopic.php?t=2384 (for mention someones) ...And, of course, (don't laught :lol: ) I'd want to achieve this goal as quickly as possible... Cause of this, maybe, if you know what I mean, I'd be very GRATEFULL if you coul give me some usefull advices, things like how you started to learn, essential tools or what is not necessary to learn in my case or, well... something to know how start "correctly" with all this "madness" at least... Well, any help would be WELCOMED :) THANK YOU very much for all! ...CIAO!
User avatar
rylleman
Posts: 750
Joined: Tue Feb 15, 2005 8:22 am
Location: sweden
Contact:

Post by rylleman »

I've just started scriptwriting myself, and I can't do very complicated scripts, but I think I can offer some advise anyway.

Study scripts that might have anything to do with what you are trying to do, Try to find pieces that you think can be useful and analyse those to see what they really are doing, copy functions that you need from other scripts etc. Learn scripting as you go along, you'll learn more for every new script you're making.
Use the print command a lot when you're writing, it help a lot in finding faulty code if you put print commands inside funtions and different arguments to see whats actually running or not.
Use comments a lot (--this line might be broken, have a look at it after line 52 is fixed).

Get a good code editor, I did my first script in notepad which was a pain in the butt... After that I got SciTE which is a great help. One very useful thing you can do with it is search all document in a folder for lines of code (moho/scripts), this makes it very easy to find relative code to what you are doing.
As resources I've used the moho programming documentation and the last two links provided by LM in this thread. The second of those I think is better with lot of easily understood examples. And of course this scripting forum has been a tremendous help.

I hope I've been of some help to you. Good luck!
User avatar
mr. blaaa
Posts: 622
Joined: Sat Jul 30, 2005 4:41 pm
Location: ---
Contact:

Re: ...Some Advices to begin Learn LUA?

Post by mr. blaaa »

Ramón López wrote:I've NO idea of programing (NOTHING) and I don't know if learn is possible for me, but for now I'd only want to know enought to can write "simple" Moho scripts (like some for I've asked in the past.
...
And, of course, (don't laught :lol: ) I'd want to achieve this goal as quickly as possible... Cause of this, maybe, if you know what I mean, I'd be very GRATEFULL if you could give me some usefull advices, things like how you started to learn, essential tools or what is not necessary to learn in my case or, well... something to know how start "correctly" with all this "madness" at least...
...CIAO!
Uhhhhh-Wheeee! If you can accomplish to make LUA-Scripts you would be the greatest, cause you have GREAT feature requests and if learn how to put them into a script THIS WOULD BE HEAVEN ON EARTH :D
Image
User avatar
Rai López
Posts: 2297
Joined: Sun Aug 08, 2004 5:41 am
Location: Spain
Contact:

Post by Rai López »

THANK YOU rylleman :D you always are so kind as your advices PRACTICAL, very GRATEFULL :) and... yes, I like study the scripts and think how can I take benefit of they... but when I need (practicaly always) to make the minimun change of the codes, I have no idea and all get down :( ...By the way, I used Notepad for my first scripting works in the past and was a pain in the butt, yes... untill I discovered SciTE like you! :) What a change...
rylleman wrote:Use the print command a lot when you're writing, it help a lot in finding faulty code if you put print commands inside funtions and different arguments to see whats actually running or not.
Hmmm... :? I'm afraid I'm not sure about what this means... :( Print comand?? Hmmm... And thank you too for the info about the links, I've been searching something in spanish but nothing :( ...And, as I've said, in my case I have NO idea of any kind of programation works, had you any when you start to learn LUA? Only for curiosity... CIAO!

And, finaly... mr. blaaa!!! :D What can I say... I LOVE YA!!! :wink: I wonder where have you been all this time when I've felt so alone here... :cry: sniff... I have not words for you but emoticons... :D :D :D THANK YOU :mrgreen: too for be SO kind (too) and "bonico" :wink: CIAO! :)

PS: Hmmm... Another post with more emoticons than content, I'm afraid... :roll: (jaja...)
User avatar
rylleman
Posts: 750
Joined: Tue Feb 15, 2005 8:22 am
Location: sweden
Contact:

Post by rylleman »

Ramón López wrote: Hmmm... :? I'm afraid I'm not sure about what this means... :( Print comand?? Hmmm...
print is a LUA command that prints things in the lua console (in moho). (And it doesn't affect your scripts)
example;

Code: Select all

if x>y then
somevalue = 23
print "(x is greater than y and I set somevalue to 23)"
else
somevalue=12
print "(x in NOT greater than y and I set somevalue to 12)"
end
Great to use when you're testing your scripts in Moho, you make the script tell you what it's doing (or not doing). If you're not sure if a funtion is executed or not, put an print "(function x is running)" in it, if the text is printed in the lua console the function is running and something else is wrong...
Ramón López wrote:...And, as I've said, in my case I have NO idea of any kind of programation works, had you any when you start to learn LUA? Only for curiosity...
Not really, just some Pascal and C(no +) from school ages ago and pieces of Flash action scripting.
It's mostly a lot of if, then, else or do. Get the hang of how those is used and you have come a long way. For the rest you can use lua and moho programming documentation.
myles
Posts: 821
Joined: Fri Aug 20, 2004 7:32 pm
Location: Australia, Victoria, Morwell
Contact:

Post by myles »

Almost all the Lua documentation assumes you already know how to program and are using Lua as another language.

For a very quick introduction to programming, see Instant Hacking (written for Python, but worth reading for any language).

For a more extensive overview of learning to program, see Learning To Program - again, written for Python, but many of the concepts apply to any language - there are now examples in Javascript and VBScript as well.
There is also a Spanish version.

Regards, Myles.
"Quote me as saying I was mis-quoted."
-- Groucho Marx
User avatar
Rai López
Posts: 2297
Joined: Sun Aug 08, 2004 5:41 am
Location: Spain
Contact:

Post by Rai López »

THANK YOU TO BOTH!!! :D You are very kind as always... and yes, the print comand seems a usefull thing, I don't know if I get it completely now, but I'll experiment with it to see...
myles wrote:Almost all the Lua documentation assumes you already know how to program and are using Lua as another language.
:( Hmmm, I was afraid it... well, I'll try start little by little... THANK YOU for the links, specially the Spanish one seems very usefull :) , of course I'd prefer that it could be about Lua, because I can made my a mess :? , but well... I'll try to be patient :roll: ...THANKS! :D
myles
Posts: 821
Joined: Fri Aug 20, 2004 7:32 pm
Location: Australia, Victoria, Morwell
Contact:

Post by myles »

Just a note about the confusing use of the word "print" - why not something like "display"?

Before personal computers, early terminals had just a keyboard and a printer, no monitor/screen, and connected to a central main computer.
You would type in a command on the keyboard, and the response would be printed on the printer (on continuous paper with sprocket holes along the edges), or you would write a program that printed results.

When some terminals later got text screens/monitors, the response was "printed" on the monitor - you could use either type of terminal, with a printer or a monitor.
A lot of programming languages retained the word "print" for displaying a simple text message to the user, even after the old printing terminals disappeared.

Regards, Myles - old enough to have briefly used a printer terminal.
"Quote me as saying I was mis-quoted."
-- Groucho Marx
User avatar
mr. blaaa
Posts: 622
Joined: Sat Jul 30, 2005 4:41 pm
Location: ---
Contact:

Post by mr. blaaa »

myles wrote:Regards, Myles - old enough to have briefly used a printer terminal.
Yes Myles this was a cool CT explanation for the "print" command :wink:

BTW: I never told you, your moho tips section at your hp is really great, it was one of the first i started with. Much respect.

And a question: How does it go with animation master? Iam thinking about purchasing it if it's worth the money and it has good fast time to step in.
Image
Post Reply