<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/">
	<channel>
		<title><![CDATA[Murga-Projects Forums - All Forums]]></title>
		<link>http://www.murga-projects.com/forum/</link>
		<description><![CDATA[Murga-Projects Forums - http://www.murga-projects.com/forum]]></description>
		<pubDate>Fri, 18 May 2012 13:41:51 -0600</pubDate>
		<generator>MyBB</generator>
		<item>
			<title><![CDATA[Wake on Lan]]></title>
			<link>http://www.murga-projects.com/forum/showthread.php?tid=419</link>
			<pubDate>Thu, 19 Apr 2012 04:31:00 -0600</pubDate>
			<guid isPermaLink="false">http://www.murga-projects.com/forum/showthread.php?tid=419</guid>
			<description><![CDATA[I just wrote a Wake on Lan script, and thought I might share it.<br />
<br />
It's a simple script using LuaSocket to send a magic packet to a computer to wake it up over the network.<br />
<br />
Usage is like:<br />
<br />
murgaLua wol.lua -i  (one or more MAC addresses, or identifiers)<br />
<br />
identifiers are defined in a table in the script in the table "targets". they start by @ and are followed by a number of characters (the set matched by %w).<br />
<br />
Feel free if you want to adapt it, or write a GUI frontend.]]></description>
			<content:encoded><![CDATA[I just wrote a Wake on Lan script, and thought I might share it.<br />
<br />
It's a simple script using LuaSocket to send a magic packet to a computer to wake it up over the network.<br />
<br />
Usage is like:<br />
<br />
murgaLua wol.lua -i  (one or more MAC addresses, or identifiers)<br />
<br />
identifiers are defined in a table in the script in the table "targets". they start by @ and are followed by a number of characters (the set matched by %w).<br />
<br />
Feel free if you want to adapt it, or write a GUI frontend.]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[MurgaLua 0.7.5 RC1 ... Maybe I release this time :-)]]></title>
			<link>http://www.murga-projects.com/forum/showthread.php?tid=418</link>
			<pubDate>Mon, 26 Dec 2011 09:52:16 -0700</pubDate>
			<guid isPermaLink="false">http://www.murga-projects.com/forum/showthread.php?tid=418</guid>
			<description><![CDATA[Hi,<br />
<br />
It seems like years since the last release ... Because it was :-(<br />
<br />
I use murgaLua for personal projects, and I am determined to get the 0.7 series done this year, as I am currently using a FLTK 1.3 version which I would like to release as 0.8.X.<br />
<br />
So here you have a release candidate for 0.7.5, I was hoping to push this out on Christmas day, but I found quite a few issues which took me while to resolve ... Either way it should be better and faster than before.<br />
<br />
In the archive you'll find builds for Windows, Linux, MacOS ...<br />
And RaspberryPI :-)<br />
<br />
The MacOS builds where done on Snow Leopard.<br />
The Linux builds where done on Centos 6.2.<br />
The Windows builds where done on Windows 8 (dev preview).<br />
And the RaspberryPI builds on an emulated Debian environment.<br />
<br />
You can find it all here :<br />
<br />
http://www.my-plan.org/storage/private/m...hot.tar.gz<br />
<br />
Highlights are stability (hopefully), a few more murgaLua API calls, JSON and Mongoose integration and a few more bits :-)<br />
<br />
The -M* flags below will cause a crash (a last minute bug I haven't fixed yet).<br />
It's kinda late here, but when I get time I'll post more info.<br />
<br />
<br />
JohnMurga Wrote:Intro<br />
<br />
This is final functionality for murgaLua 0.7.X.<br />
It is all about tidying up, fixing the docs and closing it up.<br />
<br />
I will post some examples of the neat new stuff you can do in subsequent posts.<br />
<br />
All bugs that I know about and that have been reported on the forum should be fixed.<br />
<br />
An 0.8.0 branch exists which is a major overhaul, FLTK 1.3, Unicode, breakages and all ...<br />
But I want a nice stable up-to-date base before I do anything with that.<br />
<br />
And to be honest I use 0.7.X for my day to day stuff at moment.<br />
<br />
Anyway, here is my initial drop ... More examples of note and info to follow.<br />
<br />
Testing of drop is minimal as I just wanted to give you guys something.<br />
I am pretty ill right now so I have likely made mistakes.<br />
<br />
I will update the tests and do another drop shortly.<br />
<br />
General Notes :<br />
<br />
New searchable documentation - In progress.<br />
New functions that deal with the nasty data than can be put into tables.<br />
Bugfixes for XML issues reported in forum, and new methods as requested.<br />
Overhaul of build process to better support multiple architectures.<br />
Many fixes to stability and building.<br />
Fixed lua_from_fluid, this is now a great way to generate UIs.<br />
Sound integration, several fixes to proteaAudio and RtAudio.<br />
LuaBitOp replaces bitlib due to portability and usability issues.<br />
API upgrades (luaLzo, copas, sqLite, zlib, md5) ... FLTK to final 1.1.10<br />
LuaFilesystem upgraded and patched for Solaris.<br />
Encrypted database container support changed to more solid sqlcipher API.<br />
(Which with the new sqLite version bloats things for the FULL build)<br />
CodeBlocks project support and migration of code to GIT repository.<br />
luaCom update for truly stable code for windows COM coding.<br />
More stable continue behaviour, and more examples, demos and tests.<br />
Incorprated LFann for AI code along with my stability fixes to it.<br />
Template for developing apps that look good on the OpenMoko phone.<br />
<br />
<br />
Core, Lite and Full - A reminder on the editions :<br />
<br />
Core murgaLua includes the core murgaLua functionality for the console :<br />
<br />
XML support through murgaLua bindings<br />
Efficient search and manipulation of data with murgaLua APIs<br />
Storage of data with support for encryption through snlcrypt<br />
Interface with native system APIs (DLLs, SOs, etc), with Alien<br />
Comprehensive networking support though luaSocket, enhanced through copas and coxpcall<br />
Interface to the filesystem with LuaFileSystem<br />
Compress data with LZO<br />
Customized version of luaSys for system and date functions<br />
Additional system, utility and debug functions in murgaLua<br />
All versions support the compiler<br />
<br />
(APIs : alien, luaLZO, iostring, slncrypt, luasys, luafilesystem, luaSocket, copas, coxpcall, MurgaLuaLib (system, c, lua, debug))<br />
<br />
Lite murgaLua includes the above plus the FLTK api, and is in keeping with the sub 500k dream :<br />
<br />
All fltk binding features<br />
Additional murgaLua FLTK utilities<br />
<br />
Full murgaLua is the recommended no-compromises release :<br />
<br />
Encrypted database support (custom/standard sqlite3 databases)<br />
Excellent integrated proAudioRt audio lib along with it's Ogg and WAV support<br />
Advanced date handing functionality (date lib)<br />
Advanced templating functionality (cosmo)<br />
And other useful lua bindings (md5, lzlib, random, LuaBitOp, lpeg-0.9, LFann)<br />
<br />
<br />
The new startup parameters :<br />
<br />
These are specially useful if you are spawning or forking murgaLua processes (for CGI or whatever).<br />
<br />
-M0 : Disable all murgaLua functionality<br />
This runs as a pure lua interpreter, and gives you the fastest startup.<br />
<br />
-M1 : Run in core murgaLua mode (only basic features enabled)<br />
Equivalent to running a murgaLua-core executable with CLI features only.<br />
This starts much faster than the other murgaLua modes.<br />
<br />
-M2 : Run in lite murgaLua mode if available (murgaLuaFltk + core)<br />
<br />
-M3 : DEFAULT - Run in FULL murgaLua mode (if available)<br />
<br />
The System enabler functions :<br />
<br />
These are useful if murgaLua has been started with one of new startup parameters, or if a new new murgaLua state has been created with the "Rings" API.<br />
<br />
When creating a state with "Rings" it'll be the equivalent of "M0", with the following the murgaLua mode can be changed if/when needed :<br />
<br />
These are for the murgaLua modes :<br />
<br />
_enableMurgaLuaCore()<br />
_enableMurgaLuaLite()<br />
_enableMurgaLuaFull()<br />
<br />
These for the "Stable" rings API :<br />
<br />
_enableRingsStable()<br />
<br />
Misc Notes :<br />
<br />
New murgaLua APIs<br />
<br />
<br />
Lua XML serialization is now safe (see tests)<br />
murgaLua.dumpToXml<br />
murgaLua.parseFromXml<br />
murgaLua.escapeLuaString<br />
murgaLua.getBuildProperties<br />
<br />
	<br />
New murgaLua.debug api :<br />
<br />
<br />
murgaLua.printDebug no longer works<br />
Replaced by : murgaLua.debug.printTable<br />
murgaLua.showTable for FLTK builds<br />
dumpTableAsLua for the debugger (more later)<br />
<br />
<br />
FLTK event changes :<br />
<br />
<br />
Fl.add_idle<br />
Fl.has_idle<br />
Fl.remove_idle<br />
Fl.set_event_handler<br />
Fl.start_event_handler<br />
Fl.stop_event_handler<br />
<br />
<br />
Fl_Tree changes<br />
<br />
<br />
fltk.Fl_Node<br />
fltk.Fl_ToggleNode<br />
fltk.Fl_ToggleTree<br />
fltk.FL_DAMAGE_TREE<br />
fltk.FL_TOGGLE_CLOSED<br />
fltk.FL_TOGGLE_HIT<br />
fltk.FL_TOGGLE_NONE<br />
fltk.FL_TOGGLE_OPENED<br />
fltk.FL_TOGGLE_RESELECT<br />
fltk.FL_TOGGLE_SELECT<br />
fltk.FL_TOGGLE_SELECT_MASK<br />
<br />
<br />
Other additional FLTK functions :<br />
<br />
<br />
Fl_RGB_Image.saveAsPng<br />
Fl_RGB_Image.getTiles(xSize, ySize)<br />
<br />
<br />
New APIs :<br />
<br />
<br />
alien<br />
cosmo<br />
coxpcall<br />
date<br />
inilazy<br />
lfann<br />
lpeg<br />
LuaBitOp<br />
lualogging<br />
luasys<br />
proteaAudio<br />
remdebug<br />
rings<br />
slncrypto<br />
<br />
<br />
<br />
]]></description>
			<content:encoded><![CDATA[Hi,<br />
<br />
It seems like years since the last release ... Because it was :-(<br />
<br />
I use murgaLua for personal projects, and I am determined to get the 0.7 series done this year, as I am currently using a FLTK 1.3 version which I would like to release as 0.8.X.<br />
<br />
So here you have a release candidate for 0.7.5, I was hoping to push this out on Christmas day, but I found quite a few issues which took me while to resolve ... Either way it should be better and faster than before.<br />
<br />
In the archive you'll find builds for Windows, Linux, MacOS ...<br />
And RaspberryPI :-)<br />
<br />
The MacOS builds where done on Snow Leopard.<br />
The Linux builds where done on Centos 6.2.<br />
The Windows builds where done on Windows 8 (dev preview).<br />
And the RaspberryPI builds on an emulated Debian environment.<br />
<br />
You can find it all here :<br />
<br />
http://www.my-plan.org/storage/private/m...hot.tar.gz<br />
<br />
Highlights are stability (hopefully), a few more murgaLua API calls, JSON and Mongoose integration and a few more bits :-)<br />
<br />
The -M* flags below will cause a crash (a last minute bug I haven't fixed yet).<br />
It's kinda late here, but when I get time I'll post more info.<br />
<br />
<br />
JohnMurga Wrote:Intro<br />
<br />
This is final functionality for murgaLua 0.7.X.<br />
It is all about tidying up, fixing the docs and closing it up.<br />
<br />
I will post some examples of the neat new stuff you can do in subsequent posts.<br />
<br />
All bugs that I know about and that have been reported on the forum should be fixed.<br />
<br />
An 0.8.0 branch exists which is a major overhaul, FLTK 1.3, Unicode, breakages and all ...<br />
But I want a nice stable up-to-date base before I do anything with that.<br />
<br />
And to be honest I use 0.7.X for my day to day stuff at moment.<br />
<br />
Anyway, here is my initial drop ... More examples of note and info to follow.<br />
<br />
Testing of drop is minimal as I just wanted to give you guys something.<br />
I am pretty ill right now so I have likely made mistakes.<br />
<br />
I will update the tests and do another drop shortly.<br />
<br />
General Notes :<br />
<br />
New searchable documentation - In progress.<br />
New functions that deal with the nasty data than can be put into tables.<br />
Bugfixes for XML issues reported in forum, and new methods as requested.<br />
Overhaul of build process to better support multiple architectures.<br />
Many fixes to stability and building.<br />
Fixed lua_from_fluid, this is now a great way to generate UIs.<br />
Sound integration, several fixes to proteaAudio and RtAudio.<br />
LuaBitOp replaces bitlib due to portability and usability issues.<br />
API upgrades (luaLzo, copas, sqLite, zlib, md5) ... FLTK to final 1.1.10<br />
LuaFilesystem upgraded and patched for Solaris.<br />
Encrypted database container support changed to more solid sqlcipher API.<br />
(Which with the new sqLite version bloats things for the FULL build)<br />
CodeBlocks project support and migration of code to GIT repository.<br />
luaCom update for truly stable code for windows COM coding.<br />
More stable continue behaviour, and more examples, demos and tests.<br />
Incorprated LFann for AI code along with my stability fixes to it.<br />
Template for developing apps that look good on the OpenMoko phone.<br />
<br />
<br />
Core, Lite and Full - A reminder on the editions :<br />
<br />
Core murgaLua includes the core murgaLua functionality for the console :<br />
<br />
XML support through murgaLua bindings<br />
Efficient search and manipulation of data with murgaLua APIs<br />
Storage of data with support for encryption through snlcrypt<br />
Interface with native system APIs (DLLs, SOs, etc), with Alien<br />
Comprehensive networking support though luaSocket, enhanced through copas and coxpcall<br />
Interface to the filesystem with LuaFileSystem<br />
Compress data with LZO<br />
Customized version of luaSys for system and date functions<br />
Additional system, utility and debug functions in murgaLua<br />
All versions support the compiler<br />
<br />
(APIs : alien, luaLZO, iostring, slncrypt, luasys, luafilesystem, luaSocket, copas, coxpcall, MurgaLuaLib (system, c, lua, debug))<br />
<br />
Lite murgaLua includes the above plus the FLTK api, and is in keeping with the sub 500k dream :<br />
<br />
All fltk binding features<br />
Additional murgaLua FLTK utilities<br />
<br />
Full murgaLua is the recommended no-compromises release :<br />
<br />
Encrypted database support (custom/standard sqlite3 databases)<br />
Excellent integrated proAudioRt audio lib along with it's Ogg and WAV support<br />
Advanced date handing functionality (date lib)<br />
Advanced templating functionality (cosmo)<br />
And other useful lua bindings (md5, lzlib, random, LuaBitOp, lpeg-0.9, LFann)<br />
<br />
<br />
The new startup parameters :<br />
<br />
These are specially useful if you are spawning or forking murgaLua processes (for CGI or whatever).<br />
<br />
-M0 : Disable all murgaLua functionality<br />
This runs as a pure lua interpreter, and gives you the fastest startup.<br />
<br />
-M1 : Run in core murgaLua mode (only basic features enabled)<br />
Equivalent to running a murgaLua-core executable with CLI features only.<br />
This starts much faster than the other murgaLua modes.<br />
<br />
-M2 : Run in lite murgaLua mode if available (murgaLuaFltk + core)<br />
<br />
-M3 : DEFAULT - Run in FULL murgaLua mode (if available)<br />
<br />
The System enabler functions :<br />
<br />
These are useful if murgaLua has been started with one of new startup parameters, or if a new new murgaLua state has been created with the "Rings" API.<br />
<br />
When creating a state with "Rings" it'll be the equivalent of "M0", with the following the murgaLua mode can be changed if/when needed :<br />
<br />
These are for the murgaLua modes :<br />
<br />
_enableMurgaLuaCore()<br />
_enableMurgaLuaLite()<br />
_enableMurgaLuaFull()<br />
<br />
These for the "Stable" rings API :<br />
<br />
_enableRingsStable()<br />
<br />
Misc Notes :<br />
<br />
New murgaLua APIs<br />
<br />
<br />
Lua XML serialization is now safe (see tests)<br />
murgaLua.dumpToXml<br />
murgaLua.parseFromXml<br />
murgaLua.escapeLuaString<br />
murgaLua.getBuildProperties<br />
<br />
	<br />
New murgaLua.debug api :<br />
<br />
<br />
murgaLua.printDebug no longer works<br />
Replaced by : murgaLua.debug.printTable<br />
murgaLua.showTable for FLTK builds<br />
dumpTableAsLua for the debugger (more later)<br />
<br />
<br />
FLTK event changes :<br />
<br />
<br />
Fl.add_idle<br />
Fl.has_idle<br />
Fl.remove_idle<br />
Fl.set_event_handler<br />
Fl.start_event_handler<br />
Fl.stop_event_handler<br />
<br />
<br />
Fl_Tree changes<br />
<br />
<br />
fltk.Fl_Node<br />
fltk.Fl_ToggleNode<br />
fltk.Fl_ToggleTree<br />
fltk.FL_DAMAGE_TREE<br />
fltk.FL_TOGGLE_CLOSED<br />
fltk.FL_TOGGLE_HIT<br />
fltk.FL_TOGGLE_NONE<br />
fltk.FL_TOGGLE_OPENED<br />
fltk.FL_TOGGLE_RESELECT<br />
fltk.FL_TOGGLE_SELECT<br />
fltk.FL_TOGGLE_SELECT_MASK<br />
<br />
<br />
Other additional FLTK functions :<br />
<br />
<br />
Fl_RGB_Image.saveAsPng<br />
Fl_RGB_Image.getTiles(xSize, ySize)<br />
<br />
<br />
New APIs :<br />
<br />
<br />
alien<br />
cosmo<br />
coxpcall<br />
date<br />
inilazy<br />
lfann<br />
lpeg<br />
LuaBitOp<br />
lualogging<br />
luasys<br />
proteaAudio<br />
remdebug<br />
rings<br />
slncrypto<br />
<br />
<br />
<br />
]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[murgaLua color/image]]></title>
			<link>http://www.murga-projects.com/forum/showthread.php?tid=417</link>
			<pubDate>Wed, 09 Nov 2011 10:17:05 -0700</pubDate>
			<guid isPermaLink="false">http://www.murga-projects.com/forum/showthread.php?tid=417</guid>
			<description><![CDATA[Hi,<br />
<br />
I have had some trouble loading images into my app and getting colors to properly show.<br />
<br />
<br />
What I had after converting the script to lua for colors is:<br />
<br />
<br />
Code:<br />
object:color((Fl_Color)179);<br />
<br />
<br />
That way I can't run it because it will error at the "179" part.<br />
<br />
So I changed it to:<br />
<br />
<br />
Code:<br />
object:color((Fl_Color),179);<br />
<br />
<br />
And it would run, only show everything black.<br />
<br />
<br />
About images. What I have after converting is:<br />
<br />
<br />
Code:<br />
object:image(image_intel2GenCorei5);<br />
<br />
<br />
But running it again it won't show it.<br />
<br />
Also I was wondering, the .cxx file contains an array of the entire image. How does it do it after converting, because that part is gone of course?<br />
And if I compile it into an exe, do I have to provide the image with the compiled exe?<br />
Or does it compile the image inside/with the exe?<br />
How does it work? :)<br />
<br />
<br />
Thanks.]]></description>
			<content:encoded><![CDATA[Hi,<br />
<br />
I have had some trouble loading images into my app and getting colors to properly show.<br />
<br />
<br />
What I had after converting the script to lua for colors is:<br />
<br />
<br />
Code:<br />
object:color((Fl_Color)179);<br />
<br />
<br />
That way I can't run it because it will error at the "179" part.<br />
<br />
So I changed it to:<br />
<br />
<br />
Code:<br />
object:color((Fl_Color),179);<br />
<br />
<br />
And it would run, only show everything black.<br />
<br />
<br />
About images. What I have after converting is:<br />
<br />
<br />
Code:<br />
object:image(image_intel2GenCorei5);<br />
<br />
<br />
But running it again it won't show it.<br />
<br />
Also I was wondering, the .cxx file contains an array of the entire image. How does it do it after converting, because that part is gone of course?<br />
And if I compile it into an exe, do I have to provide the image with the compiled exe?<br />
Or does it compile the image inside/with the exe?<br />
How does it work? :)<br />
<br />
<br />
Thanks.]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[idea not yet in progress - gifsicle gui]]></title>
			<link>http://www.murga-projects.com/forum/showthread.php?tid=416</link>
			<pubDate>Mon, 26 Sep 2011 08:10:21 -0600</pubDate>
			<guid isPermaLink="false">http://www.murga-projects.com/forum/showthread.php?tid=416</guid>
			<description><![CDATA[So it's been over a month without a new post here, so I thought I'd say hi.<br />
<br />
I've been using Gimp and/or Blender to do most of my gif animation, with gifsicle to optimize, and it works alright mostly.  But Gimp especially is very limited in its animation abilities, and I've been wanting to include gifsicle as a larger part of the process.  Problem is that I don't like using commandline apps for graphics (other than for doing batch processing), so I started thinking about a gui frontend to gifsicle made with murgalua, especially considering there isn't really much available elsewhere.  I've found only two gifsicle frontends, both of which are very old, and neither is available in Debian repo.<br />
<br />
Anyway...that's all I had to say about it...haven't done any actual work on it, and it will probably be at least a few weeks before I do, but I felt a need to drop something new into the forum.]]></description>
			<content:encoded><![CDATA[So it's been over a month without a new post here, so I thought I'd say hi.<br />
<br />
I've been using Gimp and/or Blender to do most of my gif animation, with gifsicle to optimize, and it works alright mostly.  But Gimp especially is very limited in its animation abilities, and I've been wanting to include gifsicle as a larger part of the process.  Problem is that I don't like using commandline apps for graphics (other than for doing batch processing), so I started thinking about a gui frontend to gifsicle made with murgalua, especially considering there isn't really much available elsewhere.  I've found only two gifsicle frontends, both of which are very old, and neither is available in Debian repo.<br />
<br />
Anyway...that's all I had to say about it...haven't done any actual work on it, and it will probably be at least a few weeks before I do, but I felt a need to drop something new into the forum.]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Response from Message Box]]></title>
			<link>http://www.murga-projects.com/forum/showthread.php?tid=415</link>
			<pubDate>Thu, 28 Jul 2011 13:24:19 -0600</pubDate>
			<guid isPermaLink="false">http://www.murga-projects.com/forum/showthread.php?tid=415</guid>
			<description><![CDATA[I have an app with a main window that I need to display a sort of Message Box to the user to confirm whether to continue with a particular operation.  The Message Box is created in a function that is called, the function defines the window and its components, populates a text box from the contents of a function argument, and awaits the user to select one of two buttons..<br />
<br />
At the end of the function a call to 'window:show()' is used to display the Message Box... but control returns to the calling code immediately.  The Message Box window is defined as being modal, which helps to keep the user from clicking off it and trying to continue without responding... that's good, however, I am unable to return to the calling code which button the user chose.<br />
<br />
Is there a recommended way to do this?<br />
<br />
Thanks,<br />
<br />
-CJ]]></description>
			<content:encoded><![CDATA[I have an app with a main window that I need to display a sort of Message Box to the user to confirm whether to continue with a particular operation.  The Message Box is created in a function that is called, the function defines the window and its components, populates a text box from the contents of a function argument, and awaits the user to select one of two buttons..<br />
<br />
At the end of the function a call to 'window:show()' is used to display the Message Box... but control returns to the calling code immediately.  The Message Box window is defined as being modal, which helps to keep the user from clicking off it and trying to continue without responding... that's good, however, I am unable to return to the calling code which button the user chose.<br />
<br />
Is there a recommended way to do this?<br />
<br />
Thanks,<br />
<br />
-CJ]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[screen corruption issue]]></title>
			<link>http://www.murga-projects.com/forum/showthread.php?tid=414</link>
			<pubDate>Thu, 28 Jul 2011 11:12:56 -0600</pubDate>
			<guid isPermaLink="false">http://www.murga-projects.com/forum/showthread.php?tid=414</guid>
			<description><![CDATA[i have the following test case which either illustrates a screen corruption issue, or i am doing something wrong:<br />
<br />
 testindex.lua to launch the script<br />
 testadmin.lua shows screen corruption when you click on one of the<br />
 entries in the (left) list box; -but- uncommenting the last two lines:-<br />
 --window:show()<br />
 --Fl:run()<br />
<br />
 then works fine!<br />
<br />
<br />
 here are the code snippets<br />
<br />
 any comments, or pointers to the problem would be appreciated<br />
<br />
regards,<br />
   --roy dobbins<br />
<br />
<br />
 -- testindex.lua<br />
<br />
 local window = fltk:Fl_Double_Window(366, 500,"MurgaLua Test Manager")<br />
<br />
 local button=fltk:Fl_Button(50,27,24,24)<br />
        button:callback(function()<br />
          require "testadmin"<br />
          testadmin.window:show()<br />
        end)<br />
<br />
 window:show()<br />
 Fl:run()<br />
<br />
-- testadmin.lua<br />
<br />
 module("testadmin", package.seeall)<br />
<br />
 local ww=400 --window width<br />
 local wh=350 --window height<br />
 local col=ww/4<br />
 local col2=ww-col -- column widths<br />
 local b<br />
 local br_two<br />
<br />
 function list_callback(w)<br />
    local colnames={'a','b','c','d','e','f'}<br />
    local colcount = # colnames<br />
    local colwidths = {}<br />
    for i=1,colcount do colwidths[i] = string.len(colnames[i]) * b:labelsize() end<br />
    table.insert(colwidths,0)<br />
<br />
    b:clear()<br />
    b:column_widths(colwidths)<br />
    b:column_char(string.byte('|'))<br />
<br />
    local header=""<br />
    for i=1,colcount do<br />
      if i>  1 then header=header.."|" end<br />
      header=header.."@B12@C7@b@."..colnames[i]<br />
    end<br />
    b:add(header)<br />
<br />
    for r=1,2500 do<br />
      local data=""<br />
      for i=1,colcount do<br />
        if i>  1 then data=data.."|" end<br />
        data=data..string.format("rc%d %d", r,i)<br />
      end<br />
      b:add(data)<br />
    end<br />
<br />
    window:redraw()<br />
 end<br />
<br />
 window = fltk:Fl_Double_Window(ww, wh, "test admin")<br />
<br />
 local nameedit = fltk:Fl_Input(200,0,100,25,'Name of this view...........:')<br />
 br_two=fltk:Fl_Hold_Browser(0,50,col,wh-75,"Fl_Hold_Browser")<br />
 br_two:add('1')<br />
 br_two:add('2')<br />
 br_two:add('3')<br />
 br_two:callback(list_callback)<br />
<br />
 b = fltk:Fl_Hold_Browser(col,50,col2,wh-75,"Table Browser")<br />
<br />
 fltk:Fl_End() -- end of window<br />
<br />
--following two lines are significant to the problem!<br />
 --window:show()<br />
 --Fl:run()<br />
<br />
-- if above two lines commented out, problem shows up<br />
--otherwise works ok]]></description>
			<content:encoded><![CDATA[i have the following test case which either illustrates a screen corruption issue, or i am doing something wrong:<br />
<br />
 testindex.lua to launch the script<br />
 testadmin.lua shows screen corruption when you click on one of the<br />
 entries in the (left) list box; -but- uncommenting the last two lines:-<br />
 --window:show()<br />
 --Fl:run()<br />
<br />
 then works fine!<br />
<br />
<br />
 here are the code snippets<br />
<br />
 any comments, or pointers to the problem would be appreciated<br />
<br />
regards,<br />
   --roy dobbins<br />
<br />
<br />
 -- testindex.lua<br />
<br />
 local window = fltk:Fl_Double_Window(366, 500,"MurgaLua Test Manager")<br />
<br />
 local button=fltk:Fl_Button(50,27,24,24)<br />
        button:callback(function()<br />
          require "testadmin"<br />
          testadmin.window:show()<br />
        end)<br />
<br />
 window:show()<br />
 Fl:run()<br />
<br />
-- testadmin.lua<br />
<br />
 module("testadmin", package.seeall)<br />
<br />
 local ww=400 --window width<br />
 local wh=350 --window height<br />
 local col=ww/4<br />
 local col2=ww-col -- column widths<br />
 local b<br />
 local br_two<br />
<br />
 function list_callback(w)<br />
    local colnames={'a','b','c','d','e','f'}<br />
    local colcount = # colnames<br />
    local colwidths = {}<br />
    for i=1,colcount do colwidths[i] = string.len(colnames[i]) * b:labelsize() end<br />
    table.insert(colwidths,0)<br />
<br />
    b:clear()<br />
    b:column_widths(colwidths)<br />
    b:column_char(string.byte('|'))<br />
<br />
    local header=""<br />
    for i=1,colcount do<br />
      if i>  1 then header=header.."|" end<br />
      header=header.."@B12@C7@b@."..colnames[i]<br />
    end<br />
    b:add(header)<br />
<br />
    for r=1,2500 do<br />
      local data=""<br />
      for i=1,colcount do<br />
        if i>  1 then data=data.."|" end<br />
        data=data..string.format("rc%d %d", r,i)<br />
      end<br />
      b:add(data)<br />
    end<br />
<br />
    window:redraw()<br />
 end<br />
<br />
 window = fltk:Fl_Double_Window(ww, wh, "test admin")<br />
<br />
 local nameedit = fltk:Fl_Input(200,0,100,25,'Name of this view...........:')<br />
 br_two=fltk:Fl_Hold_Browser(0,50,col,wh-75,"Fl_Hold_Browser")<br />
 br_two:add('1')<br />
 br_two:add('2')<br />
 br_two:add('3')<br />
 br_two:callback(list_callback)<br />
<br />
 b = fltk:Fl_Hold_Browser(col,50,col2,wh-75,"Table Browser")<br />
<br />
 fltk:Fl_End() -- end of window<br />
<br />
--following two lines are significant to the problem!<br />
 --window:show()<br />
 --Fl:run()<br />
<br />
-- if above two lines commented out, problem shows up<br />
--otherwise works ok]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[The best LUA IDE I have tried]]></title>
			<link>http://www.murga-projects.com/forum/showthread.php?tid=413</link>
			<pubDate>Thu, 28 Jul 2011 07:39:41 -0600</pubDate>
			<guid isPermaLink="false">http://www.murga-projects.com/forum/showthread.php?tid=413</guid>
			<description><![CDATA[Hi,<br />
<br />
It runs in IntelliJ IDEA, which is a bit fat.<br />
<br />
But it's worth it :<br />
<br />
https://bitbucket.org/sylvanaar2/lua-for-idea/wiki/Home<br />
<br />
The two upcoming releases are configured to integrate this fully (including debugging support).<br />
<br />
Cheers<br />
John de Murga]]></description>
			<content:encoded><![CDATA[Hi,<br />
<br />
It runs in IntelliJ IDEA, which is a bit fat.<br />
<br />
But it's worth it :<br />
<br />
https://bitbucket.org/sylvanaar2/lua-for-idea/wiki/Home<br />
<br />
The two upcoming releases are configured to integrate this fully (including debugging support).<br />
<br />
Cheers<br />
John de Murga]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Happy Birthday, John!]]></title>
			<link>http://www.murga-projects.com/forum/showthread.php?tid=412</link>
			<pubDate>Fri, 24 Jun 2011 20:05:30 -0600</pubDate>
			<guid isPermaLink="false">http://www.murga-projects.com/forum/showthread.php?tid=412</guid>
			<description><![CDATA[Happy 37th...hope it's been a good one.]]></description>
			<content:encoded><![CDATA[Happy 37th...hope it's been a good one.]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Making scroll ignore pageup/pagedown/home/end?]]></title>
			<link>http://www.murga-projects.com/forum/showthread.php?tid=411</link>
			<pubDate>Mon, 16 May 2011 07:35:29 -0600</pubDate>
			<guid isPermaLink="false">http://www.murga-projects.com/forum/showthread.php?tid=411</guid>
			<description><![CDATA[I've been trying to work out a way to navigate Fl_Browser using keyboard only, and running into a problem with the scroll automatically grabbing certain keystrokes and ignoring actions specifically associated with those events.  In Fl_Hold_Browser using Up and Down to move the section up and down one line at a time works as expected without modification.  However, PageUp, PageDown, Home, and End will only move the scroll...the browser selection doesn't change, so you still have to click to select.<br />
<br />
I tried setting up a global menu bar to detect these events, and specifically move the selection accordingly.  It works only if the browser does not have focus.  I thought a global menu was supposed to work no matter what widget has focus, but there seems to be some hard-coded events associated with some widgets.<br />
<br />
Any ideas how to accomplish this, other than by using non-standard keys to do the navigation?  It works fine if I use keys not generally associated with navigation, but PageUp/PageDown are so common it seems really weird to use anything else.<br />
<br />
<br />
<br />
Code:<br />
function nav_browser()<br />
if Fl:event_key() == fltk.FL_Home then<br />
&nbsp;&nbsp;&nbsp;&nbsp;browser:value(1)<br />
&nbsp;&nbsp;&nbsp;&nbsp;browser:topline(1)<br />
elseif Fl:event_key() == fltk.FL_End then<br />
&nbsp;&nbsp;&nbsp;&nbsp;browser:value(browser:size())<br />
&nbsp;&nbsp;&nbsp;&nbsp;browser:bottomline(browser:size())<br />
elseif Fl:event_key() == fltk.FL_Page_Up then<br />
&nbsp;&nbsp;&nbsp;&nbsp;browser:bottomline(browser:value())<br />
&nbsp;&nbsp;&nbsp;&nbsp;Fl:check()<br />
&nbsp;&nbsp;&nbsp;&nbsp;browser:value(browser:topline())<br />
elseif Fl:event_key() == fltk.FL_Page_Down then<br />
-- can't figure this one yet<br />
-- why can you use topline() without an argument, but not bottomline()?<br />
end<br />
end<br />
<br />
win = fltk:Fl_Window(400,500,"browser nav test")<br />
browser = fltk:Fl_Hold_Browser(0,0,400,500)<br />
browser_ctrl = fltk:Fl_Menu_Bar(400,500,10,10)<br />
browser_ctrl:add("home", fltk.FL_Home, nav_browser)<br />
browser_ctrl:add("end", fltk.FL_End, nav_browser)<br />
browser_ctrl:add("up", fltk.FL_Page_Up, nav_browser)<br />
browser_ctrl:add("down", fltk.FL_Page_Down, nav_browser)<br />
browser_ctrl:global()<br />
<br />
for line = 1,100 do browser:add("Line "..line) end<br />
<br />
win:show()<br />
Fl:run()<br />
<br />
]]></description>
			<content:encoded><![CDATA[I've been trying to work out a way to navigate Fl_Browser using keyboard only, and running into a problem with the scroll automatically grabbing certain keystrokes and ignoring actions specifically associated with those events.  In Fl_Hold_Browser using Up and Down to move the section up and down one line at a time works as expected without modification.  However, PageUp, PageDown, Home, and End will only move the scroll...the browser selection doesn't change, so you still have to click to select.<br />
<br />
I tried setting up a global menu bar to detect these events, and specifically move the selection accordingly.  It works only if the browser does not have focus.  I thought a global menu was supposed to work no matter what widget has focus, but there seems to be some hard-coded events associated with some widgets.<br />
<br />
Any ideas how to accomplish this, other than by using non-standard keys to do the navigation?  It works fine if I use keys not generally associated with navigation, but PageUp/PageDown are so common it seems really weird to use anything else.<br />
<br />
<br />
<br />
Code:<br />
function nav_browser()<br />
if Fl:event_key() == fltk.FL_Home then<br />
&nbsp;&nbsp;&nbsp;&nbsp;browser:value(1)<br />
&nbsp;&nbsp;&nbsp;&nbsp;browser:topline(1)<br />
elseif Fl:event_key() == fltk.FL_End then<br />
&nbsp;&nbsp;&nbsp;&nbsp;browser:value(browser:size())<br />
&nbsp;&nbsp;&nbsp;&nbsp;browser:bottomline(browser:size())<br />
elseif Fl:event_key() == fltk.FL_Page_Up then<br />
&nbsp;&nbsp;&nbsp;&nbsp;browser:bottomline(browser:value())<br />
&nbsp;&nbsp;&nbsp;&nbsp;Fl:check()<br />
&nbsp;&nbsp;&nbsp;&nbsp;browser:value(browser:topline())<br />
elseif Fl:event_key() == fltk.FL_Page_Down then<br />
-- can't figure this one yet<br />
-- why can you use topline() without an argument, but not bottomline()?<br />
end<br />
end<br />
<br />
win = fltk:Fl_Window(400,500,"browser nav test")<br />
browser = fltk:Fl_Hold_Browser(0,0,400,500)<br />
browser_ctrl = fltk:Fl_Menu_Bar(400,500,10,10)<br />
browser_ctrl:add("home", fltk.FL_Home, nav_browser)<br />
browser_ctrl:add("end", fltk.FL_End, nav_browser)<br />
browser_ctrl:add("up", fltk.FL_Page_Up, nav_browser)<br />
browser_ctrl:add("down", fltk.FL_Page_Down, nav_browser)<br />
browser_ctrl:global()<br />
<br />
for line = 1,100 do browser:add("Line "..line) end<br />
<br />
win:show()<br />
Fl:run()<br />
<br />
]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[test: emulating 3D rotation]]></title>
			<link>http://www.murga-projects.com/forum/showthread.php?tid=410</link>
			<pubDate>Tue, 10 May 2011 19:10:08 -0600</pubDate>
			<guid isPermaLink="false">http://www.murga-projects.com/forum/showthread.php?tid=410</guid>
			<description><![CDATA[This is a test of an idea that just popped into my head.<br />
I sometimes make GIF animations of 3D models showing a 360-degree<br />
rotation of the model.  GIFs are limited, though, in that they can't be<br />
paused or reversed.  A video format could do this, but it's much easier<br />
just to do it the way it would be controlled in a 3D app, by dragging.<br />
<br />
With this project I'm attempting to emulate 3D rotation by using a series of<br />
images, which are changed according to the location of the mouse while dragging.<br />
<br />
The script reads a directory of images, which can be changed by dragging the<br />
mouse back a forth.  If your images are reversed (rotating right-to-left),<br />
using the middle or right mouse button will change the images in reverse,<br />
so it appears to drag the object in the proper direction.<br />
<br />
One day I might try to take it a step further by rotating vertically,<br />
but for now I'm okay with a simple turntable.  I'm thinking it could<br />
also be taken into other directions, such as making clickable hotspots<br />
or something like that, but that's also just a passing thought.<br />
[attachment=73]]]></description>
			<content:encoded><![CDATA[This is a test of an idea that just popped into my head.<br />
I sometimes make GIF animations of 3D models showing a 360-degree<br />
rotation of the model.  GIFs are limited, though, in that they can't be<br />
paused or reversed.  A video format could do this, but it's much easier<br />
just to do it the way it would be controlled in a 3D app, by dragging.<br />
<br />
With this project I'm attempting to emulate 3D rotation by using a series of<br />
images, which are changed according to the location of the mouse while dragging.<br />
<br />
The script reads a directory of images, which can be changed by dragging the<br />
mouse back a forth.  If your images are reversed (rotating right-to-left),<br />
using the middle or right mouse button will change the images in reverse,<br />
so it appears to drag the object in the proper direction.<br />
<br />
One day I might try to take it a step further by rotating vertically,<br />
but for now I'm okay with a simple turntable.  I'm thinking it could<br />
also be taken into other directions, such as making clickable hotspots<br />
or something like that, but that's also just a passing thought.<br />
[attachment=73]]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Interactive Fish interpreter]]></title>
			<link>http://www.murga-projects.com/forum/showthread.php?tid=409</link>
			<pubDate>Thu, 21 Apr 2011 03:09:04 -0600</pubDate>
			<guid isPermaLink="false">http://www.murga-projects.com/forum/showthread.php?tid=409</guid>
			<description><![CDATA[I'm having trouble creating a text editor, for creating sort of an interactive editor/interpreter for the Fish language.<br />
<br />
With Fluid, I've managed to generate the window etc, but in the textarea text can not be entered.<br />
<br />
The code:<br />
<br />
Code:<br />
-- Declaration of global variables<br />
make_window = make_window or nil<br />
win = {}<br />
function make_window()<br />
&nbsp;&nbsp;win.window = fltk:Fl_Double_Window(334, 210, 565, 355, "Fish interpreter")<br />
&nbsp;&nbsp;do<br />
&nbsp;&nbsp;&nbsp;&nbsp;win.edt_buffer = fltk:Fl_Text_Buffer()<br />
&nbsp;&nbsp;&nbsp;&nbsp;win.edt = fltk:Fl_Text_Editor(25, 25, 260, 280)<br />
&nbsp;&nbsp;&nbsp;&nbsp;win.edt:textfont(fltk.FL_SCREEN)<br />
&nbsp;&nbsp;&nbsp;&nbsp;win.edt:textsize(10) -- TODO un magic number<br />
&nbsp;&nbsp;&nbsp;&nbsp;win.edt:selection_color(fltk.FL_BLACK)<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;local o = fltk:Fl_Text_Display(285, 25, 260, 280)<br />
&nbsp;&nbsp;&nbsp;&nbsp;local o = fltk:Fl_Roller(135, 320, 55, 25, "Delay")<br />
&nbsp;&nbsp;&nbsp;&nbsp;o:align(4)<br />
&nbsp;&nbsp;&nbsp;&nbsp;o:step(0)<br />
&nbsp;&nbsp;&nbsp;&nbsp;local o = fltk:Fl_Value_Output(190, 320, 25, 25)<br />
&nbsp;&nbsp;&nbsp;&nbsp;local o = fltk:Fl_Button(215, 320, 70, 25, "Back")<br />
&nbsp;&nbsp;&nbsp;&nbsp;local o = fltk:Fl_Button(285, 320, 70, 25, "Step")<br />
&nbsp;&nbsp;&nbsp;&nbsp;local o = fltk:Fl_Return_Button(355, 320, 70, 25, "Run")<br />
&nbsp;&nbsp;end<br />
&nbsp;&nbsp;win.window['endd'](win.window)<br />
&nbsp;&nbsp;return win.window<br />
end<br />
<br />
for _,i in ipairs {make_window()} do i:show() end<br />
Fl:run()<br />
<br />
<br />
Any ideas how to solve this?<br />
<br />
Regards,<br />
<br />
Jan-Pieter]]></description>
			<content:encoded><![CDATA[I'm having trouble creating a text editor, for creating sort of an interactive editor/interpreter for the Fish language.<br />
<br />
With Fluid, I've managed to generate the window etc, but in the textarea text can not be entered.<br />
<br />
The code:<br />
<br />
Code:<br />
-- Declaration of global variables<br />
make_window = make_window or nil<br />
win = {}<br />
function make_window()<br />
&nbsp;&nbsp;win.window = fltk:Fl_Double_Window(334, 210, 565, 355, "Fish interpreter")<br />
&nbsp;&nbsp;do<br />
&nbsp;&nbsp;&nbsp;&nbsp;win.edt_buffer = fltk:Fl_Text_Buffer()<br />
&nbsp;&nbsp;&nbsp;&nbsp;win.edt = fltk:Fl_Text_Editor(25, 25, 260, 280)<br />
&nbsp;&nbsp;&nbsp;&nbsp;win.edt:textfont(fltk.FL_SCREEN)<br />
&nbsp;&nbsp;&nbsp;&nbsp;win.edt:textsize(10) -- TODO un magic number<br />
&nbsp;&nbsp;&nbsp;&nbsp;win.edt:selection_color(fltk.FL_BLACK)<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;local o = fltk:Fl_Text_Display(285, 25, 260, 280)<br />
&nbsp;&nbsp;&nbsp;&nbsp;local o = fltk:Fl_Roller(135, 320, 55, 25, "Delay")<br />
&nbsp;&nbsp;&nbsp;&nbsp;o:align(4)<br />
&nbsp;&nbsp;&nbsp;&nbsp;o:step(0)<br />
&nbsp;&nbsp;&nbsp;&nbsp;local o = fltk:Fl_Value_Output(190, 320, 25, 25)<br />
&nbsp;&nbsp;&nbsp;&nbsp;local o = fltk:Fl_Button(215, 320, 70, 25, "Back")<br />
&nbsp;&nbsp;&nbsp;&nbsp;local o = fltk:Fl_Button(285, 320, 70, 25, "Step")<br />
&nbsp;&nbsp;&nbsp;&nbsp;local o = fltk:Fl_Return_Button(355, 320, 70, 25, "Run")<br />
&nbsp;&nbsp;end<br />
&nbsp;&nbsp;win.window['endd'](win.window)<br />
&nbsp;&nbsp;return win.window<br />
end<br />
<br />
for _,i in ipairs {make_window()} do i:show() end<br />
Fl:run()<br />
<br />
<br />
Any ideas how to solve this?<br />
<br />
Regards,<br />
<br />
Jan-Pieter]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Any thoughts on a MurgaLua facebook page?]]></title>
			<link>http://www.murga-projects.com/forum/showthread.php?tid=408</link>
			<pubDate>Thu, 10 Feb 2011 08:28:09 -0700</pubDate>
			<guid isPermaLink="false">http://www.murga-projects.com/forum/showthread.php?tid=408</guid>
			<description><![CDATA[See thread title...I guess that's all I had to say.]]></description>
			<content:encoded><![CDATA[See thread title...I guess that's all I had to say.]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[another tile game clone]]></title>
			<link>http://www.murga-projects.com/forum/showthread.php?tid=407</link>
			<pubDate>Thu, 27 Jan 2011 09:41:14 -0700</pubDate>
			<guid isPermaLink="false">http://www.murga-projects.com/forum/showthread.php?tid=407</guid>
			<description><![CDATA[This one is a clone of the concentration/memory game where you have an array of overturned cards and you flip two at a time trying to match the image on them.  It was a whim, and I decided to see how quickly I could whip out a beta.<br />
<br />
The script grabs the first 24 images from a given directory and sets each image to two randomly selected tiles.  Click on two tiles, and if they match then the images stay visible and their buttons are disabled.  If they don't match, they are hidden again after half a second.<br />
<br />
The script is based around the use of 64px images, which on a Linux (and OS X?) system are easy to find in /usr/share/icons and /usr/share/pixmaps.  No idea if Windows still uses just *.ico icons or if they've also begun to include other formats.<br />
<br />
I want to include some default images in the future, but haven't bothered with that yet.  Also haven't bothered to check what happens if there are fewer than 24 usable images in the directory.<br />
<br />
Feel free to mess with this script if you want to make it better.<br />
<br />
<br />
Code:<br />
#!/usr/bin/env murgaLua<br />
-- concentration<br />
-- 2011 mikshaw<br />
<br />
ts = 100 -- tile size<br />
cols = 8 -- number of horizontal tiles<br />
rows = 6 -- vertical tiles<br />
img_dir = "/usr/share/icons/crystalsvg/64x64/apps/"<br />
<br />
function tile_cb(self)<br />
self:labeltype(fltk.FL_NORMAL_LABEL)<br />
if not first_tile then first_tile = self<br />
else<br />
&nbsp;&nbsp;moves = moves + 1<br />
&nbsp;&nbsp;if first_tile:tooltip() == self:tooltip() then<br />
&nbsp;&nbsp;&nbsp;&nbsp;first_tile:set_output()<br />
&nbsp;&nbsp;&nbsp;&nbsp;self:set_output()<br />
&nbsp;&nbsp;&nbsp;&nbsp;active = active - 2<br />
&nbsp;&nbsp;&nbsp;&nbsp;if active == 0 then fltk.fl_alert(moves.." moves") end<br />
&nbsp;&nbsp;else<br />
&nbsp;&nbsp;&nbsp;&nbsp;Fl:check()<br />
&nbsp;&nbsp;&nbsp;&nbsp;murgaLua.sleep(500)<br />
&nbsp;&nbsp;&nbsp;&nbsp;self:labeltype(fltk.FL_NO_LABEL) <br />
&nbsp;&nbsp;&nbsp;&nbsp;first_tile:labeltype(fltk.FL_NO_LABEL) <br />
&nbsp;&nbsp;&nbsp;&nbsp;win:redraw()<br />
&nbsp;&nbsp;end<br />
first_tile = nil<br />
end<br />
end<br />
<br />
used_numbers = "x"<br />
function unique_random()<br />
math.randomseed(os.time())<br />
local rand = math.random(0, rows * cols - 1)<br />
-- try again if number is already used<br />
while string.find(used_numbers, "x"..rand.."x") do<br />
rand = math.random(0, rows * cols - 1)<br />
end<br />
-- save used numbers in a string<br />
used_numbers = used_numbers..rand.."x"<br />
return rand<br />
end<br />
<br />
win = fltk:Fl_Double_Window(ts * cols , ts * rows, "Memory Game")<br />
<br />
tile = {}<br />
r, c = 0, 0 -- row and column positions<br />
for i = 0, rows * cols - 1 do<br />
&nbsp;&nbsp;tile[i] = fltk:Fl_Button(c, r, ts, ts)<br />
&nbsp;&nbsp;tile[i]:align(80)<br />
&nbsp;&nbsp;tile[i]:callback(tile_cb)<br />
&nbsp;&nbsp;c = c + ts<br />
&nbsp;&nbsp;-- start the next row<br />
&nbsp;&nbsp;if c == win:w() then c = 0; r = r + ts end<br />
end<br />
<br />
fltk.fl_register_images()<br />
<br />
-- apply images to random tiles<br />
-- two copies of each image<br />
count = 0<br />
img = {}<br />
for file in lfs.dir(img_dir) do<br />
&nbsp;&nbsp;if count &lt; cols * rows / 2 then -- stop grabbing images after tiles are filled<br />
&nbsp;&nbsp;&nbsp;&nbsp;img_check = Fl_Shared_Image.get(img_dir..file)<br />
&nbsp;&nbsp;&nbsp;&nbsp;if img_check then<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;img[count] = img_check<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;local first = unique_random() -- first instance of the image<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tile[first]:image(img[count])<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tile[first]:tooltip(file)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tile[first]:labeltype(fltk.FL_NO_LABEL)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;local second = unique_random() -- second instance<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tile[second]:image(img[count])<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tile[second]:tooltip(file)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tile[second]:labeltype(fltk.FL_NO_LABEL)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;count = count + 1<br />
&nbsp;&nbsp;&nbsp;&nbsp;end<br />
&nbsp;&nbsp;else break<br />
&nbsp;&nbsp;end<br />
end<br />
<br />
moves = 0<br />
active = rows * cols<br />
Fl_Tooltip:disable() -- tooltip values are used only to compare tiles<br />
win:show()<br />
Fl:run()<br />
<br />
]]></description>
			<content:encoded><![CDATA[This one is a clone of the concentration/memory game where you have an array of overturned cards and you flip two at a time trying to match the image on them.  It was a whim, and I decided to see how quickly I could whip out a beta.<br />
<br />
The script grabs the first 24 images from a given directory and sets each image to two randomly selected tiles.  Click on two tiles, and if they match then the images stay visible and their buttons are disabled.  If they don't match, they are hidden again after half a second.<br />
<br />
The script is based around the use of 64px images, which on a Linux (and OS X?) system are easy to find in /usr/share/icons and /usr/share/pixmaps.  No idea if Windows still uses just *.ico icons or if they've also begun to include other formats.<br />
<br />
I want to include some default images in the future, but haven't bothered with that yet.  Also haven't bothered to check what happens if there are fewer than 24 usable images in the directory.<br />
<br />
Feel free to mess with this script if you want to make it better.<br />
<br />
<br />
Code:<br />
#!/usr/bin/env murgaLua<br />
-- concentration<br />
-- 2011 mikshaw<br />
<br />
ts = 100 -- tile size<br />
cols = 8 -- number of horizontal tiles<br />
rows = 6 -- vertical tiles<br />
img_dir = "/usr/share/icons/crystalsvg/64x64/apps/"<br />
<br />
function tile_cb(self)<br />
self:labeltype(fltk.FL_NORMAL_LABEL)<br />
if not first_tile then first_tile = self<br />
else<br />
&nbsp;&nbsp;moves = moves + 1<br />
&nbsp;&nbsp;if first_tile:tooltip() == self:tooltip() then<br />
&nbsp;&nbsp;&nbsp;&nbsp;first_tile:set_output()<br />
&nbsp;&nbsp;&nbsp;&nbsp;self:set_output()<br />
&nbsp;&nbsp;&nbsp;&nbsp;active = active - 2<br />
&nbsp;&nbsp;&nbsp;&nbsp;if active == 0 then fltk.fl_alert(moves.." moves") end<br />
&nbsp;&nbsp;else<br />
&nbsp;&nbsp;&nbsp;&nbsp;Fl:check()<br />
&nbsp;&nbsp;&nbsp;&nbsp;murgaLua.sleep(500)<br />
&nbsp;&nbsp;&nbsp;&nbsp;self:labeltype(fltk.FL_NO_LABEL) <br />
&nbsp;&nbsp;&nbsp;&nbsp;first_tile:labeltype(fltk.FL_NO_LABEL) <br />
&nbsp;&nbsp;&nbsp;&nbsp;win:redraw()<br />
&nbsp;&nbsp;end<br />
first_tile = nil<br />
end<br />
end<br />
<br />
used_numbers = "x"<br />
function unique_random()<br />
math.randomseed(os.time())<br />
local rand = math.random(0, rows * cols - 1)<br />
-- try again if number is already used<br />
while string.find(used_numbers, "x"..rand.."x") do<br />
rand = math.random(0, rows * cols - 1)<br />
end<br />
-- save used numbers in a string<br />
used_numbers = used_numbers..rand.."x"<br />
return rand<br />
end<br />
<br />
win = fltk:Fl_Double_Window(ts * cols , ts * rows, "Memory Game")<br />
<br />
tile = {}<br />
r, c = 0, 0 -- row and column positions<br />
for i = 0, rows * cols - 1 do<br />
&nbsp;&nbsp;tile[i] = fltk:Fl_Button(c, r, ts, ts)<br />
&nbsp;&nbsp;tile[i]:align(80)<br />
&nbsp;&nbsp;tile[i]:callback(tile_cb)<br />
&nbsp;&nbsp;c = c + ts<br />
&nbsp;&nbsp;-- start the next row<br />
&nbsp;&nbsp;if c == win:w() then c = 0; r = r + ts end<br />
end<br />
<br />
fltk.fl_register_images()<br />
<br />
-- apply images to random tiles<br />
-- two copies of each image<br />
count = 0<br />
img = {}<br />
for file in lfs.dir(img_dir) do<br />
&nbsp;&nbsp;if count &lt; cols * rows / 2 then -- stop grabbing images after tiles are filled<br />
&nbsp;&nbsp;&nbsp;&nbsp;img_check = Fl_Shared_Image.get(img_dir..file)<br />
&nbsp;&nbsp;&nbsp;&nbsp;if img_check then<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;img[count] = img_check<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;local first = unique_random() -- first instance of the image<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tile[first]:image(img[count])<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tile[first]:tooltip(file)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tile[first]:labeltype(fltk.FL_NO_LABEL)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;local second = unique_random() -- second instance<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tile[second]:image(img[count])<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tile[second]:tooltip(file)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tile[second]:labeltype(fltk.FL_NO_LABEL)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;count = count + 1<br />
&nbsp;&nbsp;&nbsp;&nbsp;end<br />
&nbsp;&nbsp;else break<br />
&nbsp;&nbsp;end<br />
end<br />
<br />
moves = 0<br />
active = rows * cols<br />
Fl_Tooltip:disable() -- tooltip values are used only to compare tiles<br />
win:show()<br />
Fl:run()<br />
<br />
]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[cross compileMurgaLua?]]></title>
			<link>http://www.murga-projects.com/forum/showthread.php?tid=406</link>
			<pubDate>Tue, 18 Jan 2011 18:40:32 -0700</pubDate>
			<guid isPermaLink="false">http://www.murga-projects.com/forum/showthread.php?tid=406</guid>
			<description><![CDATA[Is compileMurgaLua intended to work regardless of your platform?  I tried a test of compiling a Windows file on Linux, and it seems it doesn't work.<br />
<br />
<br />
Code:<br />
lua&gt; murgaLua.compileMurgaLua("/home/deb/bin/puzzle.lua","bin/Windows/core-lite/murgaLua_lite.exe","puzzle.exe")<br />
MurgaLua compiler 1.0<br />
=====================<br />
Loading core murgaLua executable ...<br />
Binding compressed code ...<br />
Writing executable stub info ...<br />
Done !!<br />
lua&gt;<br />
<br />
bash&#36; file puzzle.exe<br />
puzzle.exe: PE32 executable for MS Windows (console) Intel 80386 32-bit<br />
<br />
That looks like it worked, but then I got this when running it with Wine:<br />
<br />
Code:<br />
bash&#36; wine puzzle.exe <br />
err:menubuilder:WinMain unknown option -a<br />
err:menubuilder:WinMain unknown option -r<br />
puzzle.exe: ?:0: attempt to call global 'newFunc' (a nil value)<br />
stack traceback:<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;?: in function 'decompileMurgaLua'<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[string ""]:1: in main chunk<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[C]: ?<br />
MurgaLua Version 0.7.0 (http://www.murga-projects.com/murgaLua/)<br />
MurgaLua &amp; FLTK/XML bindings : Copyright 2006-9 John Murga, GPL license.<br />
Contains lsqlite by T.Dionizio, LuaSocket by D.Nehab and other bindings.<br />
Lua 5.1.4&nbsp;&nbsp;Copyright (C) 1994-2008 Lua.org, PUC-Rio<br />
lua&gt; print(murgaLua.getHostOsName())<br />
windows<br />
lua&gt;<br />
err:ole:CoUninitialize Mismatched CoUninitialize<br />
<br />
That last line was printed after exiting the Lua prompt<br />
<br />
Granted I can see that there might be issues with Wine, but this was just a quick test.  I was hoping I could find out whether or not I'm wasting my time when I should intead be testing it on a Windows machine with a Windows version of MurgaLua.]]></description>
			<content:encoded><![CDATA[Is compileMurgaLua intended to work regardless of your platform?  I tried a test of compiling a Windows file on Linux, and it seems it doesn't work.<br />
<br />
<br />
Code:<br />
lua&gt; murgaLua.compileMurgaLua("/home/deb/bin/puzzle.lua","bin/Windows/core-lite/murgaLua_lite.exe","puzzle.exe")<br />
MurgaLua compiler 1.0<br />
=====================<br />
Loading core murgaLua executable ...<br />
Binding compressed code ...<br />
Writing executable stub info ...<br />
Done !!<br />
lua&gt;<br />
<br />
bash&#36; file puzzle.exe<br />
puzzle.exe: PE32 executable for MS Windows (console) Intel 80386 32-bit<br />
<br />
That looks like it worked, but then I got this when running it with Wine:<br />
<br />
Code:<br />
bash&#36; wine puzzle.exe <br />
err:menubuilder:WinMain unknown option -a<br />
err:menubuilder:WinMain unknown option -r<br />
puzzle.exe: ?:0: attempt to call global 'newFunc' (a nil value)<br />
stack traceback:<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;?: in function 'decompileMurgaLua'<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[string ""]:1: in main chunk<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[C]: ?<br />
MurgaLua Version 0.7.0 (http://www.murga-projects.com/murgaLua/)<br />
MurgaLua &amp; FLTK/XML bindings : Copyright 2006-9 John Murga, GPL license.<br />
Contains lsqlite by T.Dionizio, LuaSocket by D.Nehab and other bindings.<br />
Lua 5.1.4&nbsp;&nbsp;Copyright (C) 1994-2008 Lua.org, PUC-Rio<br />
lua&gt; print(murgaLua.getHostOsName())<br />
windows<br />
lua&gt;<br />
err:ole:CoUninitialize Mismatched CoUninitialize<br />
<br />
That last line was printed after exiting the Lua prompt<br />
<br />
Granted I can see that there might be issues with Wine, but this was just a quick test.  I was hoping I could find out whether or not I'm wasting my time when I should intead be testing it on a Windows machine with a Windows version of MurgaLua.]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[puzzle remix]]></title>
			<link>http://www.murga-projects.com/forum/showthread.php?tid=405</link>
			<pubDate>Fri, 07 Jan 2011 10:17:14 -0700</pubDate>
			<guid isPermaLink="false">http://www.murga-projects.com/forum/showthread.php?tid=405</guid>
			<description><![CDATA[Remixed the slide puzzle into something more closely resembling a jigsaw puzzle, giving a little different gameplay, and making the code a little lighter and less complex...scrambling is less restricted, there's no swapping of images, and images don't have to be scaled to preset dimensions.<br />
<br />
It still needs work.  Some images, particularly GIFs, don't tile properly, and I had to be cautious about how scaling is done so images with prime numbers as height or width don't create a billion tiles.<br />
<br />
The scaling especially needs work.   Ideally I'd like to not scale the image at all and just scale the tiles to fit the image, but there seems to be a problem with using floating point numbers in scaling and/or tiling.  So for now it scales the image only enough to fit within a grid determined by the size of the tiles.  It still results in some crunchy pixels.<br />
<br />
I'd tried cropping the image instead of scaling, by using fl_read_image, but it seems I've completely forgotten how that works.<br />
<br />
<br />
Code:<br />
old stuff removed<br />
<br />
<br />
new stuff...<br />
<br />
Code:<br />
#!/usr/bin/env murgaLua<br />
<br />
-- jigsaw-like puzzle for MurgaLua 0.6.4+<br />
-- 2011 mikshaw<br />
<br />
ts = 64 --tile size<br />
<br />
function err(e,r)<br />
if fltk then fltk.fl_alert(e) else print(e) end<br />
os.exit(r)<br />
end<br />
<br />
if not Fl_Image.getTiles then<br />
err("This program requires murgaLua 0.6.4 or newer.&#92;n&#92;n"..<br />
&nbsp;&nbsp;&nbsp;&nbsp;"http://www.murga-projects.com/murgaLua/index.html", 1)<br />
end<br />
<br />
fileName = arg[1] -- if filename given as cmdline argument<br />
-- browse for file<br />
fltk.fl_register_images() -- do this early so chooser can show preview<br />
if not fileName then<br />
fileName = fltk.fl_file_chooser("Choose an RGB image", "Image Files (*.{jpg,png,bmp,xbm,xpm,gif})", nil, nil)<br />
end<br />
if not fileName then<br />
err("Please supply an image filename.&#92;nUse: "..<br />
&nbsp;&nbsp;&nbsp;&nbsp;fltk.fl_filename_name(arg[0]).." &#92;"filename&#92;"&#92;n"..<br />
&nbsp;&nbsp;&nbsp;&nbsp;"or select an image with the file chooser." , 2)<br />
end<br />
<br />
-- check image<br />
img = Fl_Shared_Image.get(fileName)<br />
if not img then err("Could not open "..fileName, 3) end<br />
iw = img:w(); ih = img:h()<br />
<br />
-- try to find a balance between image size and tile size<br />
if iw % ts == 0 and ih % ts == 0 then<br />
&nbsp;&nbsp;tw, th = ts, ts<br />
&nbsp;&nbsp;cols = iw / ts<br />
&nbsp;&nbsp;rows = ih / ts<br />
else<br />
&nbsp;&nbsp;cols = math.floor(iw / ts)<br />
&nbsp;&nbsp;rows = math.floor(ih / ts)<br />
&nbsp;&nbsp;tw = math.floor(iw / cols)<br />
&nbsp;&nbsp;th = math.floor(ih / rows)<br />
&nbsp;&nbsp;iw = cols * tw<br />
&nbsp;&nbsp;ih = rows * th<br />
end<br />
<br />
function set_tile_images()<br />
-- take a crop of the box image <br />
win:make_current()<br />
imageString = fltk.fl_read_image(0, 0, iw, ih, 0)<br />
image = fltk:Fl_RGB_Image(imageString, iw, ih, 3)<br />
<br />
-- tile it up<br />
imgtiles = image:getTiles(tw,th)<br />
for i,_ in pairs(tile) do<br />
&nbsp;&nbsp;tile[i]:image(imgtiles[i+1])<br />
end<br />
box:image(image)<br />
box:hide()<br />
end<br />
<br />
function scramble()<br />
math.randomseed(os.time())<br />
for scram = 1, 10000 do<br />
&nbsp;&nbsp;local a = math.random(0, rows * cols - 1)<br />
&nbsp;&nbsp;tile_A_x = tile[a]:x(); tile_A_y = tile[a]:y()<br />
&nbsp;&nbsp;local b = math.random(0, rows * cols - 1)<br />
&nbsp;&nbsp;tile[a]:position(tile[b]:x(), tile[b]:y())<br />
&nbsp;&nbsp;tile[b]:position(tile_A_x, tile_A_y)<br />
end<br />
end<br />
<br />
function secondsToClock(sSeconds)<br />
-- TJ_Tigger from http://www.indigorose.com/forums/archive/index.php/t-14669.html<br />
local nSeconds = tonumber(sSeconds)<br />
if nSeconds == 0 then<br />
return "00:00:00";<br />
else<br />
nHours = string.format("%02.f", math.floor(nSeconds/3600));<br />
nMins = string.format("%02.f", math.floor(nSeconds/60 - (nHours*60)));<br />
nSecs = string.format("%02.f", math.floor(nSeconds - nHours*3600 - nMins *60));<br />
return nHours..":"..nMins..":"..nSecs<br />
end<br />
end<br />
<br />
function drag_loop()<br />
&nbsp;&nbsp;if inplay == 1 then<br />
&nbsp;&nbsp;&nbsp;&nbsp;drag_box:position(Fl:event_x() - tw / 2, Fl:event_y() - th / 2)<br />
&nbsp;&nbsp;&nbsp;&nbsp;win:redraw()<br />
&nbsp;&nbsp;end<br />
&nbsp;&nbsp;drag_timer:doWait(.02)<br />
end<br />
<br />
function isitfinish()<br />
for i = 0, rows * cols - 1 do<br />
&nbsp;&nbsp;if tile[i]:x() ~= pos[i].col or tile[i]:y() ~= pos[i].row then<br />
&nbsp;&nbsp;return end<br />
end<br />
for i,_ in pairs(tile) do<br />
&nbsp;&nbsp;tile[i]:hide()<br />
end<br />
preview:hide()<br />
box:show()<br />
if not seconds then<br />
&nbsp;&nbsp;seconds = os.time() - starttime<br />
&nbsp;&nbsp;fltk.fl_message("time: "..secondsToClock(seconds).."&#92;n"..moves.." moves")<br />
end<br />
end<br />
<br />
function move_tile(t)<br />
if inplay == 0 then<br />
&nbsp;&nbsp;if not starttime then starttime = os.time()&nbsp;&nbsp;end<br />
&nbsp;&nbsp;inplay = 1<br />
&nbsp;&nbsp;drag_box:show()<br />
&nbsp;&nbsp;from_t, from_x, from_y = t, t:x(), t:y()<br />
&nbsp;&nbsp;drag_box:image(t:image())<br />
&nbsp;&nbsp;t:labeltype(fltk.FL_NO_LABEL)<br />
&nbsp;&nbsp;t:box(fltk.FL_DOWN_BOX)<br />
else<br />
&nbsp;&nbsp;inplay = 0<br />
&nbsp;&nbsp;from_t:labeltype(fltk.FL_NORMAL_LABEL)<br />
&nbsp;&nbsp;from_t:box(fltk.FL_NO_BOX)<br />
&nbsp;&nbsp;if from_t:x() ~= t:x() or from_t:y() ~= t:y() then<br />
&nbsp;&nbsp;&nbsp;&nbsp;from_t:position(t:x(),t:y())<br />
&nbsp;&nbsp;&nbsp;&nbsp;t:position(from_x, from_y)<br />
&nbsp;&nbsp;&nbsp;&nbsp;moves = moves + 1<br />
&nbsp;&nbsp;end<br />
&nbsp;&nbsp;drag_box:hide()<br />
&nbsp;&nbsp;win:redraw()<br />
&nbsp;&nbsp;isitfinish()<br />
end<br />
end<br />
<br />
fs, moves, starttime, seconds = 0, 0, nil, nil<br />
Fl:visible_focus(0)<br />
timer = murgaLua.createFltkTimer()<br />
timer:callback(set_tile_images)<br />
<br />
<br />
win = fltk:Fl_Double_Window(iw,ih, fltk.fl_filename_name(fileName))<br />
<br />
tile = {}; pos = {}<br />
row = 0; col = 0<br />
-- -1 is used because the number of tiles starts at 1<br />
-- but table starts at 0 (easier to position them from zero)<br />
for i = 0, rows * cols - 1 do<br />
&nbsp;&nbsp;tile[i] = fltk:Fl_Button(col,row,tw,th)<br />
&nbsp;&nbsp;tile[i]:box(fltk.FL_NO_BOX)<br />
&nbsp;&nbsp;tile[i]:align(80)<br />
&nbsp;&nbsp;tile[i]:callback(move_tile)<br />
&nbsp;&nbsp;pos[i]={col=col, row=row} <br />
&nbsp;&nbsp;col = col + tw<br />
&nbsp;&nbsp;-- start the next row<br />
&nbsp;&nbsp;if col == iw then col = 0; row = row + th end<br />
end<br />
<br />
drag_box = fltk:Fl_Box(0,0,tw,th)<br />
drag_box:hide()<br />
drag_timer = murgaLua.createFltkTimer()<br />
drag_timer:callback(drag_loop)<br />
drag_timer:do_callback()<br />
inplay = 0<br />
<br />
preview = fltk:Fl_Button(-10,-10,1,1)<br />
preview:shortcut("p")<br />
preview:callback(<br />
function()<br />
if box:visible() == 1 then box:hide() else box:show() end<br />
end<br />
)<br />
<br />
if iw &lt;= Fl:w() and ih &lt;= Fl:h() then<br />
fullscr = fltk:Fl_Button(-10,-10,1,1)<br />
fullscr:shortcut("f")<br />
fullscr:callback(<br />
function()<br />
if fs == 0 then<br />
&nbsp;&nbsp;fs = 1<br />
&nbsp;&nbsp;wx, wy = win:x(), win:y()<br />
&nbsp;&nbsp;win:fullscreen()<br />
else<br />
&nbsp;&nbsp;fs = 0<br />
&nbsp;&nbsp;win:resize(wx,wy,iw,ih)<br />
end<br />
end<br />
)<br />
end<br />
<br />
box = fltk:Fl_Box(0,0,iw,ih)<br />
box:image(img)<br />
win:show()<br />
timer:doWait(1)<br />
scramble()<br />
Fl:run()<br />
<br />
]]></description>
			<content:encoded><![CDATA[Remixed the slide puzzle into something more closely resembling a jigsaw puzzle, giving a little different gameplay, and making the code a little lighter and less complex...scrambling is less restricted, there's no swapping of images, and images don't have to be scaled to preset dimensions.<br />
<br />
It still needs work.  Some images, particularly GIFs, don't tile properly, and I had to be cautious about how scaling is done so images with prime numbers as height or width don't create a billion tiles.<br />
<br />
The scaling especially needs work.   Ideally I'd like to not scale the image at all and just scale the tiles to fit the image, but there seems to be a problem with using floating point numbers in scaling and/or tiling.  So for now it scales the image only enough to fit within a grid determined by the size of the tiles.  It still results in some crunchy pixels.<br />
<br />
I'd tried cropping the image instead of scaling, by using fl_read_image, but it seems I've completely forgotten how that works.<br />
<br />
<br />
Code:<br />
old stuff removed<br />
<br />
<br />
new stuff...<br />
<br />
Code:<br />
#!/usr/bin/env murgaLua<br />
<br />
-- jigsaw-like puzzle for MurgaLua 0.6.4+<br />
-- 2011 mikshaw<br />
<br />
ts = 64 --tile size<br />
<br />
function err(e,r)<br />
if fltk then fltk.fl_alert(e) else print(e) end<br />
os.exit(r)<br />
end<br />
<br />
if not Fl_Image.getTiles then<br />
err("This program requires murgaLua 0.6.4 or newer.&#92;n&#92;n"..<br />
&nbsp;&nbsp;&nbsp;&nbsp;"http://www.murga-projects.com/murgaLua/index.html", 1)<br />
end<br />
<br />
fileName = arg[1] -- if filename given as cmdline argument<br />
-- browse for file<br />
fltk.fl_register_images() -- do this early so chooser can show preview<br />
if not fileName then<br />
fileName = fltk.fl_file_chooser("Choose an RGB image", "Image Files (*.{jpg,png,bmp,xbm,xpm,gif})", nil, nil)<br />
end<br />
if not fileName then<br />
err("Please supply an image filename.&#92;nUse: "..<br />
&nbsp;&nbsp;&nbsp;&nbsp;fltk.fl_filename_name(arg[0]).." &#92;"filename&#92;"&#92;n"..<br />
&nbsp;&nbsp;&nbsp;&nbsp;"or select an image with the file chooser." , 2)<br />
end<br />
<br />
-- check image<br />
img = Fl_Shared_Image.get(fileName)<br />
if not img then err("Could not open "..fileName, 3) end<br />
iw = img:w(); ih = img:h()<br />
<br />
-- try to find a balance between image size and tile size<br />
if iw % ts == 0 and ih % ts == 0 then<br />
&nbsp;&nbsp;tw, th = ts, ts<br />
&nbsp;&nbsp;cols = iw / ts<br />
&nbsp;&nbsp;rows = ih / ts<br />
else<br />
&nbsp;&nbsp;cols = math.floor(iw / ts)<br />
&nbsp;&nbsp;rows = math.floor(ih / ts)<br />
&nbsp;&nbsp;tw = math.floor(iw / cols)<br />
&nbsp;&nbsp;th = math.floor(ih / rows)<br />
&nbsp;&nbsp;iw = cols * tw<br />
&nbsp;&nbsp;ih = rows * th<br />
end<br />
<br />
function set_tile_images()<br />
-- take a crop of the box image <br />
win:make_current()<br />
imageString = fltk.fl_read_image(0, 0, iw, ih, 0)<br />
image = fltk:Fl_RGB_Image(imageString, iw, ih, 3)<br />
<br />
-- tile it up<br />
imgtiles = image:getTiles(tw,th)<br />
for i,_ in pairs(tile) do<br />
&nbsp;&nbsp;tile[i]:image(imgtiles[i+1])<br />
end<br />
box:image(image)<br />
box:hide()<br />
end<br />
<br />
function scramble()<br />
math.randomseed(os.time())<br />
for scram = 1, 10000 do<br />
&nbsp;&nbsp;local a = math.random(0, rows * cols - 1)<br />
&nbsp;&nbsp;tile_A_x = tile[a]:x(); tile_A_y = tile[a]:y()<br />
&nbsp;&nbsp;local b = math.random(0, rows * cols - 1)<br />
&nbsp;&nbsp;tile[a]:position(tile[b]:x(), tile[b]:y())<br />
&nbsp;&nbsp;tile[b]:position(tile_A_x, tile_A_y)<br />
end<br />
end<br />
<br />
function secondsToClock(sSeconds)<br />
-- TJ_Tigger from http://www.indigorose.com/forums/archive/index.php/t-14669.html<br />
local nSeconds = tonumber(sSeconds)<br />
if nSeconds == 0 then<br />
return "00:00:00";<br />
else<br />
nHours = string.format("%02.f", math.floor(nSeconds/3600));<br />
nMins = string.format("%02.f", math.floor(nSeconds/60 - (nHours*60)));<br />
nSecs = string.format("%02.f", math.floor(nSeconds - nHours*3600 - nMins *60));<br />
return nHours..":"..nMins..":"..nSecs<br />
end<br />
end<br />
<br />
function drag_loop()<br />
&nbsp;&nbsp;if inplay == 1 then<br />
&nbsp;&nbsp;&nbsp;&nbsp;drag_box:position(Fl:event_x() - tw / 2, Fl:event_y() - th / 2)<br />
&nbsp;&nbsp;&nbsp;&nbsp;win:redraw()<br />
&nbsp;&nbsp;end<br />
&nbsp;&nbsp;drag_timer:doWait(.02)<br />
end<br />
<br />
function isitfinish()<br />
for i = 0, rows * cols - 1 do<br />
&nbsp;&nbsp;if tile[i]:x() ~= pos[i].col or tile[i]:y() ~= pos[i].row then<br />
&nbsp;&nbsp;return end<br />
end<br />
for i,_ in pairs(tile) do<br />
&nbsp;&nbsp;tile[i]:hide()<br />
end<br />
preview:hide()<br />
box:show()<br />
if not seconds then<br />
&nbsp;&nbsp;seconds = os.time() - starttime<br />
&nbsp;&nbsp;fltk.fl_message("time: "..secondsToClock(seconds).."&#92;n"..moves.." moves")<br />
end<br />
end<br />
<br />
function move_tile(t)<br />
if inplay == 0 then<br />
&nbsp;&nbsp;if not starttime then starttime = os.time()&nbsp;&nbsp;end<br />
&nbsp;&nbsp;inplay = 1<br />
&nbsp;&nbsp;drag_box:show()<br />
&nbsp;&nbsp;from_t, from_x, from_y = t, t:x(), t:y()<br />
&nbsp;&nbsp;drag_box:image(t:image())<br />
&nbsp;&nbsp;t:labeltype(fltk.FL_NO_LABEL)<br />
&nbsp;&nbsp;t:box(fltk.FL_DOWN_BOX)<br />
else<br />
&nbsp;&nbsp;inplay = 0<br />
&nbsp;&nbsp;from_t:labeltype(fltk.FL_NORMAL_LABEL)<br />
&nbsp;&nbsp;from_t:box(fltk.FL_NO_BOX)<br />
&nbsp;&nbsp;if from_t:x() ~= t:x() or from_t:y() ~= t:y() then<br />
&nbsp;&nbsp;&nbsp;&nbsp;from_t:position(t:x(),t:y())<br />
&nbsp;&nbsp;&nbsp;&nbsp;t:position(from_x, from_y)<br />
&nbsp;&nbsp;&nbsp;&nbsp;moves = moves + 1<br />
&nbsp;&nbsp;end<br />
&nbsp;&nbsp;drag_box:hide()<br />
&nbsp;&nbsp;win:redraw()<br />
&nbsp;&nbsp;isitfinish()<br />
end<br />
end<br />
<br />
fs, moves, starttime, seconds = 0, 0, nil, nil<br />
Fl:visible_focus(0)<br />
timer = murgaLua.createFltkTimer()<br />
timer:callback(set_tile_images)<br />
<br />
<br />
win = fltk:Fl_Double_Window(iw,ih, fltk.fl_filename_name(fileName))<br />
<br />
tile = {}; pos = {}<br />
row = 0; col = 0<br />
-- -1 is used because the number of tiles starts at 1<br />
-- but table starts at 0 (easier to position them from zero)<br />
for i = 0, rows * cols - 1 do<br />
&nbsp;&nbsp;tile[i] = fltk:Fl_Button(col,row,tw,th)<br />
&nbsp;&nbsp;tile[i]:box(fltk.FL_NO_BOX)<br />
&nbsp;&nbsp;tile[i]:align(80)<br />
&nbsp;&nbsp;tile[i]:callback(move_tile)<br />
&nbsp;&nbsp;pos[i]={col=col, row=row} <br />
&nbsp;&nbsp;col = col + tw<br />
&nbsp;&nbsp;-- start the next row<br />
&nbsp;&nbsp;if col == iw then col = 0; row = row + th end<br />
end<br />
<br />
drag_box = fltk:Fl_Box(0,0,tw,th)<br />
drag_box:hide()<br />
drag_timer = murgaLua.createFltkTimer()<br />
drag_timer:callback(drag_loop)<br />
drag_timer:do_callback()<br />
inplay = 0<br />
<br />
preview = fltk:Fl_Button(-10,-10,1,1)<br />
preview:shortcut("p")<br />
preview:callback(<br />
function()<br />
if box:visible() == 1 then box:hide() else box:show() end<br />
end<br />
)<br />
<br />
if iw &lt;= Fl:w() and ih &lt;= Fl:h() then<br />
fullscr = fltk:Fl_Button(-10,-10,1,1)<br />
fullscr:shortcut("f")<br />
fullscr:callback(<br />
function()<br />
if fs == 0 then<br />
&nbsp;&nbsp;fs = 1<br />
&nbsp;&nbsp;wx, wy = win:x(), win:y()<br />
&nbsp;&nbsp;win:fullscreen()<br />
else<br />
&nbsp;&nbsp;fs = 0<br />
&nbsp;&nbsp;win:resize(wx,wy,iw,ih)<br />
end<br />
end<br />
)<br />
end<br />
<br />
box = fltk:Fl_Box(0,0,iw,ih)<br />
box:image(img)<br />
win:show()<br />
timer:doWait(1)<br />
scramble()<br />
Fl:run()<br />
<br />
]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[converting seconds to %H:%M:%S]]></title>
			<link>http://www.murga-projects.com/forum/showthread.php?tid=404</link>
			<pubDate>Fri, 07 Jan 2011 08:55:47 -0700</pubDate>
			<guid isPermaLink="false">http://www.murga-projects.com/forum/showthread.php?tid=404</guid>
			<description><![CDATA[Maybe this has already been asked?  I don't recall.<br />
It seems like there's something wrong here...when I attempt to use os.date() to convert seconds into hours:minutes:seconds, the minutes and seconds work, but hours always displays 19 instead of 00.<br />
<br />
The first button gets the current Posix time string.<br />
The second button gets a new time string (assuming you paused after clicking the first button), subtracts the first time string from that, and then is supposed to convert the difference into %T format (a.k.a. %H:%M:%S).  That conversion is where my problem lies...it looks like this should have been easy.<br />
<br />
<br />
<br />
Code:<br />
#!/usr/bin/env murgaLua<br />
<br />
win = fltk:Fl_Window(400, 300, "os.date(), os.time()")<br />
<br />
start_button = fltk:Fl_Button(10, 10, 200, 25, "start")<br />
starttime_display = fltk:Fl_Box(220, 10, 200, 25, "start time")<br />
start_button:callback(<br />
&nbsp;&nbsp;function()<br />
&nbsp;&nbsp;&nbsp;&nbsp;starttime = os.time()<br />
&nbsp;&nbsp;&nbsp;&nbsp;starttime_display:label(starttime)<br />
&nbsp;&nbsp;&nbsp;&nbsp;endtime_display:label("end time")<br />
&nbsp;&nbsp;end<br />
)<br />
<br />
end_button = fltk:Fl_Button(10, 40, 200, 25, "stop")<br />
endtime_display = fltk:Fl_Box(220, 40, 200, 25, "end time")<br />
end_button:callback(<br />
&nbsp;&nbsp;function()<br />
&nbsp;&nbsp;&nbsp;&nbsp;endtime = os.time()<br />
&nbsp;&nbsp;&nbsp;&nbsp;elapsed = endtime - starttime<br />
&nbsp;&nbsp;&nbsp;&nbsp;endtime_display:label(endtime)<br />
&nbsp;&nbsp;&nbsp;&nbsp;elapsed_display:label(os.date("%T", elapsed))<br />
--&nbsp;&nbsp;&nbsp;&nbsp;elapsed_display:label(os.date("%H:%M:%S", elapsed))<br />
&nbsp;&nbsp;end<br />
)<br />
<br />
elapsed_display = fltk:Fl_Box(220, 80, 200, 200, "time elapsed")<br />
<br />
win:show()<br />
Fl:run()<br />
<br />
<br />
Trying to be better at using whitespace...even though it adds a few bytes, it's easier to read =o)]]></description>
			<content:encoded><![CDATA[Maybe this has already been asked?  I don't recall.<br />
It seems like there's something wrong here...when I attempt to use os.date() to convert seconds into hours:minutes:seconds, the minutes and seconds work, but hours always displays 19 instead of 00.<br />
<br />
The first button gets the current Posix time string.<br />
The second button gets a new time string (assuming you paused after clicking the first button), subtracts the first time string from that, and then is supposed to convert the difference into %T format (a.k.a. %H:%M:%S).  That conversion is where my problem lies...it looks like this should have been easy.<br />
<br />
<br />
<br />
Code:<br />
#!/usr/bin/env murgaLua<br />
<br />
win = fltk:Fl_Window(400, 300, "os.date(), os.time()")<br />
<br />
start_button = fltk:Fl_Button(10, 10, 200, 25, "start")<br />
starttime_display = fltk:Fl_Box(220, 10, 200, 25, "start time")<br />
start_button:callback(<br />
&nbsp;&nbsp;function()<br />
&nbsp;&nbsp;&nbsp;&nbsp;starttime = os.time()<br />
&nbsp;&nbsp;&nbsp;&nbsp;starttime_display:label(starttime)<br />
&nbsp;&nbsp;&nbsp;&nbsp;endtime_display:label("end time")<br />
&nbsp;&nbsp;end<br />
)<br />
<br />
end_button = fltk:Fl_Button(10, 40, 200, 25, "stop")<br />
endtime_display = fltk:Fl_Box(220, 40, 200, 25, "end time")<br />
end_button:callback(<br />
&nbsp;&nbsp;function()<br />
&nbsp;&nbsp;&nbsp;&nbsp;endtime = os.time()<br />
&nbsp;&nbsp;&nbsp;&nbsp;elapsed = endtime - starttime<br />
&nbsp;&nbsp;&nbsp;&nbsp;endtime_display:label(endtime)<br />
&nbsp;&nbsp;&nbsp;&nbsp;elapsed_display:label(os.date("%T", elapsed))<br />
--&nbsp;&nbsp;&nbsp;&nbsp;elapsed_display:label(os.date("%H:%M:%S", elapsed))<br />
&nbsp;&nbsp;end<br />
)<br />
<br />
elapsed_display = fltk:Fl_Box(220, 80, 200, 200, "time elapsed")<br />
<br />
win:show()<br />
Fl:run()<br />
<br />
<br />
Trying to be better at using whitespace...even though it adds a few bytes, it's easier to read =o)]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[slide puzzle]]></title>
			<link>http://www.murga-projects.com/forum/showthread.php?tid=403</link>
			<pubDate>Tue, 04 Jan 2011 19:53:02 -0700</pubDate>
			<guid isPermaLink="false">http://www.murga-projects.com/forum/showthread.php?tid=403</guid>
			<description><![CDATA[Dug out the slide puzzle I was working on a couple of years ago, and made a couple of changes.  It will now accept commandline options to set the image width (-iw ) and tile count (-tc ).  Tile count is the number of tiles along one edge, so it's image width divided by tile count equals tile width.  If the tile count can't be divided evenly into the image width, something was messing up, so rather than try to figure out what was happening I made it so it will just shrink the image width to make it even.<br />
<br />
You can also set keys to control tile movement.  If they're not set they will default to arrows.<br />
<br />
I don't know what else might be different from the last time i posted it...it's been a while.  One thing I did forget is that I wanted to make an option to disable setting the hotkeys if you only use the mouse, since it has to reset the hot buttons every time you move a tile.<br />
<br />
EDIT 2011-01-09: replaced Fl_Image:getTiles() with a fl_read_image() loop<br />
<br />
<br />
Code:<br />
#!/usr/bin/env murgaLua<br />
<br />
-- slide puzzle for MurgaLua 0.6.4+<br />
-- 2008-2011 mikshaw<br />
<br />
<br />
-- window and tile size are determined by these variables<br />
-- tile size = iw/tc (image size will be adjusted if it doesn't divide evenly)<br />
iw=600&nbsp;&nbsp;-- image width<br />
tc=5&nbsp;&nbsp;-- number of tiles in one line<br />
fr=5 -- frame size<br />
-- Tile movement keys default to arrows, but can be changed here<br />
-- Note: "l" and "p" are reserved (load and preview)<br />
--[[<br />
up="w" <br />
down="s"<br />
left="a"<br />
right="d"<br />
--]]<br />
<br />
-- default directory to start in. Change to nil to start in current dir<br />
--img_dir="/home/shared/image/slide_puzzle"<br />
<br />
if not Fl_Image.getTiles then<br />
err="This program requires murgaLua 0.6.4 or newer.&#92;n&#92;n"..<br />
"http://www.murga-projects.com/murgaLua/index.html"<br />
if fltk then fltk.fl_alert(err) else print(err) end<br />
os.exit(1)<br />
end<br />
<br />
-- check commandline options<br />
for i,v in pairs(arg) do<br />
if v=="-w" and type(tonumber(arg[i+1]))=="number" then iw=arg[i+1]<br />
elseif string.find(v,"^%-w%d+&#36;") then iw=string.gsub(v,"-w","")<br />
elseif v=="-tc" and type(tonumber(arg[i+1]))=="number" then tc=arg[i+1]<br />
elseif string.find(v,"^%-tc%d+&#36;") then tc=string.gsub(v,"-tc","")<br />
end<br />
end<br />
<br />
if iw/tc &lt; 50 then<br />
err="image size should be at least 50x the tile count"<br />
if fltk then fltk.fl_alert(err) else print(err) end<br />
os.exit()<br />
end<br />
<br />
-- fix to make iw evenly divisible by tc<br />
if iw % tc ~= 0 then iw=tc*math.floor(iw/tc) end<br />
<br />
function set_shortcuts()<br />
-- set arrow key shortcuts to the tiles surrounding the hidden tile<br />
-- If you have no use for keyboard control, this function can be safely removed as long<br />
-- as you also remove the two lines that call it (in the functions move_tile &amp; scramble)<br />
&nbsp;&nbsp;for i=0,tc*tc-1 do<br />
&nbsp;&nbsp;&nbsp;&nbsp;tile[i]:shortcut(nil)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (tile[i]:x()==tile[hidden]:x() and math.abs(tile[i]:y()-tile[hidden]:y()) == ts) then<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if tile[i]:y() &lt; tile[hidden]:y() then tile[i]:shortcut(mv_Down) else tile[i]:shortcut(mv_Up) end<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;elseif (tile[i]:y()==tile[hidden]:y() and math.abs(tile[i]:x()-tile[hidden]:x()) == ts) then<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if tile[i]:x() &lt; tile[hidden]:x() then tile[i]:shortcut(mv_Right) else tile[i]:shortcut(mv_Left) end<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end<br />
&nbsp;&nbsp;end<br />
end<br />
<br />
function load_callback(object)<br />
-- a stew of pieces from John Murga's functions<br />
fileName = fltk.fl_file_chooser("Choose an RGB image", "Image Files (*.{jpg,png,bmp,xbm,xpm,gif})", img_dir, nil)<br />
if fileName then<br />
&nbsp;&nbsp;w:make_current()<br />
&nbsp;&nbsp;img_dir=nil -- use previously selected dir from now on<br />
&nbsp;&nbsp;if image1 then image1:uncache() end -- don't know if this is needed<br />
&nbsp;&nbsp;image1 = Fl_Shared_Image.get(fileName,iw,iw)<br />
&nbsp;&nbsp;start=1 -- prevents gameplay checks during scramble<br />
&nbsp;&nbsp;w:label(fltk.fl_filename_name(fileName))<br />
&nbsp;&nbsp;preview:image(image1); preview:redraw(); preview:show() -- load the preview<br />
&nbsp;&nbsp;Fl:check() -- seems to keep fl_read_image from grabbing the file chooser<br />
&nbsp;&nbsp;imageString=fltk.fl_read_image(fr,fr,iw,iw) -- grab the preview image<br />
&nbsp;&nbsp;image2 = fltk:Fl_RGB_Image(imageString,iw,iw,3) -- create RGB image for tiling<br />
&nbsp;&nbsp;for i,_ in pairs(tile) do -- create an image for each tile<br />
&nbsp;&nbsp;&nbsp;&nbsp;tileString = fltk.fl_read_image(pos[i].col, pos[i].row, ts, ts)<br />
&nbsp;&nbsp;&nbsp;&nbsp;tile[i]:image(fltk:Fl_RGB_Image(tileString, ts, ts, 3))<br />
&nbsp;&nbsp;&nbsp;&nbsp;-- make sure all tile locations are reset correctly<br />
&nbsp;&nbsp;&nbsp;&nbsp;-- fixes a bug if image is changed while tiles are scrambled<br />
&nbsp;&nbsp;&nbsp;&nbsp;tile[i]:position(pos[i].col,pos[i].row)<br />
&nbsp;&nbsp;end<br />
&nbsp;&nbsp;scramble()<br />
&nbsp;&nbsp;scrambutt:label("&amp;load an image")<br />
end<br />
end<br />
<br />
function move_tile(t)<br />
if image2 then<br />
&nbsp;&nbsp;local my_x,my_y,movex,movey=t:x(),t:y()<br />
&nbsp;&nbsp;-- tile must be adjacent to the missing piece<br />
&nbsp;&nbsp;if (my_x == tile[hidden]:x() and math.abs(my_y-tile[hidden]:y()) == ts)<br />
&nbsp;&nbsp;or (my_y == tile[hidden]:y() and math.abs(my_x-tile[hidden]:x()) == ts)<br />
&nbsp;&nbsp;then<br />
&nbsp;&nbsp;&nbsp;&nbsp;-- swap selected tile with the hidden one<br />
&nbsp;&nbsp;&nbsp;&nbsp;if start==0 then num_moves=num_moves+1 end<br />
&nbsp;&nbsp;&nbsp;&nbsp;movex=tile[hidden]:x()<br />
&nbsp;&nbsp;&nbsp;&nbsp;movey=tile[hidden]:y()<br />
&nbsp;&nbsp;&nbsp;&nbsp;tile[hidden]:position(my_x,my_y)<br />
&nbsp;&nbsp;&nbsp;&nbsp;t:position(movex,movey)<br />
&nbsp;&nbsp;&nbsp;&nbsp;w:redraw()<br />
&nbsp;&nbsp;end<br />
&nbsp;&nbsp;-- check to see if puzzle is solved<br />
&nbsp;&nbsp;-- "ok" is incremented each time a tile is found in its proper place<br />
&nbsp;&nbsp;if start==0 then -- don't check puzzle during scramble<br />
&nbsp;&nbsp;set_shortcuts() -- you can remove this if you use mouse only<br />
&nbsp;&nbsp;local ok=0<br />
&nbsp;&nbsp;for i=0,tc^2-1 do<br />
&nbsp;&nbsp;&nbsp;&nbsp;if tile[i]:x()==pos[i].col and tile[i]:y()==pos[i].row then<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ok=ok+1<br />
&nbsp;&nbsp;&nbsp;&nbsp;if ok==tc^2 then -- if ok == total number of tiles<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fltk.fl_beep()<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if num_moves&lt;tc*25 then plize=firstplize<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;elseif num_moves&lt;tc*50 then plize=secondplize<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;elseif num_moves&lt;tc*75 then plize=thirdplize<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;elseif num_moves&lt;tc*100 then plize=fourthplize<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else plize=insult end<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;scrambutt:label(plize[math.random(1,table.getn(plize))].."&#92;n"..num_moves.." moves")<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;preview:show()<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;start=1<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break<br />
&nbsp;&nbsp;&nbsp;&nbsp;end<br />
&nbsp;&nbsp;&nbsp;&nbsp;end<br />
&nbsp;&nbsp;end<br />
&nbsp;&nbsp;end<br />
end<br />
end<br />
<br />
function scramble()<br />
-- this picks a random tile to attempt to move and<br />
-- repeats the process many times. Simply placing<br />
-- tiles in random locations could potentially make<br />
-- the puzzle impossible to solve<br />
preview:hide()<br />
if hidden then -- reset hidden tile<br />
&nbsp;&nbsp;tile[hidden]:box(fltk.FL_UP_BOX)<br />
&nbsp;&nbsp;tile[hidden]:labeltype(fltk.FL_NORMAL_LABEL)<br />
end<br />
-- turn a random tile into the missing piece<br />
hidden=math.random(0,tc^2-1)<br />
tile[hidden]:labeltype(fltk.FL_NO_LABEL)<br />
tile[hidden]:box(fltk.FL_DOWN_BOX)<br />
local scram=0<br />
while scram &lt; 10000*tc do<br />
&nbsp;&nbsp;move_tile(tile[math.random(0,tc^2-1)])<br />
&nbsp;&nbsp;scram=scram+1<br />
end<br />
start=0<br />
set_shortcuts() -- you can remove this if you use mouse only<br />
num_moves=0<br />
w:redraw()<br />
end<br />
<br />
firstplize={"GODLIKE!", "OWNAGE!", "TEH WINRAR!"}<br />
secondplize={"Great Job!","Hooray for You!","WIN!",<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "CONGRATULATE YOU!","Super!","Flawless Victory!",<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "You rock!","Crazygonuts!"}<br />
thirdplize={"Not bad at all!","Yay!"}<br />
fourthplize={"You're not terrible!","Petty good."}<br />
insult={"You're kinda bad at this.","Is that your best?","Ho-hum.","a mediocre performance."}<br />
<br />
Fl:get_system_colors()<br />
fltk.fl_register_images()<br />
math.randomseed(os.time())<br />
Fl:visible_focus(0) -- get rid of the ants<br />
Fl:set_boxtype(fltk.FL_UP_BOX,fltk.FL_THIN_UP_BOX) -- looks a little more like tiles<br />
Fl:set_boxtype(fltk.FL_DOWN_BOX,fltk.FL_THIN_DOWN_BOX)<br />
mv_Up=up or fltk.FL_Up<br />
mv_Down=down or fltk.FL_Down<br />
mv_Left=left or fltk.FL_Left<br />
mv_Right=right or fltk.FL_Right<br />
ts=iw/tc -- set tile size<br />
--w=fltk:Fl_Double_Window(iw+fr*2,ts*(tc+0.5)+fr*3,"slide puzzle")<br />
w=fltk:Fl_Double_Window(iw+fr*2,iw+ts/2+fr*3,"slide puzzle")<br />
<br />
scrambutt=fltk:Fl_Button(fr,iw+fr*2,iw,ts/2,"&amp;load an image")<br />
scrambutt:callback(load_callback)<br />
scrambutt:shortcut("l")<br />
<br />
-- array of tiles, top left to right, then move down<br />
tile={}; pos={}<br />
-- allow space for the frame<br />
row=fr; col=fr<br />
-- subtract one is used because the number of tiles starts at one<br />
-- but the table starts at zero (easier to position them from zero)<br />
for i=0,tc^2-1 do<br />
&nbsp;&nbsp;tile[i]=fltk:Fl_Button(col,row,ts,ts)<br />
&nbsp;&nbsp;tile[i]:align(80)<br />
&nbsp;&nbsp;tile[i]:callback(move_tile)<br />
&nbsp;&nbsp;pos[i]={col=col,row=row}<br />
&nbsp;&nbsp;-- next piece is ts pixels to the right<br />
&nbsp;&nbsp;col=col+ts<br />
&nbsp;&nbsp;-- start the next row<br />
&nbsp;&nbsp;if col == iw+fr then col=fr;row=row+ts end<br />
end<br />
<br />
-- image preview (cheat)<br />
preview=fltk:Fl_Button(fr,fr,iw,iw)<br />
preview:callback(function()<br />
if start==1 then load_callback()<br />
else preview:hide() end<br />
end)<br />
tog_prev=fltk:Fl_Button(-10,-10,0,0)<br />
tog_prev:shortcut("p")<br />
tog_prev:callback(function()<br />
if preview:visible()==1 then preview:hide() else preview:show() end<br />
end)<br />
<br />
w:callback(function()<br />
&nbsp;&nbsp;-- Esc/close hides the preview if it's visible<br />
&nbsp;&nbsp;if preview:visible()==1 and start==0 then preview:hide()<br />
&nbsp;&nbsp;else os.exit() end -- otherwise exit as normal<br />
end)<br />
<br />
start=1<br />
w:show()<br />
Fl:run()<br />
<br />
]]></description>
			<content:encoded><![CDATA[Dug out the slide puzzle I was working on a couple of years ago, and made a couple of changes.  It will now accept commandline options to set the image width (-iw ) and tile count (-tc ).  Tile count is the number of tiles along one edge, so it's image width divided by tile count equals tile width.  If the tile count can't be divided evenly into the image width, something was messing up, so rather than try to figure out what was happening I made it so it will just shrink the image width to make it even.<br />
<br />
You can also set keys to control tile movement.  If they're not set they will default to arrows.<br />
<br />
I don't know what else might be different from the last time i posted it...it's been a while.  One thing I did forget is that I wanted to make an option to disable setting the hotkeys if you only use the mouse, since it has to reset the hot buttons every time you move a tile.<br />
<br />
EDIT 2011-01-09: replaced Fl_Image:getTiles() with a fl_read_image() loop<br />
<br />
<br />
Code:<br />
#!/usr/bin/env murgaLua<br />
<br />
-- slide puzzle for MurgaLua 0.6.4+<br />
-- 2008-2011 mikshaw<br />
<br />
<br />
-- window and tile size are determined by these variables<br />
-- tile size = iw/tc (image size will be adjusted if it doesn't divide evenly)<br />
iw=600&nbsp;&nbsp;-- image width<br />
tc=5&nbsp;&nbsp;-- number of tiles in one line<br />
fr=5 -- frame size<br />
-- Tile movement keys default to arrows, but can be changed here<br />
-- Note: "l" and "p" are reserved (load and preview)<br />
--[[<br />
up="w" <br />
down="s"<br />
left="a"<br />
right="d"<br />
--]]<br />
<br />
-- default directory to start in. Change to nil to start in current dir<br />
--img_dir="/home/shared/image/slide_puzzle"<br />
<br />
if not Fl_Image.getTiles then<br />
err="This program requires murgaLua 0.6.4 or newer.&#92;n&#92;n"..<br />
"http://www.murga-projects.com/murgaLua/index.html"<br />
if fltk then fltk.fl_alert(err) else print(err) end<br />
os.exit(1)<br />
end<br />
<br />
-- check commandline options<br />
for i,v in pairs(arg) do<br />
if v=="-w" and type(tonumber(arg[i+1]))=="number" then iw=arg[i+1]<br />
elseif string.find(v,"^%-w%d+&#36;") then iw=string.gsub(v,"-w","")<br />
elseif v=="-tc" and type(tonumber(arg[i+1]))=="number" then tc=arg[i+1]<br />
elseif string.find(v,"^%-tc%d+&#36;") then tc=string.gsub(v,"-tc","")<br />
end<br />
end<br />
<br />
if iw/tc &lt; 50 then<br />
err="image size should be at least 50x the tile count"<br />
if fltk then fltk.fl_alert(err) else print(err) end<br />
os.exit()<br />
end<br />
<br />
-- fix to make iw evenly divisible by tc<br />
if iw % tc ~= 0 then iw=tc*math.floor(iw/tc) end<br />
<br />
function set_shortcuts()<br />
-- set arrow key shortcuts to the tiles surrounding the hidden tile<br />
-- If you have no use for keyboard control, this function can be safely removed as long<br />
-- as you also remove the two lines that call it (in the functions move_tile &amp; scramble)<br />
&nbsp;&nbsp;for i=0,tc*tc-1 do<br />
&nbsp;&nbsp;&nbsp;&nbsp;tile[i]:shortcut(nil)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (tile[i]:x()==tile[hidden]:x() and math.abs(tile[i]:y()-tile[hidden]:y()) == ts) then<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if tile[i]:y() &lt; tile[hidden]:y() then tile[i]:shortcut(mv_Down) else tile[i]:shortcut(mv_Up) end<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;elseif (tile[i]:y()==tile[hidden]:y() and math.abs(tile[i]:x()-tile[hidden]:x()) == ts) then<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if tile[i]:x() &lt; tile[hidden]:x() then tile[i]:shortcut(mv_Right) else tile[i]:shortcut(mv_Left) end<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end<br />
&nbsp;&nbsp;end<br />
end<br />
<br />
function load_callback(object)<br />
-- a stew of pieces from John Murga's functions<br />
fileName = fltk.fl_file_chooser("Choose an RGB image", "Image Files (*.{jpg,png,bmp,xbm,xpm,gif})", img_dir, nil)<br />
if fileName then<br />
&nbsp;&nbsp;w:make_current()<br />
&nbsp;&nbsp;img_dir=nil -- use previously selected dir from now on<br />
&nbsp;&nbsp;if image1 then image1:uncache() end -- don't know if this is needed<br />
&nbsp;&nbsp;image1 = Fl_Shared_Image.get(fileName,iw,iw)<br />
&nbsp;&nbsp;start=1 -- prevents gameplay checks during scramble<br />
&nbsp;&nbsp;w:label(fltk.fl_filename_name(fileName))<br />
&nbsp;&nbsp;preview:image(image1); preview:redraw(); preview:show() -- load the preview<br />
&nbsp;&nbsp;Fl:check() -- seems to keep fl_read_image from grabbing the file chooser<br />
&nbsp;&nbsp;imageString=fltk.fl_read_image(fr,fr,iw,iw) -- grab the preview image<br />
&nbsp;&nbsp;image2 = fltk:Fl_RGB_Image(imageString,iw,iw,3) -- create RGB image for tiling<br />
&nbsp;&nbsp;for i,_ in pairs(tile) do -- create an image for each tile<br />
&nbsp;&nbsp;&nbsp;&nbsp;tileString = fltk.fl_read_image(pos[i].col, pos[i].row, ts, ts)<br />
&nbsp;&nbsp;&nbsp;&nbsp;tile[i]:image(fltk:Fl_RGB_Image(tileString, ts, ts, 3))<br />
&nbsp;&nbsp;&nbsp;&nbsp;-- make sure all tile locations are reset correctly<br />
&nbsp;&nbsp;&nbsp;&nbsp;-- fixes a bug if image is changed while tiles are scrambled<br />
&nbsp;&nbsp;&nbsp;&nbsp;tile[i]:position(pos[i].col,pos[i].row)<br />
&nbsp;&nbsp;end<br />
&nbsp;&nbsp;scramble()<br />
&nbsp;&nbsp;scrambutt:label("&amp;load an image")<br />
end<br />
end<br />
<br />
function move_tile(t)<br />
if image2 then<br />
&nbsp;&nbsp;local my_x,my_y,movex,movey=t:x(),t:y()<br />
&nbsp;&nbsp;-- tile must be adjacent to the missing piece<br />
&nbsp;&nbsp;if (my_x == tile[hidden]:x() and math.abs(my_y-tile[hidden]:y()) == ts)<br />
&nbsp;&nbsp;or (my_y == tile[hidden]:y() and math.abs(my_x-tile[hidden]:x()) == ts)<br />
&nbsp;&nbsp;then<br />
&nbsp;&nbsp;&nbsp;&nbsp;-- swap selected tile with the hidden one<br />
&nbsp;&nbsp;&nbsp;&nbsp;if start==0 then num_moves=num_moves+1 end<br />
&nbsp;&nbsp;&nbsp;&nbsp;movex=tile[hidden]:x()<br />
&nbsp;&nbsp;&nbsp;&nbsp;movey=tile[hidden]:y()<br />
&nbsp;&nbsp;&nbsp;&nbsp;tile[hidden]:position(my_x,my_y)<br />
&nbsp;&nbsp;&nbsp;&nbsp;t:position(movex,movey)<br />
&nbsp;&nbsp;&nbsp;&nbsp;w:redraw()<br />
&nbsp;&nbsp;end<br />
&nbsp;&nbsp;-- check to see if puzzle is solved<br />
&nbsp;&nbsp;-- "ok" is incremented each time a tile is found in its proper place<br />
&nbsp;&nbsp;if start==0 then -- don't check puzzle during scramble<br />
&nbsp;&nbsp;set_shortcuts() -- you can remove this if you use mouse only<br />
&nbsp;&nbsp;local ok=0<br />
&nbsp;&nbsp;for i=0,tc^2-1 do<br />
&nbsp;&nbsp;&nbsp;&nbsp;if tile[i]:x()==pos[i].col and tile[i]:y()==pos[i].row then<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ok=ok+1<br />
&nbsp;&nbsp;&nbsp;&nbsp;if ok==tc^2 then -- if ok == total number of tiles<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fltk.fl_beep()<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if num_moves&lt;tc*25 then plize=firstplize<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;elseif num_moves&lt;tc*50 then plize=secondplize<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;elseif num_moves&lt;tc*75 then plize=thirdplize<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;elseif num_moves&lt;tc*100 then plize=fourthplize<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else plize=insult end<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;scrambutt:label(plize[math.random(1,table.getn(plize))].."&#92;n"..num_moves.." moves")<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;preview:show()<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;start=1<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break<br />
&nbsp;&nbsp;&nbsp;&nbsp;end<br />
&nbsp;&nbsp;&nbsp;&nbsp;end<br />
&nbsp;&nbsp;end<br />
&nbsp;&nbsp;end<br />
end<br />
end<br />
<br />
function scramble()<br />
-- this picks a random tile to attempt to move and<br />
-- repeats the process many times. Simply placing<br />
-- tiles in random locations could potentially make<br />
-- the puzzle impossible to solve<br />
preview:hide()<br />
if hidden then -- reset hidden tile<br />
&nbsp;&nbsp;tile[hidden]:box(fltk.FL_UP_BOX)<br />
&nbsp;&nbsp;tile[hidden]:labeltype(fltk.FL_NORMAL_LABEL)<br />
end<br />
-- turn a random tile into the missing piece<br />
hidden=math.random(0,tc^2-1)<br />
tile[hidden]:labeltype(fltk.FL_NO_LABEL)<br />
tile[hidden]:box(fltk.FL_DOWN_BOX)<br />
local scram=0<br />
while scram &lt; 10000*tc do<br />
&nbsp;&nbsp;move_tile(tile[math.random(0,tc^2-1)])<br />
&nbsp;&nbsp;scram=scram+1<br />
end<br />
start=0<br />
set_shortcuts() -- you can remove this if you use mouse only<br />
num_moves=0<br />
w:redraw()<br />
end<br />
<br />
firstplize={"GODLIKE!", "OWNAGE!", "TEH WINRAR!"}<br />
secondplize={"Great Job!","Hooray for You!","WIN!",<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "CONGRATULATE YOU!","Super!","Flawless Victory!",<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "You rock!","Crazygonuts!"}<br />
thirdplize={"Not bad at all!","Yay!"}<br />
fourthplize={"You're not terrible!","Petty good."}<br />
insult={"You're kinda bad at this.","Is that your best?","Ho-hum.","a mediocre performance."}<br />
<br />
Fl:get_system_colors()<br />
fltk.fl_register_images()<br />
math.randomseed(os.time())<br />
Fl:visible_focus(0) -- get rid of the ants<br />
Fl:set_boxtype(fltk.FL_UP_BOX,fltk.FL_THIN_UP_BOX) -- looks a little more like tiles<br />
Fl:set_boxtype(fltk.FL_DOWN_BOX,fltk.FL_THIN_DOWN_BOX)<br />
mv_Up=up or fltk.FL_Up<br />
mv_Down=down or fltk.FL_Down<br />
mv_Left=left or fltk.FL_Left<br />
mv_Right=right or fltk.FL_Right<br />
ts=iw/tc -- set tile size<br />
--w=fltk:Fl_Double_Window(iw+fr*2,ts*(tc+0.5)+fr*3,"slide puzzle")<br />
w=fltk:Fl_Double_Window(iw+fr*2,iw+ts/2+fr*3,"slide puzzle")<br />
<br />
scrambutt=fltk:Fl_Button(fr,iw+fr*2,iw,ts/2,"&amp;load an image")<br />
scrambutt:callback(load_callback)<br />
scrambutt:shortcut("l")<br />
<br />
-- array of tiles, top left to right, then move down<br />
tile={}; pos={}<br />
-- allow space for the frame<br />
row=fr; col=fr<br />
-- subtract one is used because the number of tiles starts at one<br />
-- but the table starts at zero (easier to position them from zero)<br />
for i=0,tc^2-1 do<br />
&nbsp;&nbsp;tile[i]=fltk:Fl_Button(col,row,ts,ts)<br />
&nbsp;&nbsp;tile[i]:align(80)<br />
&nbsp;&nbsp;tile[i]:callback(move_tile)<br />
&nbsp;&nbsp;pos[i]={col=col,row=row}<br />
&nbsp;&nbsp;-- next piece is ts pixels to the right<br />
&nbsp;&nbsp;col=col+ts<br />
&nbsp;&nbsp;-- start the next row<br />
&nbsp;&nbsp;if col == iw+fr then col=fr;row=row+ts end<br />
end<br />
<br />
-- image preview (cheat)<br />
preview=fltk:Fl_Button(fr,fr,iw,iw)<br />
preview:callback(function()<br />
if start==1 then load_callback()<br />
else preview:hide() end<br />
end)<br />
tog_prev=fltk:Fl_Button(-10,-10,0,0)<br />
tog_prev:shortcut("p")<br />
tog_prev:callback(function()<br />
if preview:visible()==1 then preview:hide() else preview:show() end<br />
end)<br />
<br />
w:callback(function()<br />
&nbsp;&nbsp;-- Esc/close hides the preview if it's visible<br />
&nbsp;&nbsp;if preview:visible()==1 and start==0 then preview:hide()<br />
&nbsp;&nbsp;else os.exit() end -- otherwise exit as normal<br />
end)<br />
<br />
start=1<br />
w:show()<br />
Fl:run()<br />
<br />
]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[socket.http bug or aminotdoinitrite?]]></title>
			<link>http://www.murga-projects.com/forum/showthread.php?tid=402</link>
			<pubDate>Mon, 27 Dec 2010 19:14:52 -0700</pubDate>
			<guid isPermaLink="false">http://www.murga-projects.com/forum/showthread.php?tid=402</guid>
			<description><![CDATA[In the LuaSocket docs:<br />
<br />
Code:<br />
-- tries to connect to server "wrong.host" to retrieve "/"<br />
-- and fails because the host does not exist.<br />
r, e = http.request("http://wrong.host/")<br />
-- r is nil, and e returns with value "host not found"<br />
<br />
When I try this it does more than fail...it takes murgaLua down with it.  Wondering if this is expected behaviour, because it seems like this is a pretty harsh way to handle it.<br />
<br />
<br />
Code:<br />
/home/deb/bin/murgaLua: No route to host<br />
stack traceback:<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[C]: in function 'request'<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/home/deb/bin/media.lua:28: in main chunk<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[C]: ?<br />
<br />
]]></description>
			<content:encoded><![CDATA[In the LuaSocket docs:<br />
<br />
Code:<br />
-- tries to connect to server "wrong.host" to retrieve "/"<br />
-- and fails because the host does not exist.<br />
r, e = http.request("http://wrong.host/")<br />
-- r is nil, and e returns with value "host not found"<br />
<br />
When I try this it does more than fail...it takes murgaLua down with it.  Wondering if this is expected behaviour, because it seems like this is a pretty harsh way to handle it.<br />
<br />
<br />
Code:<br />
/home/deb/bin/murgaLua: No route to host<br />
stack traceback:<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[C]: in function 'request'<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/home/deb/bin/media.lua:28: in main chunk<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[C]: ?<br />
<br />
]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Transcribe.lua]]></title>
			<link>http://www.murga-projects.com/forum/showthread.php?tid=401</link>
			<pubDate>Mon, 27 Dec 2010 17:55:25 -0700</pubDate>
			<guid isPermaLink="false">http://www.murga-projects.com/forum/showthread.php?tid=401</guid>
			<description><![CDATA[Well, another thing I'm working on: a transcription application for murgaLua.<br />
<br />
Recently I've had the task to transcribe interviews (on audio file) to text, and I took it as an opportunity to toy around a little more with murgaLua.<br />
<br />
While I initially tried to use the proteAudio library that comes with murgaLua, it couldn't cope with the requirements (pause, seek, slow audio, ...) so I interfaced my app to vlc via it's RC interface. In 2 ways even: via LuaSocket, and via io.popen and mkfifo (because it initially seemed that the socket solution was too slow). Any way, it's trivial to extend this to whatever audio application with whatever interface, as you'll see in the sources.<br />
<br />
It's not yet finished, but it's usable.<br />
<br />
Things on my wishlist for now:<br />
some easy to switch highlighting for talkers, events, signs, pauses, ...<br />
hotkeys for inserting timestamps, events, ...<br />
Word autocompletion (like in Openoffice)<br />
timestamps<br />
exporting to html (to later import in openoffice)<br />
<br />
<br />
<br />
Any comments, suggestions, critics, ... are welcome!<br />
<br />
Greetings,<br />
<br />
Jan-Pieter<br />
<br />
PS: Given the complexity (and in lesser degree the differences with the C++ version) of the FLTK bindings, I think it would be good to have some sort of a "best practices" guide for programming an interface, also taking into account pollution of the global namespace, the neat tricks we can pull off using tables and metatables in Lua, ... Maybe we should make an attempt at this at the Wiki?<br />
<br />
Edit:<br />
Right I forgot about the keybindings (though they are easily extracted from the sources):<br />
<br />
Ctrl-O open file<br />
Ctrl-Shift-O open audio file<br />
Ctrl-Space toggle audio pause<br />
Ctlr-L 10 seconds back<br />
Ctrl-M 10 seconds forward<br />
<br />
]]></description>
			<content:encoded><![CDATA[Well, another thing I'm working on: a transcription application for murgaLua.<br />
<br />
Recently I've had the task to transcribe interviews (on audio file) to text, and I took it as an opportunity to toy around a little more with murgaLua.<br />
<br />
While I initially tried to use the proteAudio library that comes with murgaLua, it couldn't cope with the requirements (pause, seek, slow audio, ...) so I interfaced my app to vlc via it's RC interface. In 2 ways even: via LuaSocket, and via io.popen and mkfifo (because it initially seemed that the socket solution was too slow). Any way, it's trivial to extend this to whatever audio application with whatever interface, as you'll see in the sources.<br />
<br />
It's not yet finished, but it's usable.<br />
<br />
Things on my wishlist for now:<br />
some easy to switch highlighting for talkers, events, signs, pauses, ...<br />
hotkeys for inserting timestamps, events, ...<br />
Word autocompletion (like in Openoffice)<br />
timestamps<br />
exporting to html (to later import in openoffice)<br />
<br />
<br />
<br />
Any comments, suggestions, critics, ... are welcome!<br />
<br />
Greetings,<br />
<br />
Jan-Pieter<br />
<br />
PS: Given the complexity (and in lesser degree the differences with the C++ version) of the FLTK bindings, I think it would be good to have some sort of a "best practices" guide for programming an interface, also taking into account pollution of the global namespace, the neat tricks we can pull off using tables and metatables in Lua, ... Maybe we should make an attempt at this at the Wiki?<br />
<br />
Edit:<br />
Right I forgot about the keybindings (though they are easily extracted from the sources):<br />
<br />
Ctrl-O open file<br />
Ctrl-Shift-O open audio file<br />
Ctrl-Space toggle audio pause<br />
Ctlr-L 10 seconds back<br />
Ctrl-M 10 seconds forward<br />
<br />
]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Listing availiable storage devices]]></title>
			<link>http://www.murga-projects.com/forum/showthread.php?tid=400</link>
			<pubDate>Sun, 26 Dec 2010 11:59:46 -0700</pubDate>
			<guid isPermaLink="false">http://www.murga-projects.com/forum/showthread.php?tid=400</guid>
			<description><![CDATA[Hi all. It's been quite a while since I've been on here, but I'm back at it. I'm trying to build a list of all availiable internal and external drives that are mounted. It needs to work in Windows and Linux. In Windows it is kind of clumsy but I do have it working with this code.<br />
<br />
Code:<br />
--check for windows<br />
CheckForWindows = "C:/"<br />
<br />
windows = false<br />
<br />
--Define the drive table.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
drive = {}<br />
<br />
if lfs.attributes (CheckForWindows) ~= nil then<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; windows = true<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; --Check for all the Windows drives.<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if lfs.attributes ("A:/") ~= nil then<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;drive["a"] = "A:"<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end<br />
<br />
&nbsp;&nbsp; -- Use the above code to check for each drive letter from A to Z.<br />
<br />
end<br />
<br />
<br />
In linux, my first thought was to just check the /mnt directory. However I found that some types of Linux don't use this directory. For instance my computer running PCLinuxOS has all removable media listed in the "/Media" directory and the "/mnt" directory is empty. I can see this could end up being really messy. Is there an easier way to do this?<br />
<br />
Thanks,<br />
Dan]]></description>
			<content:encoded><![CDATA[Hi all. It's been quite a while since I've been on here, but I'm back at it. I'm trying to build a list of all availiable internal and external drives that are mounted. It needs to work in Windows and Linux. In Windows it is kind of clumsy but I do have it working with this code.<br />
<br />
Code:<br />
--check for windows<br />
CheckForWindows = "C:/"<br />
<br />
windows = false<br />
<br />
--Define the drive table.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
drive = {}<br />
<br />
if lfs.attributes (CheckForWindows) ~= nil then<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; windows = true<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; --Check for all the Windows drives.<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if lfs.attributes ("A:/") ~= nil then<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;drive["a"] = "A:"<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end<br />
<br />
&nbsp;&nbsp; -- Use the above code to check for each drive letter from A to Z.<br />
<br />
end<br />
<br />
<br />
In linux, my first thought was to just check the /mnt directory. However I found that some types of Linux don't use this directory. For instance my computer running PCLinuxOS has all removable media listed in the "/Media" directory and the "/mnt" directory is empty. I can see this could end up being really messy. Is there an easier way to do this?<br />
<br />
Thanks,<br />
Dan]]></content:encoded>
		</item>
	</channel>
</rss>
