Cuberite Forum
Console command output callback - Printable Version

+- Cuberite Forum (https://forum.cuberite.org)
+-- Forum: Plugins (https://forum.cuberite.org/forum-1.html)
+--- Forum: Plugin Discussion (https://forum.cuberite.org/forum-8.html)
+--- Thread: Console command output callback (/thread-2030.html)



Console command output callback - xoft - 06-30-2015

If we want to make some form of RCON-based automation, we need the plugins to be able to make command output in deferred calls (such as from within cWorld:ChunkStay() callbacks). In order to do so, we'd need to export the console command output callback interface somehow and let plugins use it. Something like:
function MyConsoleCmdHandler(a_Split, a_EntireCmd, a_Output)
  a_Output:WriteLn("Starting job")
  World:ChunkStay({{0, 0}}, nil,
    function()
      a_Output:WriteLn("Chunk loaded, block is " .. World:GetBlockType(1, 1, 1))
      a_Output:Done()  -- do we need such a thing?
    end
  )
  return true
end
There is currently no way of doing it in the current API - it is not possible to output anything into the command output once the command handler callback terminates.

There's a question about theBig Grinone() function - do we need it? How else to know that the plugin is no longer using the callback? If a poorly written plugin assigns the callback to a global variable, how do we proceed? Do we keep the callback for the rest of the plugin's life? What about the "request" that has created the callback, when does it terminate?