Page 1 of 1

Gulron's Noob Questions Thread!

Posted: Mon Dec 29, 2008 8:15 pm
by Gulron
So after reading about MicroMacro and actually using it for myself I am really intrigued. After reading a little about Lua and testing out a few simple Lua scripts in MicroMacro it has encouraged me to begin learning the programming language Lua so I can create macros for MicroMacro.

I have no real experience in scripting before so I have created this thread so that I could possibly get some help with the questions to come. I have looked at the RoM bot you have posted for download and opened up some of the files in LuaEdit 2.5 to experiment with.

My first question is: What is the difference between a .tag and a .lua file? I know .lua is the script file itself, so what is the .tag?

-Gulron

Re: Gulron's Noob Questions Thread!

Posted: Mon Dec 29, 2008 9:48 pm
by Administrator
There was no .tag file included in the RoM bot or any other that I am aware of, so it must be something associated with the software you are using.

In all reality, the file extensions don't mater. You do not need to name your files with the .lua extension to run them through MicroMacro.

Re: Gulron's Noob Questions Thread!

Posted: Mon Dec 29, 2008 10:01 pm
by Gulron
Administrator wrote:There was no .tag file included in the RoM bot or any other that I am aware of, so it must be something associated with the software you are using.

In all reality, the file extensions don't mater. You do not need to name your files with the .lua extension to run them through MicroMacro.
Okay, thank you very much.

Code: Select all

printf("text")
Edit: On a side note, I see you have;

Code: Select all

printf()
and not;

Code: Select all

print() 
Why is that?

Re: Gulron's Noob Questions Thread!

Posted: Mon Dec 29, 2008 11:59 pm
by Administrator
printf() is for C-style formatted printing. print() inserts tabs and newline characters that might not be wanted.

Try this:

Code: Select all

print("This is a print", "statement.", 12345, "\n");
printf("This is a print %s. %d\n", "statement", 12345);
printf() also allows a bit of casting:

Code: Select all

local number = 12345;
printf("%d in hex is 0x%X\n", number, number);

Re: Gulron's Noob Questions Thread!

Posted: Tue Dec 30, 2008 11:14 am
by Gulron
"%d" will take the first variable after the statement, so what is repeating the variable doing?

Re: Gulron's Noob Questions Thread!

Posted: Tue Dec 30, 2008 1:21 pm
by Administrator
%d prints a number in numerical form. %X prints a number in capitol hex form (and %x for lowercase).

Re: Gulron's Noob Questions Thread!

Posted: Tue Dec 30, 2008 2:40 pm
by Gulron
Administrator wrote:%d prints a number in numerical form. %X prints a number in capitol hex form (and %x for lowercase).
So why the "Ox" at the beginning?

Re: Gulron's Noob Questions Thread!

Posted: Tue Dec 30, 2008 4:07 pm
by Administrator
That's a 0, not an O. And it just denotes that it's hexadecimal.

Re: Gulron's Noob Questions Thread!

Posted: Tue Dec 30, 2008 6:03 pm
by Gulron
Okay I see. printf() gives more leeway for printing scripts while print() just prints out plain text.

Re: Gulron's Noob Questions Thread!

Posted: Thu Jan 01, 2009 8:34 pm
by zer0
printf is used because Elverion finds it easier to remember and shorter. However it's just a function reference to string.format() which can be located here:
http://lua-users.org/wiki/StringLibraryTutorial

Re: Gulron's Noob Questions Thread!

Posted: Thu Jan 01, 2009 9:03 pm
by Gulron
zer0 wrote:printf is used because Elverion finds it easier to remember and shorter. However it's just a function reference to string.format() which can be located here:
http://lua-users.org/wiki/StringLibraryTutorial
Whoa! Not ready for that yet.

Re: Gulron's Noob Questions Thread!

Posted: Thu Jan 01, 2009 10:33 pm
by zer0
Ok, then my best advice is to not start looking at the MicroMacro scripts yet.

Instead download lua and do a few tutorials.
http://lua-users.org/wiki/LuaTutorial

The tutorials may be a bit boring but you can probably pick it up in a few weeks if your new to programming.

When your confident that you can do most without any issue, then start modifying MM Scripts to suit your needs.

Lua has many uses outside of MicroMacro, and is one of the most popular scripting languages so it's definitely worth learning if you want to get into any programming. In fact an Open Source MMORPG I've worked on in the past now use Lua for most of there NPC's I believe.

If you get the core fundamentals right coding MM Scripts will be a breeze. My first mistake was trying to make scripts without much knowledge about Lua, when I started looking at the reference pages and learning the building blocks, that is when I started coding some seriously cool scripts. :)

It's always great to hear someone enthusiastic about learning about them and not just using scripts, Good luck and all the best.

Re: Gulron's Noob Questions Thread!

Posted: Thu Jan 01, 2009 11:13 pm
by Gulron
Thank you Zer0! Much appreciation for your tips.

I'm on Chapter 2 of http://www.lua.org/pil/index.html so far and have been enjoying learning about Lua.

Thanks again,
Gulron

Re: Gulron's Noob Questions Thread!

Posted: Sat Jan 03, 2009 12:02 pm
by Gulron
In Chapter 2.5 of Programming in Lua it teaches you about tables and I am a little confused. Here is the snippet of coding they use.

Code: Select all

   a = {}
    for i=1,10 do
      a[i] = io.read()
    end
My question is, where does the 'i' come from?

Re: Gulron's Noob Questions Thread!

Posted: Sat Jan 03, 2009 12:24 pm
by Administrator
'i' is just another variable. 'i' is often used in for-loops as the incremented value (hence, 'i'). Variables in Lua do not need to be explicitly declared, so it is created as soon as you see "for i".

Re: Gulron's Noob Questions Thread!

Posted: Sat Jan 03, 2009 4:54 pm
by Gulron
Thanks