So I create an object via a macro. Everything works well
ecs.group players:
comps: CHealth
scope: public
this object has sequence of proc pointers. I can add action via macro
ecs.group players:
comps: CHealth
scope: public
event: handle_event
proc handle_event*() =
for e in players.added:
log e
This proc is for handling entities events. The thing is that group players is treated as an undeclared identifier inside of handle_event.
But if I just manually define group like in code below everything works.
var g = Group()
g.actions.add(handle_event)
proc handle_event*() =
for e in g.added:
log e
What am I missing? I dumped astgen and pretty sure that wrote macro correctly
I guess I found a solution. This language makes me insane XD
ecs.group players:
comps: CObject
scope: public
players.handle:
for e in this.added:
log e, "added"
for e in this.removed:
log e, "removed"
template handle*(self: Group, code: untyped): untyped =
self.events.add((this :GroupEvent) => code )