-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSaveClass.chai
More file actions
97 lines (83 loc) · 1.64 KB
/
Copy pathSaveClass.chai
File metadata and controls
97 lines (83 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
class Test
{
def Test(_a, _b, _c, _d)
{
this.a = _a;
this.b = _b;
this.c = _c;
this.d = _d;
}
def GetFirstItem()
{
return this.a;
}
def GetSecondItem()
{
return this.b;
}
def GetThirdItem()
{
return this.c;
}
def GetFourthItem()
{
return this.d;
}
var a;
var b;
var c;
var d;
}
global test = Vector();
for (var i = 0; i < 5; ++i)
{
test.push_back(Test(i+1,i+2,i+3,i+4));
}
log("Before load vect size: " + test.size().to_string());
def OnSave(StringVector sv, IntVector iv)
{
var vectSize = test.size();
iv.push_back(vectSize);
for (var i = 0; i < vectSize; ++i)
{
iv.push_back(test[i].GetFirstItem());
iv.push_back(test[i].GetSecondItem());
iv.push_back(test[i].GetThirdItem());
iv.push_back(test[i].GetFourthItem());
}
test.clear();
}
def OnLoad(StringVector sv, IntVector iv)
{
if (iv.size() > 0)
{
test.clear();
var vectSize = iv[0];
log("After load vect size: " + vectSize.to_string());
var a;
var b;
var c;
var d;
var k = 1;
for (var i = 1; i < vectSize+1; k = k + 4)
{
++i;
a = iv[i];
b = iv[i+1];
c = iv[i+2];
d = iv[i+3];
test.push_back(Test(a,b,c,d));
}
}
}
def OnTurn()
{
log("Test size: " + test.size().to_string());
for (var i = 0; i < test.size(); ++i)
{
log(test[i].GetFirstItem().to_string());
log(test[i].GetSecondItem().to_string());
log(test[i].GetThirdItem().to_string());
log(test[i].GetFourthItem().to_string());
}
}