Micro LUA DS Documentation
Some useful variables
SCREEN_WIDTH: width of the screens
SCREEN_HEIGHT: height of the screens
NB_FPS: number of frame per second automatically updated each second. You can display it with a screen.print between screen.startDrawing() and screen.stopDrawing(). Don’t display it in the debug console
SCREEN_UP, SCREEN_DOWN and SCREEN_BOTH: screen number where to draw. See examples for more details
RAM and VRAM: destination where to load some object. See examples for more details
screen.spaceBetweenScreens: space between screens in pixel where using SCREEN_BOTH. Can be modify. 0 by default
The screen
(All methods are shared)
Void screen.startDrawing() & screen.stopDrawing()
All your drawing instructions must be between these two functions
Void screen.switch()
Switch the screens
Void screen.print(screen, x, y, text [, color] [, font])
Print a text on the screen
screen (Number): screen where to draw (SCREEN_UP or SCREEN_DOWN)
x (Number): x-coordinate where to draw
y (Number): y-coordinate where to draw
text (String): text to print
color (Color): color of the text
font (Font) : special font
Void screen.blit(screen, x, y, image, [, sourcex, sourcey] [, width, height])
Blit an image on the screen
screen (Number): screen where to draw (SCREEN_UP or SCREEN_DOWN)
x (Number): x-coordinate where to draw
y (Number): y-coordinate where to draw
image (Image): image to blit
sourcex, sourcey (Number): coordinates in the source image to draw
width, height (Number): width and height of the rectangle to draw
Void screen.drawLine(screen, x0, y0, x1, y1, color)
Draw a line on the screen
screen (Number): screen where to draw (SCREEN_UP or SCREEN_DOWN)
x0, y0, x1, y1 (Number): coordinates of the line
color (Color): color of the line
Void screen.drawRect(screen, x0, y0, x1, y1, color)
Draw a rectangle on the screen
screen (Number): screen where to draw (SCREEN_UP or SCREEN_DOWN)
x0, y0, x1, y1 (Number): coordinates of the rectangle
color (Color): color of the rectangle
Void screen.drawFillRect(screen, x0, y0, x1, y1, color)
Draw a fill rectangle on the screen
screen (Number): screen where to draw (SCREEN_UP or SCREEN_DOWN)
x0, y0, x1, y1 (Number): coordinates of the rectangle
color (Color): color of the rectangle
Void drawGradientRect(screen, x0, y0, x1, y1, color1, color2, color3, color4)
Draw a gradient rectangle on the screen
screen (Number): screen where to draw (SCREEN_UP or SCREEN_DOWN)
x0, y0, x1, y1 (Number): coordinates of the rectangle
color1, color2, color3, color4 (Color): colors of the rectangle
Void drawTextBox(screen, x0, y0, x1, y1, text [, color])
Draw a text box on the screen
screen (Number): screen where to draw (SCREEN_UP or SCREEN_DOWN)
x0, y0, x1, y1 (Number): coordinates of the text box
text (String): text to print
color (Color): color of the text box
Colors
Color Color.new(r, g, b)
Create a new color
r (Number): red mask
g (Number): green mask
b (Number): blue mask
Number color:getR()
Get the red mask
Number color:getG()
Get the gree mask
Number color:getB()
Get the blue mask
Controls
Void Controls.read()
Read the controls and update all control structures
Stylus:
Stylus.X: x-coordinate of the stylus
Stylus.Y: y-coordinate of the stylus
Stylus.held: is the stylus held on the screen
Stylus.released: is the stylus released
Stylus.doubleClick: true if stylus do a double click
Stylus.deltaX: delta x of the stylus movement
Stylus.deltaY: delta y of the stylus movement
Stylus.newPress: true if stylus do a new press
Keys:
([KEY] can take the following values :
A B X Y R L Start Select Up Down Left Right)
Keys.held.[KEY]: is the key held
Keys.released.[KEY]: is the key released
Keys.newPress.[KEY]: true if key do a new press
Images
Image Image.load(path, destination)
Create a new image in memory from an image file (PNG, JPG or GIF)
path (String): path of the image to load
dest (Number): destination of the image in memory (can be RAM of VRAM)
Void image:destroy()
Desotroy the image
To completely destroy an image, do :
myImage:desotroy()
myImage = nil
Number image:width()
Get the width of the image
Number image:height()
Get the height of the image
Void image:scale(width, height)
Scale the image
width (Number): new width of the image
height (Number): new height of the image
Void image:rotate(angle [, centerx, centery])
Rotate the image around rotation center
angle (Number): angle of roattion (between 0 and 511)
centerx (Number): x-coordinate of the new rotation center
centery (Number): y-coordinate of the new rotation center
Void image:rotateDegree(angle [, centerx, centery])
Rotate the image around rotation center, the angle is given in degree
angle (Number): angle of rotation in degree (between 0 and 360)
centerx (Number): x-coordinate of the new rotation center
centery (Number): y-coordinate of the new rotation center
Void image:mirrorH()
Mirror the image horizontally
Void image:mirrorV()
Mirror the image vertically
Void image:setTint(color)
Set the tint of the image
color (Color): color of the image
Millisecond Timers
Timer Timer.new()
Create a new timer, you can start it
Number timer:time()
Return the time of the timer
Void timer:start()
Start a timer
Void timer:stop()
Stop a timer
Void timer:reset()
Reset a timer
Sprites
Sprite Sprite.new(path, frameWidth, frameHeight, dest)
Create a sprite from an image file
path (String): path of the file which contains the sprite
frameWidth (Number): width of the frames
frameHeight (Number): height of the frames
dest (Number): destination (RAM or VRAM)
Void sprite:drawFrame(screen, x, y, nbFrame)
Draw a frame of the sprite
screen (Number): screen (SCREEN_UP or SCREEN_DOWN)
x (Number): X-coordinate where to draw the frame
y (Number): Y-coordinate where to draw the frame
nbFrame (Number): number of the frame to draw
Void sprite:addAnimation(tabAnim, delay)
Create an animation
tabAnim (Table): the table of the animation frames
delay (Number): delay between each frame
Void sprite:playAnimation(screen, x, y, nbAnim)
Play an animation on the screen
screen (Number): screen (SCREEN_UP or SCREEN_DOWN)
x (Number): X-coordinate where to draw the frame
y (Number): Y-coordinate where to draw the frame
nbAnim (Number): number of the animation to play
Void sprite:resetAnimation(nbAnim)
Reset an animation
nbAnim (Number): number of the animation
Void sprite:startAnimation(nbAnim)
Start an animation
nbAnim (Number): number of the animation
Void sprite:stopAnimation(nbAnim)
Stop an animation
nbAnim (Number): number of the animation
Boolean sprite:isAnimationAtEnd(nbAnim)
Return true if the animation has drawn the last frame
nbAnim (Number): number of the animation
Debug
(All methods are shared)
Void Debug.ON()
Activate the debug mode
Void Debug.OFF()
Desactivate the debug mode
Void Debug.print(text)
Print a debug line
text (String): text to print
Void Debug.clear()
Clear the debug console
Void Debug.setColor(color)
Set the debug text color
color (Color): color of the text
System
(Al methods are shared)
String System.currentDirectory()
Get the current working directory
Void System.changeDirectory(path)
Change the current working directory
path (String): path of the directory
Void System.remove(name)
Remove a file or an empty folder
name (String): name of the file or directory to remove
Void System.rename(oldName, newName)
Rename file or an empty folder
oldName (String): name of the file or directory to rename
newName (String): new name of the file or directory
Void System.makeDirectory(name)
Create a new directory
name (String): path and name of the directory
Table System.listDirectory(path)
List all files and folders of a directory
path (String): path of the directory to list
(See examples for more details)
Keyboard
(All methods are shared)
String Keyboard.input(maxLength, normalColor, pressedColor, bgColorUp, bgColorDown, textColorUp, textColorDown)
Draw a keyboard. The user can enter a string. The function returns this string
maxLength (Number): max length of the string entered
normalColor (String): color of the keyboard (Keyboard.color.[COLOR] where [COLOR] can be gray, red, blue, green or yellow)
pressedColor (String): color of the pressed keys (Keyboard.color.[COLOR] where [COLOR] can be gray, red, blue, green or yellow)
bgColorUp (Color): color of the background of the upper screen
bgColorDown (Color): color of the background of the upper lower
textColorUp (Color): color of the text of the upper screen
textColorDown (Color): color of the text of the lower screen
Fonts
Font Font.load(path)
Create a new font from a font file (oslib and µLibrayr format)
Path (String): path of the file to load
Void font:print(screen, x, y, text [, color])
Print a text with a special font
screen (Number): screen where to draw (SCREEN_UP or SCREEN_DOWN)
x (Number): x-coordinate where to draw
y (Number): y-coordinate where to draw
text (String): text to print
color (Color): color of the text
Number font:getCharHeight()
Get the height of the characters of a font
Maps
Map Map.new(image, mapfile, width, height, tileWidth, tileHeight)
Create a new map by giving a map file
image (Image): image which contains tiles
mapfile (String): path to the map file (.map)
width (Number): width of the map in tile
height (Number): height of the map in tile
tileWidth (Number): width of the tiles in pixel
tileHeight (Number): height of the tiles in pixel
Void map:destroy()
Destroy a map
Void map:draw(screen, x, y, width, height)
Draw a map
screen (Number): screen where to draw (SCREEN_UP or SCREEN_DOWN)
x (Number): x-coordinate where to draw the map
y (Number): y-coordinate where to draw the map
width (Number): x number of tiles to draw
height (Number): y number of tiles to draw
Void map:scroll(x, y)
Scroll a map
x (Number): x number of tiles to scroll
y (Number): y number of tiles to scroll
Void map:space(x, y)
Set the space between each tiles of a map
x (Number): x space between tiles
y (Number): y space between tiles
Void map:setTile(x, y, tile)
Change a tile value
x (Number): x-coordinate of the tile to change in the map table
y (Number): y-coordinate of the tile to change in the map table
tile (Number): new tile value
Sound: Mods
(all methods are shared)
Module Mod.load(path)
Load a module in RAM
path (String): path of the mod file (it can be all files used by mikmod library)
Void Mod.destroy(module)
Destroy a module
module (Module): module to destroy
Module Mod.getModule()
Get the played module
Void Mod.play(module)
Play a module
module (Module): moldule to play
Void Mod.stop()
Stop the player
Void Mod.pauseResume()
Pause or resume the player
Number Mod.isActive()
Is the player active. Return 1 if the player is active or 0 if not.
Number Mod.isPaused()
Is the player paused. Return 1 if the player is paused or 0 if not.
Void Mod.nextPosition()
Move the player to the next position of the played module
Void Mod.previousPosition()
Move the player to the previous position of the played module
Void Mod.setPosition(position)
Set the current position in the played module
position (Number): new position
Void Mod.setVolume(volume)
Change the volume of the player
volume (Number): new volume between 0 and 128
Void Mod.setSpeed(speed)
Change the speed of the player
speed (Number): new speed between 1 and 32
Void Mod.setTempo(tempo)
Change the tempo of the player
tempo (Number): new tempo between 32 and 255
Number Mod.time(module)
Get the elapsed time in milliseconds of a module
module (Module): module to use