LuCI - some noob questions


I am newbie in LuCI (but not in sw development) and tried to understand how it works :slight_smile: Sorry for my dumb questions..

Is it possible to call function defined in my module from another module?

I created a function, registered it with entry() in my module index() and would like to call it as target for page from another module. But I've got error "Cannot resolve function"..

my module code:

module("luci.controller.zgroject.zgmodule", package.seeall)

function select_slider()
        luci.http.write("Haha, rebooting now...")

function index()
        entry({"zgproject","select_slider"}, call("select_slider"), "SelectSlider" , 80).dependent=false


I tried to call it from /admin/index.lua

 = call("zgproject/select_slider")


Failed to execute call dispatcher target for entry '/zgproject'.
The called action terminated with an exception:
/usr/lib/lua/luci/dispatcher.lua:818: Cannot resolve function "zgproject/select_slider". Is it misspelled or local?
stack traceback:
	[C]: in function 'assert'
	/usr/lib/lua/luci/dispatcher.lua:818: in function </usr/lib/lua/luci/dispatcher.lua:816>

With best regards,

Not sure if it matters, but zgproject is misspelled, it's missing a p.

1 Like

Thank you for your note. Corrected it, but still not work...

No, you cannot reference functions from other controller scopes. You could use an alias() action though to map the page node in admin/index.lua to another one in zgproject/zgmodule

1 Like

O! Thank you! Now it works :slight_smile: