Welcome Guest.   Make a donation to an author on the site September 17, 2014, 10:39:04 AM  *

Please login or register.
Or did you miss your validation email?


Login with username and password (forgot your password?)
Why not become a lifetime supporting member of the site with a one-time donation of any amount? Your donation entitles you to a ton of additional benefits, including access to exclusive discounts and downloads, the ability to enter monthly free software drawings, and a single non-expiring license key for all of our programs.


You must sign up here before you can post and access some areas of the site. Registration is totally free and confidential.
 
The N.A.N.Y. Challenge 2014! Download dozens of custom programs!
   
   Forum Home   Thread Marks Chat! Downloads Search Login Register  
Pages: [1]   Go Down
  Reply  |  New Topic  |  Print  
Author Topic: FLua: FARR Plugins Using Lua  (Read 4564 times)
ewemoa
Honorary Member
**
Posts: 2,419



View Profile Give some DonationCredits to this forum member
« on: July 02, 2010, 09:38:25 AM »

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 smiley
Logged
mouser
First Author
Administrator
*****
Posts: 33,354



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #1 on: July 02, 2010, 03:39:36 PM »

amazing  Kiss Kiss Kiss
Logged
lanux128
Global Moderator
*****
Posts: 6,089



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #2 on: July 03, 2010, 12:37:31 AM »

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

ewemoa
Honorary Member
**
Posts: 2,419



View Profile Give some DonationCredits to this forum member
« Reply #3 on: July 03, 2010, 01:23:11 AM »

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):

Formatted for Lua with the GeSHI Syntax Highlighter [copy or print]
  1. function on_init(
  2.  directory
  3. )
  4.  odprintf("    current working directory is: " .. lfs.currentdir())
  5.  plugin_dir = directory
  6.  odprintf("    plugin_dir set to: " .. directory)
  7.  determine_envvars()
  8.  return true
  9. end

Below is an attempt at explaining the content (if there are other Lua folks around and see errors please speak up smiley ).

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/
Logged
ecaradec
Honorary Member
**
Posts: 408



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #4 on: July 04, 2010, 05:21:01 AM »

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 !
Logged

Blog & Projects : Blog | Qatapult | SwiffOut | FScript
ewemoa
Honorary Member
**
Posts: 2,419



View Profile Give some DonationCredits to this forum member
« Reply #5 on: July 04, 2010, 07:12:35 AM »

Do you know if FLua can use external libraries from lua ?
Depending on what you mean, I think it may be doable (perhaps in more than one way).

See:

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

Specifically, some bits I'm thinking of trying include:

  http://alien.luaforge.net/
  http://www.nongnu.org/cinvoke/lua.html

Quote
Thank you so much !
Thank you for FScript and its source smiley

BTW, the DLL is built using Code::Blocks and MinGW.  I'm hoping to clean up the source and make it generally available before too long.
Logged
ewemoa
Honorary Member
**
Posts: 2,419



View Profile Give some DonationCredits to this forum member
« Reply #6 on: July 09, 2010, 12:42:40 AM »

Specifically, some bits I'm thinking of trying include:
  http://alien.luaforge.net/
I've been trying to get alien to work with FLua but haven't had much luck so far.  Actually, it looks more like some kind of problem building alien (or libffi which alien uses) using Code::Blocks / MinGW.  Compilation is successful but when trying to do something as simple as:

Formatted for Lua with the GeSHI Syntax Highlighter [copy or print]
  1. require('alien')
  2. mb = alien.User32.MessageBoxA
  3. mb:types({ret = "long", abi = "stdcall", "long", "string", "string", "long"})
  4. mb(0, "Hey!", "From Lua", 0)

The host application (whether it's FARR of lua.exe) crashes at line 4 Sad
Logged
ecaradec
Honorary Member
**
Posts: 408



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #7 on: July 09, 2010, 06:29:02 AM »

Actually I was talking about lua libraries which I saw you can use in sources. Calling DLL would be neat too, but lua libraries open a lot of doors already.
Logged

Blog & Projects : Blog | Qatapult | SwiffOut | FScript
ewemoa
Honorary Member
**
Posts: 2,419



View Profile Give some DonationCredits to this forum member
« Reply #8 on: July 09, 2010, 09:01:47 AM »

Thanks for the follow-up comment.

I intend to continue looking into getting Alien to work, but in the mean time, here is a rearranged Flua:

  http://ewemoa.dcmembers.com/tmp/FLua-2010-07-09.zip

SHA-1: fd0c178adf51726d529c2e4edc5cd9c753b81add

The main difference in this version is that the core lua portion lives in its own dll (luadll.dll) and that FLua.dll and lfs.dll both link to luadll.dll.

Also included are rex_pcre.dll (also linked to luadll.dll) with pcre.dll and a minor amount of related test code in plugin.lua.
« Last Edit: July 09, 2010, 08:22:48 PM by ewemoa » Logged
ewemoa
Honorary Member
**
Posts: 2,419



View Profile Give some DonationCredits to this forum member
« Reply #9 on: July 09, 2010, 05:31:00 PM »

Here's something preliminary for sqlite 3 access:

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

SHA-1: 9de918c90409e4c9cfa879decf5c1d91af07868b

Some brief docs are included for lsqlite3 usage, but the original distribution has more detail. 

To install for use with FLua, I think all that is necessary is to place lsqlite3.dll and sqlite3.dll in the FLua plugins folder.
Logged
ewemoa
Honorary Member
**
Posts: 2,419



View Profile Give some DonationCredits to this forum member
« Reply #10 on: July 09, 2010, 08:39:15 PM »

FLua-2010-07-09.zip contained a lua.exe (for interactive fun and testing) which might lead to problems.

The following has a (hopefully) fixed lua.exe along with a lightly-tested LuaSocket:

  http://ewemoa.dcmembers.c...m/tmp/FLua-2010-07-10.zip

SHA-1: 2dd74629b0f8487444214dfdac1ae548880dff98

Short sample of LuaSocket use:

Formatted for Lua with the GeSHI Syntax Highlighter [copy or print]
  1. http = require("socket.http")
  2. print(http.request("http://donationcoder.com"))

For more details, please see the reference.
Logged
phitsc
Honorary Member
**
Posts: 1,003



see users location on a map View Profile Give some DonationCredits to this forum member
« Reply #11 on: July 22, 2010, 02:57:01 PM »

I agree with ecaradec. It's really cool that you have done this ewemoa!  Thmbsup

I've wanted to look into lua for a long time, have several times considered using it for work even, and have read quite a bit about it too (I confess: I'm a big fan of the Game Programming Gems series smiley).

I promise I'll check this stuff out as soon as I manage to come loose from Red Dead Redemption Wink
Logged

ecaradec
Honorary Member
**
Posts: 408



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #12 on: August 14, 2010, 01:06:55 PM »

Just a word to tell that you can consider fscript under the lgpl, mit license or even the even the WTFPL as you like, in case I disappear somewhere.
Logged

Blog & Projects : Blog | Qatapult | SwiffOut | FScript
Pages: [1]   Go Up
  Reply  |  New Topic  |  Print  
 
Jump to:  
   Forum Home   Thread Marks Chat! Downloads Search Login Register  

DonationCoder.com | About Us
DonationCoder.com Forum | Powered by SMF
[ Page time: 0.062s | Server load: 0.03 ]