A bunch of beginner LUA questions
I wrote a little script to help me add map pins.
However, this is my first time working with LUA and while understanding other scripts works fine, writing "blind" is kinda hard. I can't test my script without a beta, so there are probably a bunch of errors in it. There are some sections where I am really unsure whether they work (see bottom of this post). Feel free to read the whole script, though. There are probably other errors i couldn't find. (You may also correct my English, if I made some mistakes. I don't mind improving in another language besides LUA :D) complete script:
Warning: Spoiler
1) Does this delete the entry with the key pinTag, or will the key be associated with the value nil? (The former implies the later but will pairs(self.pins[pinType]) yield (pinTag, nil) or is it completely removed from the table?) Lua Code:
2) radius = radius gives me headaches...I'm really unsure about this. (Line 42) Lua Code:
3) At first, pinTooltipCreator is a string, but then its assigned to a table. What happens with AddLine(pinTooltipCreator)? What's the application order of LUA? Will it add the string because when the function was defined, pinTooltipCreator was still a string? ...or will it crash because when the function is executed, pinTooltipCreator is a table? Lua Code:
4) The function is defined and called inside methods of two different objects. Will self represent the defining or the executing object? Lua Code:
|
You wanna call
Lua Code:
Key being the colon instead of a period, also Create instead of create. Colon signifies self being passed invisibly to the function. foo:Bar() == foo.Bar( self ) Will keep reading |
Thanks, I fixed the mentioned errors.
Using : instead of . is kinda new to me. I've rarely seen a : in other languages. |
Lua indeed has some nice benefits.
http://www.lua.org/pil/5.html Quote:
|
All times are GMT -6. The time now is 11:03 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI