Jump to content

Devs: adding 3rd party Lua scripts without rewriting files


Jetfire

Recommended Posts

hi,

 

I have made a few scripts that I find very useful, and I would like to share with everyone. The problem is, if I want to share a script that only modifies one function or one line, I have to get the person who downloads my file to overwrite the entire file, thus overwriting other modifications the person might have made. So, is there any way to go about this differently? Will Lockon compile/link any lua file within certain folders, or just the lua files that are already there?

 

If the only way to do it now is to overwrite the files, here's a possible fix:

make it so Lomac will compile all Lua scripts in a certain folder AFTER all other scripts have been compiled. So, for example, this folder was called Lua Addons. Say I wanted to modify cockpit.lua, I could put a file named "cockpit.lua" in the "Lockon\Lua Addons" folder, containing only the functions or variables that were changed. Then, LockOn would compile the "cockpit.lua" in the Config/Views folder, then it would compile the "cockpit.lua" in the Lua Addons folder, so the new variables and functions would be redefined by the new file.

sig36aa.jpg
Link to comment
Share on other sites

Hello Jetfire.

You have rise a interesting issue, I thought about it too.

But I see a problem here - what if a person want to install 2 script add-on, both patching the same "event" functions?

ED developers should think about suitable way to allow 3rd party developers easily deploy scripts add-on to user.

"There are five dangerous faults which may affect a general: recklessness, which leads to destruction; cowardice, which leads to capture; a hasty temper, which can be provoked by insults; a delicacy of honor which is sensitive to shame; over-solicitude for his men, which exposes him to worry and trouble." Sun Tzu

[sigpic]http://forums.eagle.ru/signaturepics/sigpic2354_5.gif[/sigpic]

Link to comment
Share on other sites

Ahh! That is true Dmut!

 

So, any addon file has to have it's own distinct filename, so there would have to be some type of association made within the addon Lua file that associates it with the original file it will modify. This association would have to be made because, to my experience, most Lua script functions in LockOn don't share the same scope. So, perhaps to an addon that modifies "cockpit.lua", we could have a function call dofileafter( "cockpit.lua" ) at the very beginning of a new file called "cockpit by Jetfire.lua". This function would make the association between "cockpit.lua" and "cockpit by Jetfire.lua". Just an idea...

sig36aa.jpg
Link to comment
Share on other sites

it's a good suggestion, Jetfire.

but then we come into the situation, when two 3rd party scripts both want to catch a same event function ( e.g. "LuaExportAfterNextFrame()" ), so I'm not sure how we should handle this.

 

first way:

LO should look into every .LUA in "/scripts/" and subdirs, and search for a function like "add_me_to_events_chain( my_function_name() )"

then every script author will have it's own "my_script.LUA", and the common thing will be that "add_me..." function only.

 

second way:

LO should look into every .LUA in "/scripts/" and subdirs, and search for a function with exactly the same name as in spec's:

LuaExportStart()

LuaExportBeforeNextFrame()

LuaExportAfterNextFrame()

LuaExportStop()

LuaExportActivityNextEvent(t)

and if LO found these functions - it's should call it one-by-one in those scripts where LO found it. Then every script get it's own "event" fucntions running in time.

 

What's do you think of it?

"There are five dangerous faults which may affect a general: recklessness, which leads to destruction; cowardice, which leads to capture; a hasty temper, which can be provoked by insults; a delicacy of honor which is sensitive to shame; over-solicitude for his men, which exposes him to worry and trouble." Sun Tzu

[sigpic]http://forums.eagle.ru/signaturepics/sigpic2354_5.gif[/sigpic]

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...