Changes between Version 1 and Version 2 of UserGuide/Lua


Ignore:
Timestamp:
08/10/2016 12:53:33 (4 years ago)
Author:
pulkomandy
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • UserGuide/Lua

    v1 v2  
    132132
    133133 * {{{inputbox(window_title,label_1,initial_value_1,min_1,max_1,digits_1,...)}}} Opens a window that asks the user for one or several setting values. The control only accepts values between the min and max that you provide, and you can specify how many decimal places of precision it should have with {{{digits}}}. You can ask for more than one value by adding arguments: label_2, initial_value_2, min_2, max_2, digits_2 etc, with a limit of 9 settings. This function returns one value to tell if the user accepted or cancelled (true or false), and one additional return value by setting. Example:
    134 {{{
     134
     135{{{#!lua
    135136ok, w, h = inputbox("Modify brush size",
    136137  "Width",     w, 1,100,0,
     
    138139);
    139140}}}
     141
    140142   * If min and max are 0 and 1, and digits is 0, it will show a checkbox. Ex:
    141 {{{
     143{{{#!lua
    142144ok, xflip, yflip = inputbox("Transformation",
    143145  "X-Flip",    0, 0, 1,0,
     
    145147);
    146148}}}
     149
    147150   * If min and max are 0 and 1, and digits is negative, it will show a radio button. Radio buttons with the same number of "digits" are grouped together. Ex:
    148 {{{
     151{{{#!lua
    149152ok, a, b ,c, d = inputbox("Your choice",
    150153  "A",    1, 0, 1,-1,
     
    154157);
    155158}}}
     159
    156160   * If min and max are 0, the entry is just a label, the user can't input anything on this line.
    157161
    158162 * {{{selectbox(caption,label_1,callback_1,label_2,callback_2)}}} Opens a window where the user has to click on one of the buttons. You provide the button labels, and Grafx2 executes the associated callback, which must be a function : a pre-defined function (don't type the parentheses after function name) or an anonymous function that you build on the spot. The user can press Esc to cancel. Example:
    159 {{{
     163{{{#!lua
    160164selectbox("Menu",
    161165  "Sub-menu 1", sub_menu1_func,
     
    195199Here is a very small sample script that generate a diagonal gradient.
    196200
    197 {{{
     201{{{#!lua
    198202-- get the size of the brush
    199203w, h = getbrushsize()
     
    225229 * Memory.lua : persistent on-disk storage for your scripts. Use this for storing your own settings or other data.
    226230
    227 We welcome any additions you want to make to this set of functions. If something proves too slow when done in lua, we may provide a faster C version, with the same interface whenever possible. This way all scripts can share the enhancements.
     231We welcome any additions you want to make to this set of functions. If something proves too slow when done in lua, we may provide a faster C version, with the same interface whenever possible. This way all scripts can share the enhancements.º