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 )
-- this function is called everytime, the customs pins of the given pinType are to be drawn (map update because of zone/area change or RefreshPins call)
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:
self.pins[pinType][pinTag]=nil
2) radius = radius gives me headaches...I'm really unsure about this. (Line 42)
Lua Code:
pins[pinTag]={ area = subzone, x = locx, y = locy, radius = radius }
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 also offers a special syntax for object-oriented calls, the colon operator. An expression like o:foo(x) is just another way to write o.foo(o, x), that is, to call o.foo adding o as a first extra argument. In Chapter 16 we will discuss such calls (and object-oriented programming) in more detail.