> ## Documentation Index
> Fetch the complete documentation index at: https://docs.projectreal.gg/llms.txt
> Use this file to discover all available pages before exploring further.

# restorefunction

> Restaura ou substitui uma function chamando function hook operation internamente e não retorna values. O first argument deve ser uma function. Com um function argument, a function procura the saved original function; se nenhum entry existir, gera "Function is not hooked". Em seguida chama function hook operation com a hooked closure e a stored original closure, limpa o Lua stack e remove a restored closure de hook records quando a stored original foi usada. Se o second argument também for uma function, a function trata firstFunction como a original function a instalar e secondFunction como a closure a corrigir. Nessa forma, nenhum missing-original check e feito contra o valor armazenado em hook records; o valor armazenado e apenas comparado durante o final remove check. Non-function second arguments são ignorados pela branch condition. restorefunc e restoreclosure são aliases da mesma function.

<div className="real-function-page">
  ```lua theme={null}
  restorefunction(firstFunction: function, secondFunction?: function)
  ```

  ## Aliases

  * `restorefunc`
  * `restoreclosure`

  ## Argumentos

  <ParamField path={"firstFunction"} type={"function"} required>
    Com um argument, a hooked closure restaurada de hook records. Com um function second argument, a function instalada em secondFunction.
  </ParamField>

  <ParamField path={"secondFunction"} type={"function"}>
    Closure opcional corrigida com firstFunction. Esse branch só é usado quando o second argument é uma function.
  </ParamField>

  ## Exemplo

  Restore a hooked closure to its original function.

  ```lua theme={null}
  local function target()
      return "original"
  end

  hookfunction(target, function()
      return "hooked"
  end)

  print(target())

  restorefunction(target)

  print(target())
  ```
</div>
