Lua script implementation