Logic Machine Forum
Execute the script from remote .lua file - 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: Execute the script from remote .lua file (/showthread.php?tid=936)



Execute the script from remote .lua file - buuuudzik - 11.08.2017

Hello,

do you know if there is a possibility to download the .lua file from remote localization and execute it on LM? Such possibility could be helpful for service purpose.


RE: Execute the script from remote .lua file - admin - 11.08.2017

You can load source via HTTP request, then execute it like this (data variable must contain valid Lua code):
Code:
fn = loadstring(data)
fn()



RE: Execute the script from remote .lua file - buuuudzik - 11.08.2017

Very powerfull toolWink


RE: Execute the script from remote .lua file - Thomas - 11.08.2017

This is wonderfull! Now I can load a lua table from object comment.


RE: Execute the script from remote .lua file - nhieulk - 15.08.2017

How to load? Can you help me? detail.

Thank you so much
Big Grin


RE: Execute the script from remote .lua file - buuuudzik - 15.08.2017

(15.08.2017, 09:33)nhieulk Wrote: How to load? Can you help me? detail.

Thank you so much
Big Grin

E.g. like below:
Code:
data = socket.http.request('http://scripts.com/script1.lua')
fn = loadstring(data)

fn()