-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathtest30.lua
65 lines (52 loc) · 893 Bytes
/
test30.lua
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
local ecs = require "ecs"
local w = ecs.world()
w:register {
name = "vector",
"x:float",
"y:float",
}
w:register {
name = "mark"
}
w:register {
name = "id",
type = "int"
}
w:register {
name = "object",
type = "lua",
}
w:register {
name = "name",
type = "lua",
}
local eid = w:new {
vector = { x = 1, y = 2 },
mark = true,
id = 42,
object = { x = 3, y = 4 },
name = "foo",
}
local a = w:accessor(eid)
assert(a.vector.x == 1)
assert(a.vector.y == 2)
assert(a.mark == true)
assert(a.id == 42)
assert(a.object.x == 3)
assert(a.object.y == 4)
assert(a.name == "foo")
a.name = "foobar"
a.vector.x = 10
a.vector.y = 20
a.id = 24
a.mark = false
a.object.x = 0
assert(a.name == "foobar")
a() -- sync
for e in w:select "vector:in mark?in id:in object:in name:in" do
print(e.vector.x, e.vector.y)
print(e.mark)
print(e.id)
print(e.object.x, e.object.y)
print(e.name)
end