Logic Machine Forum
.lp call lua library function - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: .lp call lua library function (/showthread.php?tid=2252)



.lp call lua library function - benanderson_475 - 24.09.2019

Is it possible to call a lua library function from custom javascript using a .lp file, i know we can retrieve data from the .lp script

many Thanks


RE: .lp call lua library function - admin - 24.09.2019

You can call any function but you need to make sure that there are no blocking call because that will block the web server until function is executed. .lp can be loaded via XHR/AJAX call. What kind of function do you want to execute?


RE: .lp call lua library function - benanderson_475 - 24.09.2019

Thanks,
I have something working now,
If I have some lua lib function with parameters eg

function do_cmd(cmd)
return(“MV”.. cmd)
end

Can the parameter cmd be passed through the .lp
From the js Or do I need separate .lp for each function call?

Many thanks


RE: .lp call lua library function - admin - 24.09.2019

You can pass parameters via GET or POST. You can retrieve values via getvar() function in .lp. See complete documentation for more info: https://forum.logicmachine.net/showthread.php?tid=85

jQuery docs on how to send data via POST: https://api.jquery.com/jQuery.post/#jQuery-post-url-data-success-dataType