Menu

API471 Log in to Edit

Description of the functions provided by MicroLua as of version 4.7.1.

The variables or functions that you will find here may be defined either in the Lua libraries (libs tag) or in the C code (nds tag).
Some are also tagged as deprecated, or as unused because you are not meant to access them directly.

Constants and Variables

  • ULUA_VERSION (nds): version of Micro Lua as a String; usually of the form MicroLua X.X.X
  • SCREEN_WIDTH, SCREEN_HEIGHT (nds): width and height of the screens
  • NB_FPS (libs): number of frame per second automatically updated every second
  • SCREEN_UP, SCREEN_DOWN (nds): screen number where to draw; see examples for more details
  • RAM and VRAM (nds): destination where to load some object; see examples for more details
  • ATTR_X1, ATTR_Y1, ATTR_X2, ATTR_Y2, ATTR_X3, ATTR_Y3, ATTR_COLOR, ATTR_COLOR1, ATTR_COLOR2, ATTR_COLOR3, ATTR_COLOR4, ATTR_TEXT, ATTR_VISIBLE, ATTR_FONT, ATTR_IMAGE (nds): attributes used in canvas
  • ALPHA_RESET (nds): blending coefficient value to reset alpha transparency; is equal to 100
  • PLAY_LOOP, PLAY_ONCE (nds): arguments to play mods respectively loop and once
  • LED_ON, LED_BLINK, LED_SLEEP (nds): blink modes for the LED (always ON, blinking fast, blinking slow)
  • Path constants (some of them are made up from precedent ones) (nds):
    • ULUA_DIR: /lua/ (main directory of µLua)
    • ULUA_SCRIPTS: ULUA_DIR scripts/ (default folder for scripts)
    • ULUA_LIBS: ULUA_DIR libs/ (default folder for libraries)
    • ULUA_BOOT_FILE: boot.lua (first loaded file)
    • ULUA_BOOT_FULLPATH: ULUA_DIR ULUA_BOOTFILE (full path of the first loaded file)
  • System.EFS (nds): tells whether an Embedded File System is included
  • mustCountFPS (libs, unused): regulate the FPS counting system; it is an internal variable, you should never have to deal with it
  • Debug.isDebugOn, Debug.debugText and Debug.debugColor (nds, unused): variables used by the debug system; you should only modify them by using the Debug functions

Functions and their tables

Screen

Void render() (libs)
Refresh the screen.

Void startDrawing(), Void stopDrawing() (libs, deprecated)
All your drawing instructions must be between these two functions.

Void screen.switch() (nds)
Switch the screens.

Number screen.getLayer() (nds)
Get the current layer.

Number screen.getAlphaLevel() (nds)
Get the current transparency level.

Void screen.setAlpha(level[, layer]) (nds)
Set the transparency level for the given layer.

  • level (Number): blending coefficient, between 0 and 99 (100, that is to say ALPHA_RESET, reset all the transparency system)
  • layer (Number): layer to set; the function however automatically keeps the count so you don't have to give and layer

Void screen.print(screen, x, y, text [, color]) (nds)
Print a text on the screen.

  • screen (Constant / 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

Void screen.printFont(screen, x, y, text , color, font) (nds)
Print a text on the screen using a special font.

  • screen (Constant / 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]) (nds)
