Matrix Games Forums

Forums  Register  Login  Photo Gallery  Member List  Search  Calendars  FAQ 

My Profile  Inbox  Address Book  My Subscription  My Forums  Log Out

Lua: Calling functions of another script

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
  Printable Version
All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Mods and Scenarios >> Lua: Calling functions of another script Page: [1]
Login
Message << Older Topic   Newer Topic >>
Lua: Calling functions of another script - 1/4/2015 11:28:06 AM   
hawkeye_de

 

Posts: 51
Joined: 4/19/2009
Status: offline
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.
Post #: 1
RE: Lua: Calling functions of another script - 1/4/2015 8:11:14 PM   
DeSade

 

Posts: 156
Joined: 3/1/2004
Status: offline
try ScenEdit_RunScript (script):

http://commandlua.github.io/#ScenEdit_RunScript

script (library usually) should reside in Lua folder

(in reply to hawkeye_de)
Post #: 2
RE: Lua: Calling functions of another script - 1/4/2015 8:45:03 PM   
Dimitris

 

Posts: 13282
Joined: 7/31/2005
Status: offline
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.).

_____________________________


(in reply to DeSade)
Post #: 3
RE: Lua: Calling functions of another script - 1/5/2015 6:12:10 AM   
hawkeye_de

 

Posts: 51
Joined: 4/19/2009
Status: offline
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/debugging-wireshark-lua-scripts-with-zerobrane-studio

But to do so, you need to bind a library...

(in reply to Dimitris)
Post #: 4
RE: Lua: Calling functions of another script - 1/5/2015 7:35:23 AM   
Dimitris

 

Posts: 13282
Joined: 7/31/2005
Status: offline
Hawkeye, how's your SSN sim going? I recently tried accessing your blog on it but seems to have vanished.

_____________________________


(in reply to hawkeye_de)
Post #: 5
RE: Lua: Calling functions of another script - 1/5/2015 9:50:48 AM   
hawkeye_de

 

Posts: 51
Joined: 4/19/2009
Status: offline

quote:

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/z6wgduu3_jpg.htm
http://www.directupload.net/file/d/3858/lgmhnhua_jpg.htm
http://www.directupload.net/file/d/3858/w3ojyl3d_jpg.htm
http://www.directupload.net/file/d/3858/eopefd7y_jpg.htm

(in reply to Dimitris)
Post #: 6
Page:   [1]
All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Mods and Scenarios >> Lua: Calling functions of another script Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts


Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI

1.480