whereis, a small script I hacked together to locate units on the currently loaded map. Saved me a lot of frustration trying to pinpoint the position of the mother of the child I rescued from a goblin fortress.
gist.github.com/MatthiasValvekens/0c649c348a7...Posted Nov 16, 2014, 11:08 AM UTC
Usually "for k,v in ipairs(list)" is preferred over for i=0,#list-1,1. Also, it would make the code run faster, since the "unit=df.global.world.units.all[i]" bit can be skipped (make it "for k,unit in ipairs(df.global.world.units.active)" and you don't even need to rewrite anything).
Also, Lua doesn't scope variables locally automatically--any variable that isn't explicitly defined as "local" is global, so you may want to add a "local" or two.
Thanks! I don't use lua very often, so I'm not familiar with the idioms. I appreciate the feedback.
EDIT: Modified the snippet accordingly.