`KSR.rr.is_direction(...)` returns `1` if the direction is matching the parameter and `-1` if not. It does not return `true` or `false`, therefore be sure you do the appropriate comparison, it is different that kamailio.cfg language, where a negative return value is evaluated as false and positive is evaluate to true. In Lua, you have to do `<0` or `>0`.
Then, there is no function exported by kamailio `headers.get("$rdir(name)")`.
So overall, it looks like misunderstanding/misuse, rather than a bug in the code. You can discuss more or sr-users if you have further questions about using KEMI and Lua. If it proves to be a bug somewhere, then this can be reopen.