For that reason, we select the app.activeSprite if it is nil, we create a new Sprite.Īfter we have access to a Sprite, we create a new Layer and Cel. A dialog window may be opened before a new Sprite is even created. We access information about the Aseprite editor via the variable app. The fields in args correspond to the ids we provided to dlg:color, slider and number. To read the information from the dialog, we cache dlg.data. The number method’s decimals parameter is the maximum decimal places before the number is rounded. The first argument, "%.1f" specifies the decimal places to print, 1 in this case. To accomplish this we supply a number as the second argument to string.format. The number dialog’s text parameter requires a string. We’ll draw a large blue dot with the pencil tool. Now let’s create a dialog that uses inputs to change a sprite’s canvas. Last but not least, we need to call show for the dialog to appear. Text in this console cannot be selected or copied. Whenever a Lua script contains at least one print call, the Aseprite console will appear. In this case we print, then close the dialog. The button method’s most important parameter is onclick, where we will define a function of our own to be called when the button is clicked. The option parameter specifies the selected option, while the options parameter specifies the possibilities. The combo box works with a table of strings that acts as an enumeration. There is a shades input if we wish to handle multiple colors. We could also construct a color using hue, saturation and value (HSV) hue, saturation and lightness (HSL) or an ABGR hexadecimal, such as 0xffccbbaa. Above, we’ve created a color by supplying the red, green, blue and alpha channels in the range. The color picker input works with a Color object. If we wanted real number inputs, or didn’t have a bounding range, we could use a number input instead. The first input, a slider, works on integers with a min (minimum) and max (maximum). The colon syntax implicitly passes the dlg instance as the first argument into the method as self. Because the methods which create a slider, color selector and combo box are instance methods of dlg, we call them with a colon : rather than a dot. The local keyword limits the scope of the variable. Arguments that we do not specify fall back to a default.Īfter we create a Dialog, we assign an instance to a local variable dlg. We use Lua’s table syntax, curly braces, to call dialog methods because we can label each argument that we pass to a method with a named parameter followed by an equal sign =.
0 Comments
Leave a Reply. |