Cuberite Forum

Full Version: WebAdmin doesn't display correct content
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I'm actually creating a plugin for Cuberite. I wanted to create web admin pages for it, so, like Cuberite's LUA API says, I wrote this code:

Code:
   cWebAdmin.AddWebTab("Example", "example1", function(a_Request, a_UrlPath)
       return "asd", "text/html; charset=utf-8"
   end)


But it wasn't working (3rd argument should be string, not function (incorrect docs?Big Grin)). So, I've tried something like this:
Code:
   cWebAdmin.AddWebTab("Example", "example1", "example2", function(a_Request, a_UrlPath)
       return "asd", "text/html; charset=utf-8"
   end)

And, now "example1" appeared in the webadmin.
But, instead of "asd", webpage displays exactly the same content, as for Home. Maybe it's a bug, or I'm an idiot? ^^

Thank you for your help. Smile
Hello, welcome to the forum.

You're calling the function wrong, it should be
cWebAdmin:AddWebTab(...)  -- Note the colon instead of dot!
Then the parameters will match what the API docs say (the cWebAdmin itself is the first hidden parameter, like "this" in C++).
Oh, I forgot about it. Too much Java... :D

But still instead of "asd", Home page is displaying. Even I added LOG("dadadda") into handler and it's not displaying in console. I'm just doing something really wrong... Even this obsolete method with Plugin:AddWebTab() is not working...
That's strange, I tried your exact code in the Debuggers plugin and it works for me.
function Initialize(a_Plugin)
	-- Other unrelated code
	cWebAdmin:AddWebTab("Example", "example1", function(a_Request, a_UrlPath)
		return "asd", "text/html; charset=utf-8"
	end)
	-- Other unrelated code
end

Are you sure you reloaded the plugin (or restarted the server) so that the code changes were applied? Could you post your entire plugin source so that we can have a look?
Ekhm, it seems that Cuberite doesn't like spaces in plugin names... Alright, I fixed it by removing space from name of the plugin...

Anyway, thank you for help!Big Grin