Posted by member 7223 on 2006-08-21 00:04:25
© 2006 Smurth ( smurth@free.fr )
Here is some usefull !bangs to use with LSLua.
No litestep module; no lua module needed; nothing but Lua.
Download the package here: http://www.litestep.net/download.php?mod=138,module
With !TextAppend, !TextReplace and !VarSave, every can be: "arg" , 'arg' or [arg]
!Exec !bang
or
!Exec [!bang1][!bang2]...
Examples:
!exec !alert %#resolutionx*10%#
!exec [!setevar newevar "This evar exist, now"][!alert "%#newevar%#"][!setevar newevar "The same evar :)"][!alert "%#newevar%#"]
!if [condition] [!bangIfTrue] [!bangIfFalse]
must be written in Lua's form: "==" for "equal" , "~=" for "different" , etc.
Example: !if ["%#resolutionx*10%#" < "8000"] [!alert "too small"]
!TextAppend
!TextReplace
use the Lua's pattern mechanism
IS CASE SENSITIVE
You can do some "TextDelete" with an empty replacement string
!VarSave []
IS NOT case sensitive
is optionnal. If ommited, the evar's value is taken
Note: if is a string, it will be surrounded by quotes ( " ) ; if it already contains quotes, it'll be surrounded by single quotes ( ' )
Then,
!varsave "$themevarfile$" HelloText 12
will write:
HelloText 12
!varsave "$themevarfile$" HelloText "Hello world"
will write:
HelloText "Hello world"
!varsave [$themevarfile$] HelloText [Hello world]
will write:
HelloText "Hello world"
!varsave [$themevarfile$] HelloText [!alert "Hello world"]
will write:
HelloText '!alert "Hello world"'
But,
!varsave [$themevarfile$] HelloText [!alert "Hello world's..."]
will write,
HelloText '!alert "Hello world's..."'
!ThemeSelect "path"
SHOULD be surrounded by quotes ( " )
Example:
*popup "Themes" !PopupActionFolder:!ThemeSelect:"$ThemesDir$*\"
*popup "Schemes" !PopupActionFolder:!ThemeSelect:"$GfxCommonDir$*\"
Notes:
- writes the evar in "$ProfileDir$themeselect.rc"
- can be use to switch schemes, too (hum, you'll need to modify the code to make it works with YOUR scheme's system)
Other Lua's functions:
string.nocase( string )
Returns a case-insensitive string to use as a pattern
Example:
string.nocase( "--aBc123" )
returns "--[aA][bB][cC]123"
string.unpack( string )
Can be used to split multiples arguments stored in one string
Example:
string.unpack( ' "word one" [word two] \'word ...\' ' )
returns unpack( { "word one" "word two" "word ..." } )
parseevar( string )
Just like the !ParseEvars from xLabel but for Lua :)
Can execute Lua's functions, like: parseevar( "resolutionx*cos(sin(0.5))" )
Non existing evars are replaced by "0"
Example:
parseevar( "10*ThisEvarDoesNotExist+20" )
returns "20"
alert( string, title )
or
alert( string )
A simple message_box that can be used for error messages
All messages are prefixed with the current date/time (with millisecondes)
You can replace lslua.message_box() with something like f:write() to use this for logging
Changes:
1.0 (060828): First public release