Is someone familiar with lua enough to override or create the -= or += operator?
I would like to use that instead of:
self.reallyLongDecriptiveVariable = self.reallyLongDecriptiveVariable - 1
With this operator like in java can be:
self.reallyLongDecriptiveVariable -= 1
If this is solely to keep from having to type all that out each time, you could do something like the following:
function IV(v,i) --takes in variable and increment and applies the later to the former
v = v + i
end
IV(self.reallyLongDecriptiveVariable,-1) --sic
Using this function you could increment it plus or minus any number, even use another variable as the second item passed and calculate by it just the same.
I assume there might be a time/performance penalty (though I haven’t run into one yet). [import]uid: 64596 topic_id: 19852 reply_id: 77050[/import]