lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Folks, I really like the LuaMacro
extension(http://lua-users.org/wiki/LuaMacros) and I'd like to use it
to simplify some of my AI scripts.

However while I do understand simple examples of its usage I can't
wrap my head  around more complicated scenarios :(

Basically I have the following Lua code(it's a piece of some AI
behavior tree logic):

parallel(function (self)
  self:add(sequence(function (self)
    self:add(Foo())
    self:add(Bar())
  end))
end)

... which I'd like to rewrite using LuaMacro as follows:

PARAL(
  ADD(SEQ(
     ADD(Foo())
     ADD(Bar))
  ))
)

I started with PARAL trying to implement it as follows:

def('PARAL', {'body';handle_params = true},
'parallel(function(self) body end)'
)

However the simple test script using this macro yields an error:

local f = PARAL(
  function(self) end
)

$ lua -lmacro test.lua
lua: test.lua:6: '<name>' expected near '('

I know how I would write these macro in plain C but can't write
similar stuff using LuaMacro. Help me please :)

-- 
Best regards, Pavel