Came to my mind that one of the hard to track bugs is when you do a misspelling on a variable.
As example:
Enemy.MovementAmount = 1
vs
Enemy.MovmenetAmount = 2
You might only notice that there is some strange behavior (as in this case enemy moves at wrong speed) and it might be difficult to track it down, since point is that you have in your code a place where you are setting the right speed, but you are putting it to a wrong named variable.
This kind of bug is quite common (to me at least, although I have so far been able to find them quite quick), and if there would be option to protect tables in some way, it would be easy to spot.
What I am after with this protection is that suppose I have table:
Enemy = {x, y, movementamount}
If I could then protect this table somehow, as in it wouldn't accept any more indexes, then if I would put Enemy.MovmentAmount=2, it would give me error saying that Enemy is protected from adding more variables, at which point I would instantly know where the error is.
Basically I can already do this myself in way of having Enemy.SetX(), Enemy.getX(), but especially if there are lots of these variables in a table, it starts to become quite messy making each variable have their own setter and getter commands, and even more problematic when looking at list of functions and trying to find some certain function in IDEs list of functions, since all those Getter and Setter functions would be bloating the list.
An example of how this could work:
Code: Select all
TurnOnTableProtection(True)
Enemy = {x, y, movementamount}
ProtectTable(Enemy)