ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

DonationCoder.com Software > FARR Plugins and Aliases

FLua: FARR Plugins Using Lua

(1/3) > >>

ewemoa:
I've been working on trying to make it possible to write plugins for FARR in Lua and there is now something that seems to work somewhat so...

The design is almost completely based on ecaradec's FScript (many thanks to him for releasing the source to that).  I haven't implemented timers yet, but other things are somewhat in-place.  If you've used FScript before, the interface should feel very familiar. 

Had some luck with following:


* on_init
* on_set_str_val
* on_search_begins
* on_regex_search_match
* on_process_trigger
* farr_set_str_value
* farr_get_str_value
* farr_emit_result
* farr_set_state
* farr_emit_results (this may be more convenient than using the last two)
Implemented but didn't really test:


* on_receive_key
* on_idle_time
Below is a link to a sample Lua plugin.  It is supposed to be similar to vitalyb's FARREnvironmentVariables plugin.

It's got some issues (e.g. DOS window showing up momentarily), but anyway:

  http://ewemoa.dcmembers.com/tmp/LuaPathEnvVars.zip

SHA-1: 50f501d3d6e85b7ea3052e76b13ecda58ca8be72

The contained files and folders are:


* FLua.dll
* flua.lua
* LICENSES\
* LuaPathEnvVars.ico
* plugin.lua
* README.txt <- pretty much useless at this point
The main file to tinker with at this point is plugin.lua.

Any comments welcome :)

mouser:
amazing  :-* :-* :-*

lanux128:
nice.. :up: btw, i'm not well-versed with Lua, is it easy to pick up?

ewemoa:
From what I understand, there was (and may be still is?) quite a bit of effort on the parts of the creators/maintainers (3 people as I understand it) to keep the language simple -- internally and externally.

Conceptually it reminds me a lot of Lisp/Scheme but with a syntax that feels more mainstream (though not really C-like).

To give you a taste, here's a snippet from plugin.lua (from the sample plugin):


--- Code: Text ---function on_init(  directory)  odprintf("    current working directory is: " .. lfs.currentdir())  plugin_dir = directory  odprintf("    plugin_dir set to: " .. directory)  determine_envvars()  return trueend
Below is an attempt at explaining the content (if there are other Lua folks around and see errors please speak up :) ).

This is a function definition.

Lines 1-3 are the portions that indicate a name for the function and a parameter names (the parameter being on separate lines is just a style I am experimenting with -- haven't seen any one else do this in Lua).  The name of the function is 'on_init' and it has one parameter named 'directory'.

Line 4 is a function call.  The argument is the result of concatenating (via ..) two things, a string and the result of another function call (the function currentdir in the module lfs)).

Line 5 is an assignment of the passed in value of 'directory' to the 'plugin_dir' variable (which currently is global).

Line 6 is another function call, similar to line 4.

Line 7 is a call to another function defined elsewhere in plugin.lua.

Line 8 is a return statement.  It returns a boolean true value.

Line 9 delimits the end of the function statement.

For reference, some potentially handy Lua resources:

  lua-users wiki
    http://lua-users.org/wiki/

  Programing in Lua (1st edition, covers a slightly older Lua, but still quite useful)
    http://www.lua.org/pil/

  The Programming Language Lua
    http://www.lua.org/

ecaradec:
This rocks ! I didn't know any lua, but I heard it's a great language and FLua is a native port (not activescripting ). People won't probably notice, but this will certainly prove much more flexible. Now I have a very good reason to learn Lua.

Do you know if FLua can use external libraries from lua ? That was lacking with FScript.

It certainly was a lot of work, even starting from FScript code... Thank you so much !

Navigation

[0] Message Index

[#] Next page

Go to full version