Page 1 of 1
Lua: Calling functions of another script
Posted: Sun Jan 04, 2015 9:28 am
by hawkeye_de
Is it not possible to use require in the Lua sandbox of CMNO ?
So, I have a script file in the Lua directory
function testFunction(unit)
return unit.name
end
and try to call in the console:
myModule = require "myModule"
myModule.testFunction(unit)
as error I get
ERROR: [string "chunk"]:2: attempt to call global 'require' (a nil value)
If require does not work, is there any other means to create reuse functions, which I could reuse ?
Thanks.
RE: Lua: Calling functions of another script
Posted: Sun Jan 04, 2015 6:11 pm
by DeSade
try ScenEdit_RunScript (script):
http://commandlua.github.io/#ScenEdit_RunScript
script (library usually) should reside in Lua folder
RE: Lua: Calling functions of another script
Posted: Sun Jan 04, 2015 6:45 pm
by Dimitris
One of the things coming in v1.07 is that you'll be able to bundle such scripts with the scen you are distributing and have it work "out of the box" without having to instruct the end player to do anything ("place this file here" etc.).
RE: Lua: Calling functions of another script
Posted: Mon Jan 05, 2015 4:12 am
by hawkeye_de
Hm...the Runscript is not the same as require
For instance, it does not allow you to bind external libraries. Also, my understanding is that RunScript executes a script but not a function.
Additionally:
ZeroBraneStudio IDE (
http://studio.zerobrane.com/doc-remote-debugging) supports remote debugging...that is you should be able to debug embedded scripts. See for a usecase here:
http://notebook.kulchenko.com/zerobrane ... ane-studio
But to do so, you need to bind a library...
RE: Lua: Calling functions of another script
Posted: Mon Jan 05, 2015 5:35 am
by Dimitris
Hawkeye, how's your SSN sim going? I recently tried accessing your blog on it but seems to have vanished.
RE: Lua: Calling functions of another script
Posted: Mon Jan 05, 2015 7:50 am
by hawkeye_de
ORIGINAL: Sunburn
Hawkeye, how's your SSN sim going? I recently tried accessing your blog on it but seems to have vanished.
I've disabled the blog....the feedback which I've got was quite limited, so I've thought it is not worth the effort.
Frankly, I've developed it not so much further in the last 2-3 months. To do this alone in your spare time is really tough. I think developing such a sim like you in a team, would make much more sense.
Also from a game design perspective, there is the issue (in contrast to Command) that submarine combat is really slow. So, atmosphere is important, which translates into the fact, that you need a sophisticated UI experience. A hell of work
Anyways, here are some screenshots from the current build:
http://www.directupload.net/file/d/3858 ... u3_jpg.htm
http://www.directupload.net/file/d/3858 ... ua_jpg.htm
http://www.directupload.net/file/d/3858 ... 3d_jpg.htm
http://www.directupload.net/file/d/3858 ... 7y_jpg.htm