You should probably read the script properties manual then: Script component properties
Hmm, well it’s probably not going to work exactly the same way as the debug “draw_line”. The script you have now only handles one straight line per script, so you would need a separate script instance for each line segment, which is not convenient at all. Hmm…
I would probably use a lua module. Put the draw_dotted_line function in the module and change it so instead of using ‘self’, all the things it needs are passed in as arguments. Pass in the ‘self.dot_ids’ list, and an optional ‘start index’ so you can use the same list of IDs for multiple line segments.
-- Something like this...
drawLine(start_pt, end_pt, dist_between_dots, factory_url, dot_ids, [first_dot_id_index])
It’ll need to return the last dot index that it used so you know which index to start with for the next line segment.
Separate the dot destroying/hiding part into a separate function in the module, which you’ll use after drawing all of your lines.
Once you have those things working you could add another function to the module to draw a full polyline from a list of points (it’ll just call the other module functions for you, taking care of the boilerplate stuff).
On another note, it would be slightly better if you only update the line when you need to—probably on mouse move instead of update.