
Lua::registerCallback은 함수의 이름을 인자로 받는 것처럼 보이지만, 실제로는 함수의 포인터를 인자로 받습니다.
registerCallback을 통해 함수를 등록한 후, 다른 함수에서 이 등록된 함수를 호출하려면, 등록된 함수의 이름을 사용하여 호출하면 됩니다.
예를 들어, 다음과 같이 함수를 등록하고 호출할 수 있습니다.
#hostingforum.kr
lua
function myFunction()
print("myFunction 호출")
end
-- myFunction을 등록
Lua::registerCallback("myFunction")
-- myFunction을 호출
myFunction()
또는, 등록된 함수의 이름을 사용하여 호출할 수 있습니다.
#hostingforum.kr
lua
function myFunction()
print("myFunction 호출")
end
-- myFunction을 등록
Lua::registerCallback("myFunction")
-- 등록된 함수의 이름을 사용하여 호출
Lua::call("myFunction")
registerCallback은 함수의 포인터를 인자로 받기 때문에, 함수의 이름을 인자로 넘겨도 됩니다.
예를 들어, 다음과 같이 함수의 이름을 인자로 넘겨서 호출할 수 있습니다.
#hostingforum.kr
lua
function myFunction()
print("myFunction 호출")
end
function anotherFunction()
print("anotherFunction 호출")
end
-- myFunction을 등록
Lua::registerCallback("myFunction")
-- myFunction을 호출
Lua::call("myFunction")
-- anotherFunction을 등록
Lua::registerCallback("anotherFunction")
-- 등록된 함수의 이름을 사용하여 호출
Lua::call("myFunction") -- myFunction 호출
Lua::call("anotherFunction") -- anotherFunction 호출
2025-06-26 19:49