I have a problem with tables. I have created two objets and when I change the table of one of this, it is changed in the other object too...
I don't know how to solve this.
Code:
class Driver{
name = 0;
times = {};
constructor(n){
this.name = n;
}
function AddTime(time){
this.times[this.times.len()] <- time;
}
function GetTimes(){
return this.times;
}
}
local d1 = Drive("D1");
local d2 = Drive("D2");
log("times.len() " + d2.GetTimes().len());
d1.AddTime(12345);
log("times.len() " + d2.GetTimes().len());
Before the line "d1.AddTime(12345);" the length of the table of the d2 object is 0,
but after the instruction the length is 1, the same of the d1 object...