Blit an image on the screen.

  • screen (Constant / 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.drawPoint(screen, x, y, color) (nds)
Draw a point on the screen.

  • screen (Constant / Number): screen where to draw (SCREEN_UP or SCREEN_DOWN)
  • x (Number): x-coordinate where to draw
  • y (Number): y-coordinate where to draw
  • color (Color): color of the point

Void screen.drawLine(screen, x0, y0, x1, y1, color) (nds)
Draw a line on the screen.

  • screen (Constant / 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) (nds)
Draw a rectangle on the screen.

  • screen (Constant / 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) (nds)
Draw a fill rectangle on the screen.

  • screen (Constant / 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.drawGradientRect(screen, x0, y0, x1, y1, color1, color2, color3, color4) (nds)
Draw a gradient rectangle on the screen.

  • screen (Constant / 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 screen.drawTextBox(screen, x0, y0, x1, y1, text [, color]) (nds)
Draw a text box on the screen.

  • screen (Constant / 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

Void screen.drawTexturedQuad(screen, x0, y0, x1, y1, x2, y2, x3, y3, texture[, sourceX, sourceY][, width, height]) (nds)
Display a textured quadrilateral.

  • screen (Constant / Number): screen where to draw (SCREEN_UP or SCREEN_DOWN)
  • x0, y0, x1, y1, x2, y2, x3, y3 (Number): coordinates of the quadrilateral angles
  • texture (Image): texture image
  • sourcex, sourcey (Number): coordinates in the texture image to draw
  • width, height (Number): width and height of the texture image piece to draw

Void screen.drawTexturedTriangle(screen, x0, y0, x1, y1, x2, y2, texture[, sourceX, sourceY][, width, height]) (nds)
Display a textured triangle.

  • screen (Constant / Number): screen where to draw (SCREEN_UP or SCREEN_DOWN)
  • x0, y0, x1, y1, x2, y2 (Number): coordinates of the triangle angles
  • texture (Image): texture image
  • sourcex, sourcey (Number): coordinates in the texture image to draw
  • width, height (Number): width and height of the texture image piece to draw

Boolean screen.getMainLcd() (nds)
Give the screen the µLibrary is drawing on (true for upper screen, false for the lower screen).

Void screen.setSpaceBetweenScreens(space) (nds, deprecated (you can no longer draw on the two screens at the same time))
Set the space between the screens (so some drawing will not be displayed if drawn in this space).

  • space (Number): space (in pixels) between the screens

Void screen.init() (nds, unused)
Initialise some stuff about the screens. It is done automatically, so you should have nothing to care about this.

Void screen.startDrawing2D() (nds, unused)
Start a new drawing and configure 2D. You should have nothing to care about this.

Void screen.endDrawing() (nds, unused)
End drawing. You will never need to use it (use render() to command screens actualisation).

Void screen.waitForVBL() (nds, unused)
Wait for the VBlank period to reach 60FPS. You will never need to use it (using render() will synchronise the frames).

Colors

Color Color.new(r, g, b) (nds)
Create a new color.

  • r (Number): red mask (from 0 to 31)
  • g (Number): green mask (from 0 to 31)
  • b (Number): blue mask (from 0 to 31)

Color Color.new256(r, g, b) (nds)
Create a new color from 8bit values.

  • r (Number): red mask (from 0 to 255)
  • g (Number): green mask (from 0 to 255)
  • b (Number): blue mask (from 0 to 255)

Controls

Void Controls.read() (nds)
Read the controls and update all control structures.

Void Controls.setStylusDblcFreq(dblcFreq) (nds)
Set the maximum delay between two Stylus clicks to make it a double click.

  • dblcFreq (Number): maximum delay (from 0 to 30, 30 being half a second and the default value)

Stylus

These are numbers or booleans. Everything here is defined in the nds.

  • 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

These are booleans. Everything here is defined in the nds.

[KEY] can take one of the following values:

  • A
  • B
  • X
  • Y
  • L
  • R
  • Start
  • Select
  • Up
  • Down
  • Left
  • Right
  • Lid

And then the state of a key can be checked using these subtables:

  • Keys.held.[KEY]: is the key held?
  • Keys.released.[KEY]: is the key released?
  • Keys.newPress.[KEY]: true if the key does a new press

Images

Image Image.load(path, destination) (nds)
Create a new image in memory from an image file (PNG, JPG or GIF).

  • path (String): path of the image to load
  • destination (Number): destination of the image in memory (can be RAM of VRAM)

Void Image.destroy(image) (nds)
Destroy the image.

  • image (Image): image to destroy

Number Image.width(image) (nds)
Get the width of the image.

  • image (Image): image to use

Number Image.height(image) (nds)
Get the height of the image.

  • image (Image): image to use

Void Image.scale(image, width, height) (nds)
Scale the image.

  • image (Image): image to scale
  • width (Number): new width of the image
  • height (Number): new height of the image

Void Image.rotate(image, angle [, centerx, centery]) (nds)
Rotate the image around rotation center.

  • image (Image): image to rotate
  • 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(image, angle [, centerx, centery]) (nds)
Rotate the image around rotation center, the angle is given in degree.

  • image (Image): image to rotate
  • 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(image, activate) (nds)
Mirror the image horizontally.

  • image (Image): image to mirror
  • activate (Boolean): true to activate the mirroring, false to cancel the transformation

Void Image.mirrorV(image, activate) (nds)
Mirror the image vertically.

  • image (Image): image to mirror
  • activate (Boolean): true to activate the mirroring, false to cancel the transformation

Void Image.setTint(image, color) (nds)
Set the tint of the image.

  • image (Image): image to tint
  • color (Color): color of the image

Timers

The unit is the millisecond. The return value is a decimal number, not an integer, but no lower precision than 1ms can be guaranteed.

Timer Timer.new([time]) (libs)
Create a new timer, with the specified time if given.

  • time (Number): initial time of the Timer, in millisecond.

Number timer:getTime() (libs)
Return the time of the timer.

Void timer:start() (libs)
Start a timer.

Void timer:stop() (libs)
Stop a timer.

Void timer:reset([time]) (libs)
Reset a timer, to 0 or to time if given.

  • time (Number): initial time of the Timer, in millisecond.

Sprites

Sprite Sprite.new(graph, frameWidth, frameHeight, dest) (libs)
Create a sprite from an image file or an Image resource.

  • graph (String or Image): path of the file which contains the sprite; or already loaded Image resource
  • frameWidth (Number): width of the frames
  • frameHeight (Number): height of the frames
  • dest (Number): destination (RAM or VRAM)

Void sprite:destroy() (libs)
Destroy the Sprite.

Void sprite:drawFrame(screen, x, y, nbFrame) (libs)
Draw a frame of the sprite.

  • screen (Constant / 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) (libs)
Create an animation.

  • tabAnim (Table): the table of the animation frames
  • delay (Number): delay between each frame

Void sprite:playAnimation(screen, x, y, nbAnim) (libs)
Play an animation on the screen.

  • screen (Constant / 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) (libs)
Reset an animation.

  • nbAnim (Number): number of the animation

Void sprite:startAnimation(nbAnim) (libs)
Start an animation.

  • nbAnim (Number): number of the animation

Void sprite:stopAnimation(nbAnim) (libs)
Stop an animation.

  • nbAnim (Number): number of the animation

Boolean sprite:isAnimationAtEnd(nbAnim) (libs)
Return true if the animation has drawn the last frame.

  • nbAnim (Number): number of the animation

Number sprite:getWidth() (libs)
Return the width of the frames as given to Sprite.new().

Number sprite:getHeight() (libs)
Return the height of the frames as given to Sprite.new().

Table SpriteAnimation.new(tabAnim, delay) (libs, unused)
Create a new sprite animation. You don't have to use it, use sprite:addAnimation() instead.

  • tabAnim (Table): table containing the animation frames
  • delay (Number): delay between each frame

Debug

Void Debug.ON() (libs)
Activate the debug mode.

Void Debug.OFF() (libs)
Deactivate the debug mode.

Void Debug.print(text) (libs)
Print a debug line.

  • text (String): text to print

Void Debug.clear() (libs)
Clear the debug console.

Void Debug.setColor(color) (libs)
Set the debug text color.

  • color (Color): color of the text

System

String System.currentDirectory() (nds)
Get the current working directory.

Void System.changeDirectory(path) (nds)
Change the current working directory.

  • path (String): path of the directory

Void System.remove(name) (nds)
Remove a file or an empty folder.

  • name (String): name of the file or directory to remove

Void System.rename(oldName, newName) (nds)
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) (nds)
Create a new directory.

  • name (String): path and name of the directory

Table System.listDirectory(path) (nds)
List all files and folders of a directory.

  • path (String): path of the directory to list

NOTE: See examples for more details.

Number System.CurrentVramUsed() (nds)
Give the current amount of used VRAM (seems to return some weird number).

Number System.CurrentVramFree() (nds)
Give the current amount of free VRAM.

Number System.CurrentPalUsed() (nds)
Give the current amount of used palette memory (seems to return some weird number).

Number System.CurrentPalFree() (nds)
Give the current amount of free palette memory.

Void System.setLedBlinkMode(mode) (nds)
Set the blink mode for the LED.

  • mode (Number): the blink mode; choose between LED_ON, LED_BLINK and LED_SLEEP

Void System.shutDown() (nds)
Shutdown the console.

Void System.sleep() (nds)
Put the system in sleep state.

Fonts

Font Font.load(path) (nds)
Create a new font from a font file (oslib and µLibrary format).

  • path (String): path of the file to load

Void Font.destroy(font) (nds)
Destroy the font.

  • font (Font): font to destroy

Number Font.getCharHeight(font) (nds)
Get the height of the characters of a font.

  • font (Font): font to use

Number getStringWidth(font, text) (nds)
Get the width of a text with a specific font.

  • font (Font): font to use
  • text (String): text

Maps

Map Map.new(image, mapfile, width, height, tileWidth, tileHeight) (nds)
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 tiles
  • height (Number): height of the map in tiles
  • tileWidth (Number): width of the tiles in pixels
  • tileHeight (Number): height of the tiles in pixels

Void Map.destroy(map) (nds)
Destroy a map.

  • map (Map): map to destroy

Void Map.draw(screen, map, x, y, width, height) (nds)
Draw a map.

  • screen (Constant / Number): screen where to draw (SCREEN_UP or SCREEN_DOWN)
  • map (Map): map to destroy
  • 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(map, x, y) (nds)
Scroll a map.

  • map (Map): map to scroll
  • x (Number): x number of tiles to scroll
  • y (Number): y number of tiles to scroll

Void Map.space(map, x, y) (nds)
Set the space between each tiles of a map.

  • map (Map): map to modify
  • x (Number): x space between tiles
  • y (Number): y space between tiles

Void Map.setTile(map, x, y, tile) (nds)
Change a tile value.

  • map (Map): map to modify
  • 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

Number Map.getTile(map, x, y) (nds)
Get a tile value.

  • map (Map): map to read
  • x (Number): x-coordinate of the tile to get
  • y (Number): y-coordinate of the tile to get

Scroll Maps

ScrollMap ScrollMap.new(image, mapfile, width, height, tileWidth, tileHeight) (nds)
Create a new ScrollMap 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 tiles
  • height (Number): height of the map in tiles
  • tileWidth (Number): width of the tiles in pixels
  • tileHeight (Number): height of the tiles in pixels

Void ScrollMap.destroy(scrollmap) (nds)
Destroy a ScrollMap.

  • scrollmap (ScrollMap): ScrollMap to destroy

Void ScrollMap.draw(screen, scrollmap) (nds)
Draw a ScrollMap.

  • screen (Constant / Number): screen where to draw (SCREEN_UP or SCREEN_DOWN)
  • scrollmap (ScrollMap): ScrollMap to draw

Void ScrollMap.scroll(scrollmap, x, y) (nds)
Scroll a ScrollMap.

  • scrollmap (ScrollMap): ScrollMap to scroll
  • x (Number): x-coordinate of the upper-left corner of the map (can be a negative value)
  • y (Number): y-coordinate of the upper-left corner of the map (can be a negative value)

Void ScrollMap.setTile(scrollmap, x, y, tile) (nds)
Change a tile value.

  • scrollmap (ScrollMap): ScrollMap to modify
  • x (Number): x-coordinate of the tile to change in the scrollmap table
  • y (Number): y-coordinate of the tile to change in the scrollmap table
  • tile (Number): new tile value

Number ScrollMap.getTile(scrollmap, x, y) (nds)
Get a tile value.

  • scrollmap (ScrollMap): ScrollMap to read
  • x (Number): x-coordinate of the tile to get
  • y (Number): y-coordinate of the tile to get

Canvas

Canvas Canvas.new() (nds)
Create a new canvas.

Void Canvas.destroy(canvas) (nds)
Destroy a canvas.

  • canvas (Canvas): canvas to destroy

CanvasObject Canvas.newLine(x1, y1, x2, y2, color) (nds)
Create a new line.

  • x1, y1, x2, y2 (Number): coordinates of the line
  • color (Color): color of the line

CanvasObject Canvas.newPoint(x1, y1, color) (nds)
Create a new point.

  • x1, y1 (Number): coordinates of the point
  • color (Color): color of the point

CanvasObject Canvas.newRect(x1, y1, x2, y2, color) (nds)
Create a new rectangle.

  • x1, y1, x2, y2 (Number): coordinates of the rectangle
  • color (Color): color of the rectangle

CanvasObject Canvas.newFillRect(x1, y1, x2, y2, color) (nds)
Create a new fill rectangle.

  • x1, y1, x2, y2 (Number): coordinates of the rectangle
  • color (Color): color of the rectangle

CanvasObject Canvas.newGradientRect(x1, y1, x2, y2, color1, color2, color3, color4) (nds)
Create a new gradient rectangle.

  • x1, y1, x2, y2 (Number): coordinates of the rectangle
  • color1, color2, color3, color4 (Color): colors of the fill rectangle

CanvasObject Canvas.newText(x1, y1, text [, color]) (nds)
Create a new text.

  • x1, y1 (Number): coordinates of the text
  • text (String): text
  • color (Color): color of the text

CanvasObject Canvas.newTextFont(x1, y1, text, color, font) (nds)
Create a new text with a special font.

  • x1, y1 (Number): coordinates of the text
  • text (String): text
  • color (Color): color of the text
  • font (Font): special font of the text

CanvasObject Canvas.newTextBox(x1, y1, x2, y2, text [, color]) (nds)
Create a new textbox.

  • x1, y1, x2, y2 (Number): coordinates of the textbox
  • text (String): text
  • color (Color): color of the textbox

CanvasObject Canvas.newImage(x1, y1, image [, x2, y2] [, x3, y3]) (nds)
Create a new image.

  • x1, y1 (Number): coordinates of the image
  • x2, y2 (Number): coordinates in the source image to draw
  • x3, y3 (Number): width and height of the rectangle to draw

Void Canvas.add(canvas, object) (nds)
Add a CanvasObject in a canvas.

  • canvas (Canvas): canvas to draw
  • object (CanvasObject): object to add

Void Canvas.draw(screen, canvas, x, y) (nds)
Draw a canvas to the screen.

  • screen (Constant / Number): screen where to draw (SCREEN_UP or SCREEN_DOWN)
  • canvas (Canvas): canvas to draw
  • x (Number): x-coordinate where to draw
  • y (Number): y-coordinate where to draw

Void Canvas.setAttr(object, attrName, attrValue) (nds)
Set an attribute value.

  • object (CanvasObject): object to modify
  • attName (Constant / Number): attribute to modify; must be ATTR_XXX. See Variables for more details
  • attrValue (?): new value for the attribute; must be the good type

? Canvas.getAttr(object, attrName) (nds)
Get an attribute value. Return type depends of the attribute (number, font or image).

  • object (CanvasObject): object to use
  • attName (Constant / Number): attribute to get value. Must be ATTR_XXX. See Variables for more details

Void Canvas.setObjOnTop(canvas, object) (nds)
Make a CanvasObject on the first plan of a Canvas.

  • canvas (Canvas): Canvas in which we work.
  • object (CanvasObject): Object that we want to set on Top.

Void Canvas.removeObj(canvas, object) (nds)
Delete an CanvasObject in a Canvas.

  • canvas (Canvas): Canvas in which we want to delete an Object.
  • object (CanvasObject): Object that we want to delete.

Rumble

Boolean Rumble.isInserted() (nds)
Check if a rumble pack is inserted.

Void Rumble.set(status) (nds)
Set the rumble status.

  • status (Boolean): status of the rumble (true: ON, false: OFF)

Motion

Boolean Motion.init (nds)
Init the motion system if a motion device is detected. Return true if a motion device is detected.

Void Motion.calibrate (nds)
Calibrate the motion system.

Number Motion.readX (nds)
Read the X tilt of the motion.

Number Motion.readY (nds)
Read the Y tilt of the motion.

Number Motion.readZ (nds)
Read the Z tilt of the motion.

Number Motion.accelerationX (nds)
Read the X acceleration of the motion.

Number Motion.accelerationY (nds)
Read the Y acceleration of the motion.

Number Motion.accelerationZ (nds)
Read the Z acceleration of the motion.

Number Motion.readGyro (nds)
Read the gyro value of the motion.

Number Motion.rotation (nds)
Read the rotation value of the motion.

Wifi

Void Wifi.connectWFC() (nds)
Connect the DS to the Wifi connection. Use the firmware configuration. So, you need to configure your connection with an official DS game.

Void Wifi.initDefault() (nds)
Init the DS Wifi system. Must be done before all Wifi functions except Wifi.connectWFC(). Don't use with Wifi.connectWFC().

Void Wifi.autoConnectWFC() (nds)
Same as Wifi.connectWFC() but used after Wifi.initDefault().

String Wifi.status() (nds)
Get the Wifi association status.

Void Wifi.scanAP() (nds)
Set the DS in scan mode for AP detection (Access Points such as Livebox, Freebox, Neufbox...). When starting, the DS searches all the time but doesn't warn for a found connection.

Number Wifi.getNumAP() (nds)
Return the number of AP found after a Wifi.scanAP(). The search may be long.

Tableau Wifi.newAP() (nds)
Return an empty table with AP data. There are:

  • ssid (String): name of the network's AP
  • bssid (String):
  • macaddr (String): MAC address of the AP
  • channel (Number): network channel number
  • rssi (Number): signal strength
  • maxrate (Number): communication speed (1M or 2M)
  • protection (String): Wifi protection (NONE, WEP, WPA)
  • adhoc (Boolean): is the connection adhoc (true) or not (false)
  • active (Boolean): is the connection active (true) or not (false)

Tableau Wifi.getAP(numap) (nds)
Return data about the AP with the number numap found by Wifi.scanAP().

  • numap (Number): number of the AP.

Number Wifi.connectAP(numap, numkey, key) (nds)
Make a association request to the AP of index numap with the key number numkey and the WEP key key.
If you intend to associate with an unprotected AP set numkey to 1 and key to an empty String ("").
numkey must be between 1 and 4, but the first key is more often used.
Return -1 if the association is refused.

  • numap (Number): AP number
  • numkey (Number): key number
  • key (String): WEP key.

Void Wifi.disconnect() (nds)
Disconnect the DS from the Wifi connection.

Void Wifi.stop() (nds)
Disengage the Wifi.

String Wifi.getLocalConf(choice) (nds)
Return data of the DS connection.

  • choice (Number):
    • 1: console's IP.
    • 2: gateway.
    • 3: subnet mask.
    • 4: first DNS.
    • 5: second DNS.
    • 6: MAC address of the console

Void Wifi.resetIP() (nds)
Reset the IP, GateWay, SubnetMask and DNS data.
If called before association, the DS queries the DHCP server.

Void Wifi.setLocalIp(ip, gateway[, subnetmask[, dns1[, dns2]]]) (nds)
Set the IP, gateWay, subnetMask and DNS. The strings must be formated like "N1.N2.N3.N4" where N is a number between 0 to 255.

  • ip (String): IP address.
  • gateway (String): gateway address.
  • subnetmask (String): subnet mask.
  • dns1 (String): first DNS.
  • dns2 (String): second DNS.

Socket Wifi.createTCPSocket() (nds)
Create a new TCP socket.

Socket Wifi.createUDPSocket() (nds)
Create an new UDP socket.

Shared UDP and TCP sockets methods

Number socket:checkData() (nds)
Check if there are data in the socket's Wifi buffer and return the number of characters to be read (TCP or UDP).

Void socket:closeSocket() (nds)
Close a socket (TCP or UDP).

UDP sockets only methods

Void udpSocket:sendTo(buffer, host, port) (nds)
Send data to the given peer.

  • buffer (String): data to be sent
  • host (String): URl of the peer
  • port (Number): port number

String, String, Number udpSocket:receiveFrom(length) (nds)
Receive data from any server, and also give the host's IP address and port.

  • length (Number): size of the data to receive

Void udpSocket:setPeerName(host, port) (nds)
Set the default peer for this UDP socket.

  • host (String): URl of the peer
  • port (Number): port number

Void udpSocket:send(buffer) (nds)
Send data to the socket's default peer (raise an error if none has been set).

  • buffer (String): data to be sent

String udpSocket:receive(length) (nds)
Receive data from the socket's default peer (raise an error if none has been set).

  • length (Number): size of the data to be received

TCP sockets only methods

Void tcpSocket:connect(host, port) (nds)
Connect the socket to a peer.

  • host (String): URl of the peer
  • port (Number): port number

Void tcpSocket:send(buffer) (nds)
Send data to the socket's peer.

  • buffer (String): data to be sent

String tcpSocket:receive(length) (nds)
Receive data from the socket's peer.

  • length (Number): size of the data to be received

Nifi

Boolean Nifi.init(channel) (nds)
Init the Wifi in Nifi mode on a channel and return true if success, false otherwise.

  • channel (Number): the wifi channel where to discuss (must be between 1 and 13).

Void Nifi.changeChannel(channel) (nds)
Change the channel where the Nifi discuss.

  • channel (Number): The new channel (must be between 1 and 13).

Void Nifi.stop() (nds)
Stop the nifi.

Boolean Nifi.checkMessage() (nds)
Check if a new message is arrived and return true if there is one and false otherwise.

String Nifi.getTrame() (nds)
Get the last trame receive by Nifi even if it's not address to the NDS. Its max size is 4096 bytes.

Void Nifi.sendMessage(message) (nds)
Send a message on the channel.

  • message (String): Message to send. The max size of the message is 2048 bytes.

String Nifi.readMessage() (nds)
Read the last message received.

Sound

Sound banks

Void Sound.loadBank(filename) (nds)
Load a soundbank from a file in memory.

  • filename (String): path of the file to load

Void Sound.unloadBank() (nds)
Unload the sound bank from the memory.

Mods

Void Sound.loadMod(id) (nds)
Load a module in memory.

  • id (Number): id of the module to load

Void Sound.unloadMod(id) (nds)
Unload a module from the memory.

  • id (Number): id of the module to unload

Void Sound.startMod(id, playmode) (nds)
Start playing a module already loaded in memory.

  • id (Number): id of the module to play
  • playmode (Number): playing mode (PLAY_ONCE or PLAY_LOOP)

Void Sound.pause() (nds)
Pause all modules.

Void Sound.resume() (nds)
Resume all modules.

Void Sound.stop() (nds)
Stop all modules.

Void Sound.setPosition(id, position) (nds)
Set the cursor position of a module.

  • id (Number): id of the module

Boolean Sound.isActive() (nds)
Return true if the player is active and false otherwise.

Void Sound.startJingle(id) (nds)
Start playing a module as a jingle.

  • id (Number): id of the module to play

Void Sound.setModVolume(volume) (nds)
Set the volume of the played module.

  • volume (Number): new volume value between 0 and 1024

Void Sound.setJingleVolume(volume) (nds)
Set the volume of the played jingle.

  • volume (Number): new volume value between 0 and 1024

Void Sound.setModTempo(tempo) (nds)
Set the tempo of the module player.

  • tempo (Number): new tempo value between 512 and 2048

Void Sound.setModPitch(pitch) (nds)
Set the pitch of the module player.

  • pitch (Number): new pitch value

SFX

Void Sound.loadSFX(id) (nds)
Load a SFX in the meory.

  • id (Number): id of the SFX to load

Void Sound.unloadSFX(id) (nds)
Unload a SFX in the meory.

  • id (Number): id of the SFX to unload

Handle Sound.startSFX(id) (nds)
Start a sound effect already loaded in memory. Return and handle to this SFX.

  • id (Number): id of the SFX to start

Void Sound.stopSFX(handle) (nds)
Stop a played SFX.

  • handle (Handle): handle of a SFX, given by the startSFX function

Void Sound.releaseSFX(handle) (nds)
Mark an effect as low priority.

  • handle (Handle): handle of a SFX, given by the startSFX function

Void Sound.stopAllSFX() (nds)
Stop all payed SFX.

Void Sound.setSFXVolume(handle, volume) (nds)
Set the volume of a playing SFX.

  • handle (Handle): handle of a SFX, given by the startSFX function
  • volume (Number): new volume value between 0 and 255 (different from Mods)

Void Sound.setSFXPanning(handle, panning) (nds)
Set the panning of a playing SFX.

  • handle (Handle): handle of a SFX, given by the startSFX function
  • panning (Number): new panning value between 0 (left) and 255 (right)

Void Sound.setSFXPitch(handle, pitch) (nds)
Set the pitch of a playing SFX.

  • handle (Handle): handle of a SFX, given by the startSFX function
  • pitch (Number): new pitch value

Void Sound.setSFXScalePitch(handle, scale) (nds)
Set the scaling pitch ratio of a playing SFX.

  • handle (Handle): handle of a SFX, given by the startSFX function
  • scale (Number): new scale pitch value

INI Files

Table INI.load(filename [, mode]) (libs)
Load an INI file and create a table with it.

  • filename (String): file to load
  • mode (Boolean): use the simple mode or not

Void INI.save(filename, tab) (libs)
Save a table in an INI file.

  • filename (String): file to load
  • tab (Table): table to save

Example:

An INI file contains:

[infos]
name=toto
age=25

And then in the Lua script:

tab = INI.load(myfile.ini)
tab[infos][name] = tata
INI.save(myfile.ini, tab)

This example changes the line name=toto into name=tata.

These tables can only contain Strings! If you want to store numbers convert them with the tostring() function.

User's informations

Variables

They are defined in nds.

  • (Number) dsUser.color: gives the color theme, between 0 and 15
  • (Number) dsUser.birthDay: gives the birth day
  • (Number) dsUser.birthMonth: gives the birth month
  • (String) dsUser.name: gives the user's name
  • (Number) dsUser.nameLength: gives the user's name length
  • (String) dsUser.message: gives the user's personal message
  • (Number) dsUser.messageLength: gives the user's personal message length
  • (Number) dsUser.alarmHour: gives the alarm hour setting
  • (Number) dsUser.alarmMinute: gives the alarm minute setting
  • (Number) dsUser.language: gives the user's language, between 0 and 5
  • (Boolean) dsUser.GBAScreen: gives the GBA screen setting (true for the upper screen, and false for the lower screen)
  • (Number) dsUser.defaultBrightness: gives the default brightness (between 0 and 3 with a NDS Lite)
  • (Boolean) dsUser.getAutoMode: gives the auto launching mode setting (true if enabled, and false if disabled)

Functions (unused, nds)

They are not really useful since the variables herebefore are based on them.

Number dsUser.getColor()
Give the color theme, between 0 and 15.

Number dsUser.getBirthDay()
Give the birth day.

Number dsUser.getBirthMonth()
Give the birth month.

String dsUser.getName()
Give the user's name.

Number dsUser.getNameLength()
Give the user's name length.

String dsUser.getMessage()
Give the user's personal message.

Number dsUser.getMessageLength()
Give the user's personal message length.

Number dsUser.getAlarmHour()
Give the alarm hour setting.

Number dsUser.getAlarmMinute()
Give the alarm minute setting.

Number dsUser.getLanguage()
Give the user's language, between 0 and 5.

Boolean dsUser.getGBAScreen()
Give the GBA screen setting (true for the upper screen, and false for the lower screen).

Number dsUser.getDefaultBrightness()
Give the default brightness (between 0 and 3 with a NDS Lite).

Boolean dsUser.getAutoMode()
Give the auto launching mode setting (true if enabled, and false if disabled).


Related

Wiki: APIDocumentation