Select the types of activity you want to include in your feed.
[READ-ONLY] Mirror of https://github.com/thoda-dev/du_render_script_library. A library to build renderscript in boards without writting it as a full string
···11# du_render_script_library
22- A library to build renderscript in boards without writting it as a full string
22+33+A library to build renderscript in boards without writting it as a full string
44+55+The goal of that lib is to make RenderScript easier to write and read when written un control units and not directly in screens.
66+77+## How to use it
88+99+Paste all the content of the library (prefer the minified version) at the start of your script in a control unit in game and then you can use it like this:
1010+1111+```lua
1212+local script = setmetatable({},RenderScript)
1313+local MyFirstLayer = script:createLayer()
1414+script:addBox(MyFirstLayer,0,0,100,100)
1515+1616+if not script:isTooLong() then
1717+ screen.setRenderScript(tostring(script))
1818+else
1919+ system.print("WARNING: Script too long!! Length is actualy " .. script:len() .. " / " .. script:getMaxSize())
2020+end
2121+2222+```
2323+2424+## Code before
2525+2626+Code was all formated as a string and was hard to read, write and debug
2727+2828+```lua
2929+local script = [[
3030+ local MyFirstLayer = createLayer()
3131+ addBox(MyFirstLayer, 0, 0, 100, 100)
3232+]]
3333+3434+screen.setRenderScript(script)
3535+```
+416
RenderScript.lua
···11+RenderScript = {
22+ __index = {
33+ _s = "", --script stored as string
44+ _l = {}, --layers variable name stored
55+ _f = {}, --fonts variable name stored
66+77+ ---@alias table Shape IDs
88+ SHAPES = {
99+ BEZIER=0,
1010+ BOX=1,
1111+ BOX_ROUNDED=2,
1212+ CIRCLE=3,
1313+ IMAGE=4,
1414+ LINE=5,
1515+ POLYGON=6,
1616+ TEXT=7,
1717+ },
1818+1919+ ---@alias table AlignH IDs
2020+ ALIGN_H = {
2121+ LEFT=0,
2222+ CENTER=1,
2323+ RIGHT=2,
2424+ },
2525+2626+ ---@alias table AlignV IDs
2727+ ALIGN_V = {
2828+ ASCENDER=0,
2929+ TOP=1,
3030+ MIDDLE=2,
3131+ BASELINE=3,
3232+ BOTTOM=4,
3333+ DESCENDER=5,
3434+ },
3535+3636+ --- Create a new layer that will be rendered on top of all previously-created layers
3737+ ---@return integer index The id that can be used to uniquely identify the layer for use with other API functions
3838+ createLayer = function(self)
3939+ local layer_name = '_L' .. (#self._l + 1)
4040+ self._s = self._s .. 'local ' .. layer_name .. '=createLayer();'
4141+ self._l[#self._l + 1] = layer_name
4242+ return #self._l
4343+ end,
4444+4545+ --- Load a font to be used with addText
4646+ ---@param name string The name of the font to load; see the font list section for available font names
4747+ ---@param size integer The size, in vertical pixels, at which the font will render. Note that this size can be changed during script execution with the setFontSize function
4848+ ---@return integer value The id that can be used to uniquely identify the font for use with other API functions
4949+ loadFont = function (self, name, size)
5050+ local font_name = '_F' .. (#self._f + 1)
5151+ self._f[#self._f + 1] = font_name
5252+ self._s = self._s .. 'local ' .. font_name .. '=loadFont("' .. name .. '",' .. size .. ');'
5353+ end,
5454+5555+ --- Return the screen location that is currently raycasted by the player
5656+ ---@return number x, number y A tuple containing the (x, y) coordinates of the cursor, or (-1, -1) if the screen is not currently raycasted
5757+ getCursor = function (self)
5858+ self._s = self._s .. 'local _CX,_CY=getCursor();'
5959+ --cursor x and y are always named _CX and _CY in the RenderScript
6060+ return '_CX','_CY'
6161+ end,
6262+6363+ --- Return the screen's current resolution.
6464+ --- Ideally, your render scripts should be written to adapt to the resolution, as it may change in the future
6565+ ---@return integer width, integer height A tuple containing the (width, height) of the screen's render surface, in pixels
6666+ getResolution = function (self)
6767+ self._s = self._s .. 'local _RX,_RY=getResolution();'
6868+ --resolution x and y are always named _RX and _RY in the RenderScript
6969+ return '_RX','_RY'
7070+ end,
7171+7272+ --- Add a quadratic bezier curve to the given layer.
7373+ --- Supported properties: shadow, strokeColor, strokeWidth
7474+ ---@param layer integer The id of the layer to which to add
7575+ ---@param x1 number X coordinate of the first point of the curve (the starting point)
7676+ ---@param y1 number Y coordinate of the first point of the curve (the starting point)
7777+ ---@param x2 number X coordinate of the second point of the curve (the control point)
7878+ ---@param y2 number Y coordinate of the second point of the curve (the control point)
7979+ ---@param x3 number X coordinate of the third point of the curve (the ending point)
8080+ ---@param y3 number Y coordinate of the third point of the curve (the ending point)
8181+ addBezier = function(self, layer, x1, y1, x2, y2, x3, y3)
8282+ self._s = self._s .. 'addBezier(' .. self._l[layer] .. ',' .. x1 .. ',' .. x2 .. ',' .. y1 .. ',' .. y2 .. ',' .. x3 .. ',' .. y3 .. ');'
8383+ end,
8484+8585+ --- Add a box to the given layer.
8686+ --- Supported properties: fillColor, rotation, shadow, strokeColor, strokeWidth
8787+ ---@param layer integer The id of the layer to which to add
8888+ ---@param x number X coordinate of the box's top-left corner
8989+ ---@param y number Y coordinate of the box's top-left corner
9090+ ---@param sx number Width of the box
9191+ ---@param sy number Height of the box
9292+ addBox = function(self, layer, x, y, sx, sy)
9393+ self._s = self._s .. 'addBox(' .. self._l[layer] .. ',' .. x .. ',' .. y .. ',' .. sx .. ',' .. sy .. ');'
9494+ end,
9595+9696+ --- Add a rounded box to the given layer.
9797+ --- Supported properties: fillColor, rotation, shadow, strokeColor, strokeWidth
9898+ ---@param layer integer The id of the layer to which to add
9999+ ---@param x number X coordinate of the box's top-left corner
100100+ ---@param y number Y coordinate of the box's top-left corner
101101+ ---@param sx number Width of the box
102102+ ---@param sy number Height of the box
103103+ ---@param r number Rounding radius of the box
104104+ addBoxRounded = function (self, layer, x, y, sx, sy, r)
105105+ self._s = self._s .. 'addBoxRounded(' .. self._l[layer] .. ',' .. x .. ',' .. y .. ',' .. sx .. ',' .. sy .. ',' .. r .. ');'
106106+ end,
107107+108108+ --- Add a circle to the given layer.
109109+ --- Supported properties: fillColor, shadow, strokeColor, strokeWidth
110110+ ---@param layer integer The id of the layer to which to add
111111+ ---@param x number X coordinate of the circle's center
112112+ ---@param y number Y coordinate of the circle's center
113113+ ---@param r number Radius of the circle
114114+ addCircle = function(self, layer, x, y, r)
115115+ self._s = self._s .. 'addCircle(' .. self._l[layer] .. ',' .. x .. ',' .. y .. ',' .. r .. ');'
116116+ end,
117117+118118+ --- Add an image to the given layer.
119119+ --- Supported properties: fillColor, rotation
120120+ ---@param layer integer The id of the layer to which to add
121121+ ---@param image integer The id of the image to add
122122+ ---@param x number X coordinate of the image's top-left corner
123123+ ---@param y number Y coordinate of the image's top-left corner
124124+ ---@param sx number Width of the image
125125+ ---@param sy number Height of the image
126126+ addImage = function(self, layer, image, x, y, sx, sy)
127127+ self._s = self._s .. 'addImage(' .. self._l[layer] .. ',' .. image .. ',' .. x .. ',' .. y .. ',' .. sx .. ',' .. sy .. ');'
128128+ end,
129129+130130+ --- Add a sub-region of an image to the given layer.
131131+ --- Supported properties: fillColor, rotation
132132+ ---@param layer integer The id of the layer to which to add
133133+ ---@param image integer The id of the image to add
134134+ ---@param x number X coordinate of the image's top-left corner
135135+ ---@param y number Y coordinate of the image's top-left corner
136136+ ---@param sx number Width of the image
137137+ ---@param sy number Height of the image
138138+ ---@param subX number X coordinate of the top-left corner of the sub-region to draw
139139+ ---@param subY number Y coordinate of the top-left corner of the sub-region to draw
140140+ ---@param subSx number Width of the sub-region within the image to draw
141141+ ---@param subSy number Height of the sub-region within the image to draw
142142+ addImageSub = function(self, layer, image, x, y, sx, sy, subX, subY, subSx, subSy)
143143+ self._s = self._s .. 'addImageSub(' .. self._l[layer] .. ',' .. image .. ',' .. x .. ',' .. y .. ',' .. sx .. ',' .. sy .. ',' .. subX .. ',' .. subY .. ',' .. subSx .. ',' .. subSy .. ');'
144144+ end,
145145+146146+ --- Add a line to the given layer.
147147+ --- Supported properties: rotation, shadow, strokeColor, strokeWidth
148148+ ---@param layer integer The id of the layer to which to add
149149+ ---@param x1 number X coordinate of the start of the line
150150+ ---@param y1 number Y coordinate of the start of the line
151151+ ---@param x2 number X coordinate of the end of the line
152152+ ---@param y2 number Y coordinate of the end of the line
153153+ addLine = function(self, layer, x1, y1, x2, y2)
154154+ self._s = self._s .. 'addLine(' .. self._l[layer] .. ',' .. x1 .. ',' .. y1 .. ',' .. x2 .. ',' .. y2 .. ');'
155155+ end,
156156+157157+ --- Add a quadrilateral to the given layer.
158158+ --- Supported properties: fillColor, rotation, shadow, strokeColor, strokeWidth
159159+ ---@param layer integer The id of the layer to which to add
160160+ ---@param x1 number X coordinate of the first point of the quad
161161+ ---@param y1 number Y coordinate of the first point of the quad
162162+ ---@param x2 number X coordinate of the second point of the quad
163163+ ---@param y2 number Y coordinate of the second point of the quad
164164+ ---@param x3 number X coordinate of the third point of the quad
165165+ ---@param y3 number Y coordinate of the third point of the quad
166166+ ---@param x4 number X coordinate of the fourth point of the quad
167167+ ---@param y4 number Y coordinate of the fourth point of the quad
168168+ addQuad = function(self, layer, x1, y1, x2, y2, x3, y3, x4, y4)
169169+ self._s = self._s .. 'addQuad(' .. self._l[layer] .. ',' .. x1 .. ',' .. y1 .. ',' .. x2 .. ',' .. y2 .. ',' .. x3 .. ',' .. y3 .. ',' .. x4 .. ',' .. y4 .. ');'
170170+ end,
171171+172172+ --- Add a string of text to the given layer.
173173+ --- See setNextTextAlign for information on controlling text anchoring.
174174+ --- Supported properties: fillColor, shadow, strokeColor, strokeWidth
175175+ ---@param layer integer The id of the layer to which to add
176176+ ---@param font integer The id of the font to use
177177+ ---@param text string The string of text to be added
178178+ ---@param x number X coordinate of the text anchor
179179+ ---@param y number Y coordinate of the text anchor
180180+ addText = function(self, layer, font, text, x, y)
181181+ self._s = self._s .. 'addText(' .. self._l[layer] .. ',' .. self._f[font] .. ',' .. text .. ',' .. x .. ',' .. y .. ');'
182182+ end,
183183+184184+ --- Add a triangle to the given layer.
185185+ --- Supported properties: fillColor, rotation, shadow, strokeColor, strokeWidth
186186+ ---@param layer integer The id of the layer to which to add
187187+ ---@param x1 number X coordinate of the first point of the triangle
188188+ ---@param y1 number Y coordinate of the first point of the triangle
189189+ ---@param x2 number X coordinate of the second point of the triangle
190190+ ---@param y2 number Y coordinate of the second point of the triangle
191191+ ---@param x3 number X coordinate of the third point of the triangle
192192+ ---@param y3 number Y coordinate of the third point of the triangle
193193+ addTriangle = function(self, layer, x1, y1, x2, y2, x3, y3)
194194+ self._s = self._s .. 'addTriangle(' .. self._l[layer] .. ',' .. x1 .. ',' .. y1 .. ',' .. x2 .. ',' .. y2 .. ',' .. x3 .. ',' .. y3 .. ');'
195195+ end,
196196+197197+ --- Set the background color of the screen
198198+ ---@param r number Red component, between 0 and 1
199199+ ---@param g number Green component, between 0 and 1
200200+ ---@param b number Blue component, between 0 and 1
201201+ setBackgroundColor = function (self, r, g, b)
202202+ self._s = self._s .. 'setBackgroundColor(' .. r .. ',' .. g .. ',' .. b .. ');'
203203+ end,
204204+205205+ --- Set the default fill color for all subsequent shapes of the given type added to the given layer
206206+ ---@param layer integer The layer for which the default will be set
207207+ ---@param shapeType integer The type of shape to which the default will apply (see ShapeType)
208208+ ---@param r number Red component, between 0 and 1
209209+ ---@param g number Green component, between 0 and 1
210210+ ---@param b number Blue component, between 0 and 1
211211+ ---@param a number Alpha component, between 0 and 1
212212+ setDefaultFillColor = function (self, layer, shapeType, r, g, b, a)
213213+ self._s = self._s .. 'setDefaultFillColor(' .. self._l[layer] .. ',' .. shapeType .. ',' .. r .. ',' .. g .. ',' .. b .. ',' .. a .. ');'
214214+ end,
215215+216216+ --- Set the default rotation for all subsequent shapes of the given type added to the given layer
217217+ ---@param layer integer The layer for which the default will be set
218218+ ---@param shapeType integer The type of shape to which the default will apply (see ShapeType)
219219+ ---@param rotation number Rotation, in radians; positive is counter-clockwise, negative is clockwise
220220+ setDefaultRotation = function (self, layer, shapeType, rotation)
221221+ self._s = self._s .. 'setDefaultRotation(' .. self._l[layer] .. ',' .. shapeType .. ',' .. rotation .. ');'
222222+ end,
223223+224224+ --- Set the default shadow for all subsequent shapes of the given type added to the given layer
225225+ ---@param layer integer The layer for which the default will be set
226226+ ---@param shapeType integer The type of shape to which the default will apply (see ShapeType)
227227+ ---@param radius number The distance that the shadow extends from the shape's border
228228+ ---@param r number Red component, between 0 and 1
229229+ ---@param g number Green component, between 0 and 1
230230+ ---@param b number Blue component, between 0 and 1
231231+ ---@param a number Alpha component, between 0 and 1
232232+ setDefaultShadow = function (self, layer, shapeType, radius, r, g, b, a)
233233+ self._s = self._s .. 'setDefaultShadow(' .. self._l[layer] .. ',' .. shapeType .. ',' .. radius .. ',' .. r .. ',' .. g .. ',' .. b .. ',' .. a .. ');'
234234+ end,
235235+236236+ --- Set the default stroke color for all subsequent shapes of the given type added to the given layer
237237+ ---@param layer integer The layer for which the default will be set
238238+ ---@param shapeType integer The type of shape to which the default will apply (see ShapeType)
239239+ ---@param r number Red component, between 0 and 1
240240+ ---@param g number Green component, between 0 and 1
241241+ ---@param b number Blue component, between 0 and 1
242242+ ---@param a number Alpha component, between 0 and 1
243243+ setDefaultStrokeColor = function (self, layer, shapeType, r, g, b, a)
244244+ self._s = self._s .. 'setDefaultStrokeColor(' .. self._l[layer] .. ',' .. shapeType .. ',' .. r .. ',' .. g .. ',' .. b .. ',' .. a .. ');'
245245+ end,
246246+247247+ --- Set the default stroke width for all subsequent shapes of the given type added to the given layer
248248+ ---@param layer integer The layer for which the default will be set
249249+ ---@param shapeType integer The type of shape to which the default will apply (see ShapeType)
250250+ ---@param strokeWidth number Stroke width, in pixels
251251+ setDefaultStrokeWidth = function (self, layer, shapeType, strokeWidth)
252252+ self._s = self._s .. 'setDefaultStrokeWidth(' .. self._l[layer] .. ',' .. shapeType .. ',' .. strokeWidth .. ');'
253253+ end,
254254+255255+ --- Set the default text alignment of all subsequent text strings on the given layer
256256+ ---@param layer integer The layer for which the default will be set
257257+ ---@param alignH integer Specifies the horizontal anchoring of a text string relative to the draw coordinates; must be one of the following built-in constants: AlignH_Left, AlignH_Center, AlignH_Right
258258+ ---@param alignV integer Specifies the vertical anchoring of a text string relative to the draw coordinates; must be one of the following built-in constants: AlignV_Ascender, AlignV_Top, AlignV_Middle, AlignV_Baseline, AlignV_Bottom, AlignV_Descender
259259+ setDefaultTextAlign = function (self, layer, alignH, alignV)
260260+ self._s = self._s .. 'setDefaultTextAlign(' .. self._l[layer] .. ',' .. alignH .. ',' .. alignV .. ');'
261261+ end,
262262+263263+ --- Set the size at which a font will render.
264264+ --- Impacts all subsequent font-related calls, including addText, getFontMetrics, and getTextBounds.
265265+ ---@param font integer The font for which the size will be set
266266+ ---@param size integer The new size, in vertical pixels, at which the font will render
267267+ setFontSize = function (font, size)
268268+ self._s = self._s .. 'setFontSize(' .. self._f[font] .. ',' .. size .. ');'
269269+ end,
270270+271271+ --- Set a clipping rectangle applied to the layer as a whole.
272272+ --- Layer contents that fall outside the clipping rectangle will not be rendered, and those that are
273273+ --- partially within the rectangle will be 'clipped' against it. The clipping rectangle is applied
274274+ --- before layer transformations. Note that clipped contents still count toward the render cost.
275275+ ---@param layer integer The layer for which the clipping rectangle will be set
276276+ ---@param x number X coordinate of the clipping rectangle's top-left corner
277277+ ---@param y number Y coordinate of the clipping rectangle's top-left corner
278278+ ---@param sx number Width of the clipping rectangle
279279+ ---@param sy number Height of the clipping rectangle
280280+ setLayerClipRect = function (self, layer, x, y, sx, sy)
281281+ self._s = self._s .. 'setLayerClipRect(' .. self._l[layer] .. ',' .. x .. ',' .. y .. ',' .. sx .. ',' .. sy .. ');'
282282+ end,
283283+284284+ --- Set the transform origin of a layer; layer scaling and rotation are applied relative to this origin
285285+ ---@param layer integer The layer for which the origin will be set
286286+ ---@param x number X coordinate of the layer's transform origin
287287+ ---@param y number Y coordinate of the layer's transform origin
288288+ setLayerOrigin = function (self, layer, x, y)
289289+ self._s = self._s .. 'setLayerOrigin(' .. self._l[layer] .. ',' .. x .. ',' .. y .. ');'
290290+ end,
291291+292292+ --- Set a rotation applied to the layer as a whole, relative to the layer's transform origin
293293+ ---@param layer integer The layer for which the rotation will be set
294294+ ---@param rotation number Rotation, in radians; positive is counter-clockwise, negative is clockwise
295295+ setLayerRotation = function (self, layer, rotation)
296296+ self._s = self._s .. 'setLayerRotation(' .. self._l[layer] .. ',' .. rotation .. ');'
297297+ end,
298298+299299+ --- Set a scale factor applied to the layer as a whole, relative to the layer's transform origin.
300300+ --- Scale factors are multiplicative, so that a scale >1 enlarges the size of the layer, 1.0 does nothing, and
301301+ --- <1 reduces the size of the layer.
302302+ ---@param layer integer The layer for which the scale factor will be set
303303+ ---@param sx number Scale factor along the X axis
304304+ ---@param sy number Scale factor along the Y axis
305305+ setLayerScale = function (self, layer, sx, sy)
306306+ self._s = self._s .. 'setLayerScale(' .. self._l[layer] .. ',' .. sx .. ',' .. sy .. ');'
307307+ end,
308308+309309+ --- Set a translation applied to the layer as a whole
310310+ ---@param layer integer The layer for which the translation will be set
311311+ ---@param tx number Translation along the X axis
312312+ ---@param ty number Translation along the Y axis
313313+ setLayerTranslation = function (self, layer, tx, ty)
314314+ self._s = self._s .. 'setLayerTranslation(' .. self._l[layer] .. ',' .. tx .. ',' .. ty .. ');'
315315+ end,
316316+317317+ --- Set the fill color of the next rendered shape on the given layer; has no effect on shapes that do not support a fill color
318318+ ---@param layer integer The layer to which this property applies
319319+ ---@param r number Red component, between 0 and 1
320320+ ---@param g number Green component, between 0 and 1
321321+ ---@param b number Blue component, between 0 and 1
322322+ ---@param a number Alpha component, between 0 and 1
323323+ setNextFillColor = function (self, layer, r, g, b, a)
324324+ self._s = self._s .. 'setNextFillColor(' .. self._l[layer] .. ',' .. r .. ',' .. g .. ',' .. b .. ',' .. a .. ');'
325325+ end,
326326+327327+ --- Set the rotation of the next rendered shape on the given layer; has no effect on shapes that do not support rotation
328328+ ---@param layer integer The layer to which this property applies
329329+ ---@param rotation number Rotation, in radians; positive is counter-clockwise, negative is clockwise
330330+ setNextRotation = function (self, layer, rotation)
331331+ self._s = self._s .. 'setNextRotation(' .. self._l[layer] .. ',' .. rotation .. ');'
332332+ end,
333333+334334+ --- Set the rotation of the next rendered shape on the given layer; has no effect on shapes that do not support rotation
335335+ ---@param layer integer The layer to which this property applies
336336+ ---@param rotation number Rotation, in degrees; positive is counter-clockwise, negative is clockwise
337337+ setNextRotationDegrees = function (self, layer, rotation)
338338+ self._s = self._s .. 'setNextRotationDegrees(' .. self._l[layer] .. ',' .. rotation .. ');'
339339+ end,
340340+341341+ --- Set the shadow of the next rendered shape on the given layer; has no effect on shapes that do not support a shadow
342342+ ---@param layer integer The layer to which this property applies
343343+ ---@param radius number The distance that the shadow extends from the shape's border
344344+ ---@param r number Red component, between 0 and 1
345345+ ---@param g number Green component, between 0 and 1
346346+ ---@param b number Blue component, between 0 and 1
347347+ ---@param a number Alpha component, between 0 and 1
348348+ setNextShadow = function (self, layer, radius, r, g, b, a)
349349+ self._s = self._s .. 'setNextShadow(' .. self._l[layer] .. ',' .. radius .. ',' .. r .. ',' .. g .. ',' .. b .. ',' .. a .. ');'
350350+ end,
351351+352352+ --- Set the stroke color of the next rendered shape on the given layer; has no effect on shapes that do not support a stroke color
353353+ ---@param layer integer The layer to which this property applies
354354+ ---@param r number Red component, between 0 and 1
355355+ ---@param g number Green component, between 0 and 1
356356+ ---@param b number Blue component, between 0 and 1
357357+ ---@param a number Alpha component, between 0 and 1
358358+ setNextStrokeColor = function (self, layer, r, g, b, a)
359359+ self._s = self._s .. 'setNextStrokeColor(' .. self._l[layer] .. ',' .. r .. ',' .. g .. ',' .. b .. ',' .. a .. ');'
360360+ end,
361361+362362+ --- Set the stroke width of the next rendered shape on the given layer; has no effect on shapes that do not support a stroke width
363363+ ---@param layer integer The layer to which this property applies
364364+ ---@param strokeWidth number Stroke width, in pixels
365365+ setNextStrokeWidth = function (self, layer, strokeWidth)
366366+ self._s = self._s .. 'setNextStrokeWidth(' .. self._l[layer] .. ',' .. strokeWidth .. ');'
367367+ end,
368368+369369+ --- Set the text alignment of the next rendered text string on the given layer.
370370+ --- By default, text is anchored horizontally on the left, and vertically on the baseline
371371+ ---@param layer integer The layer to which this property applies
372372+ ---@param alignH AlignH Specifies the horizontal anchoring of a text string relative to the draw coordinates; must be one of the following built-in constants: AlignH_Left, AlignH_Center, AlignH_Right
373373+ ---@param alignV AlignV Specifies the vertical anchoring of a text string relative to the draw coordinates; must be one of the following built-in constants: AlignV_Ascender, AlignV_Top, AlignV_Middle, AlignV_Baseline, AlignV_Bottom, AlignV_Descender
374374+ setNextTextAlign = function (self, layer, alignH, alignV)
375375+ self._s = self._s .. 'setNextTextAlign(' .. self._l[layer] .. ',' .. alignH .. ',' .. alignV .. ');'
376376+ end,
377377+378378+ --************************************************************************************************************
379379+ -- Joker function that is here to permit all the things that are not doable with the other functions
380380+ --************************************************************************************************************
381381+382382+ --- Add a line of code to the renderscript as a string
383383+ ---@param line string The line of code to add
384384+ insertCodeLine = function(self, line)
385385+ self._s = self._s .. line .. '\n'
386386+ end,
387387+388388+ --************************************************************************************************************
389389+ -- utilities to add to the renderscript that are not by default in game
390390+ --************************************************************************************************************
391391+392392+ --- Return the maximum size of a renderscript
393393+ ---@return integer The maximum size of a renderscript, in characters
394394+ getMaxSize = function(self)
395395+ return 50000
396396+ end,
397397+398398+ --- Return whether the renderscript is too long
399399+ ---@return boolean Whether the renderscript is too long
400400+ isTooLong = function(self)
401401+ return #self._s > 50000
402402+ end,
403403+404404+ --- Return the current size of the renderscript
405405+ ---@param screen Screen The screen to which to send the renderscript
406406+ sendToScreen = function(self, screen)
407407+ screen.setRenderScript(self._s)
408408+ end,
409409+ },
410410+ __tostring = function(self)
411411+ return self._s
412412+ end,
413413+ __len = function(self)
414414+ return #self._s
415415+ end,
416416+}