-
Notifications
You must be signed in to change notification settings - Fork 1
Description
This scripts uses directly self as an storage for new values (that are needed internally for the script purposes). This may bring potential break in the future as keys used by this script can be taken also by other script. I'd suggest to use "namespacing" and put the values for this script-only into such namespace. For example, if you have this
function threshingFlowIndicator:onLoad(savegame)
self.hardStop = ....
end;and then you will have another script, that also operates with self.hardStop, you have problem as those values will collide and the value defined later will take precedence (on load, when in game directly, it depends on internal logic of scripts).
So in my oppinion it is better to use something like this:
function threshingFlowIndicator:onLoad(savegame)
self.DFI = {}; -- shortcut from 'Da-hoffi Flow Indicator'
self.DFI.hardStop = ....
end;This will prevent collisions as there are small chance any other author will use DFI as namespace. Of course namespace could be as long as you want, but for my convenience, I use three letters (author's first letter and then two letters for script identification).