Last night I had my second Lua tutorial from Arcturus, one of my coworkers at Metaplace. :)
Again - it went pretty well! I am feeling like I understand more about how this all works already. I haven’t started the scripts related to the lesson yet - I’ll probably do that tonight sometime.
We continued our discussion about variables, and I learned what Assignment is - apparently I had been doing it already, I just didn’t know what it was actually called. (Assignment is when you set a variable - such as: my_variable = new_value). What I never realized, is that in assignment, the RIGHT side of the equation is evaluated first.
An example of this which helped me understand how variables are stored a LOT was the following:
command variable_testing()
local my_variable = 5
Debug (my_variable) — This will show that the variable is 5.
my_variable = my_variable + 1
Debug (my_variable) — This will show that the variable is now 6.
end
Another thing that I had always wondered - at what point would that variable no longer be what I had assigned it to be in the command? It apparently depends on where and how the variable is stored. In the case above, since it was stored locally in the command - it will reset back to what I had set it to once the command has finished running - so the next time I run the command, it would still say 5, and 6.
We also discussed command arguments (things you include with the name of the command when you run it) , and why we should declare them in the Define Commands block. If you don’t actually define them (tell the script what it is expecting - such as an int (integer), float (number that may include a decimal point) string, object, or player - it might work in SOME cases, such as in the case of an int or string - but in other cases, such as if the argument for your command is a player (which is a very specific thing to expect), it will just plain break. Good to know. :)
We also began to touch on the Metascript API - a library of functions that I can call on in a script to have the server do specific things in Metaplace. (It’s at http://www.metaplace.com/wiki/index.php/API_Functions). There’s a lot you can do with it, but for now I will probably do something simple using CreateObject and SlideObject to make an object of my choice appear, and start to wander. :)
That’s it for now, just wanted to post up what I learned yesterday - it really helps me to remember if I write it in my own words!