Data Realms Fan Forums
http://forums.datarealms.com/

load other data
http://forums.datarealms.com/viewtopic.php?f=73&t=31942
Page 1 of 1

Author:  p3lb0x [ Sun Oct 14, 2012 10:49 am ]
Post subject:  load other data

What is the easiest way to load a bunch of data into my lua script? At the moment I have all my data at the start of my script and that certainly isn't optimal.

Author:  p3lb0x [ Sun Oct 14, 2012 2:00 pm ]
Post subject:  Re: load other data

Oh yeah, should probably have specified that. From a file, is it possible to just ask lua to read lua from another file in the middle of the script? That would make it a whole lot easier to just strip the current data I have out and place it somewhere else, so that I don't have to parse it.

Author:  Bad Boy [ Sun Oct 14, 2012 3:21 pm ]
Post subject:  Re: load other data

It's not hard to call lua. Other stuff is probably more difficult, you use io.lines or some such, I don't really know anything about it.
But for lua you use:
Code:
dofile("folder.rte/filepath/script.lua");

You can also use require (not sure how the filepath works there) which I gather require is faster than dofile but limits the reloadability of the script (at least in the case of the ai).
With that you can call functions or variables defined in any lua file as if they were defined in this one. It's a great way to separate things into manageable chunks (e.g. my current scenario project has 7 separate lua files for the scenario so far).

Page 1 of 1 All times are UTC [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/