Files
mini/vscode/library.lua
Raimon Zamora eac20bbbe0 VERSIÓ 1.3.15
- [NEW] mouse.dblclick()
- [FIX] de vegades no pillava be la rodeta del ratolí
- [NEW] sys.dir() torna el contingut del directori primer les carpetes, i tot ordenat alfabèticament
- [WIP] Treballant en ferramentes
2025-12-04 17:46:22 +01:00

837 lines
19 KiB
Lua

---@meta
---@class mini
mini = {}
---@class surf
surf = {}
---@param w number
---@param h number
---@return number surface
---Create new surface specifying width and height
function surf.new(w, h) end
---@param filename string
---@return number surface
---Load GIF file and return surface
function surf.load(filename) end
---@param surface number
---@param filename string
---@optional palette table
---Save surface as GIF file, with optional palette
function surf.save(surface, filename, palette) end
---@param surface number
---Free the specified surface
function surf.free(surface) end
---@param surface number
---@return number w, number h
---Retrieve width and height of surface
function surf.size(surface) end
---@param surface number
---Set surface as target
function surf.target(surface) end
---@param surface number
---Set surface as source
function surf.source(surface) end
---Erase the current target surface with color 0.
function surf.cls() end
---@param color number
---Erase the current target surface with 'color'
function surf.cls(color) end
---@param x number
---@param y number
---@return number color
---Get color of pixel (x,y) on the source surface.
function surf.pixel(x, y) end
---@param x number
---@param y number
---@param color number
---Set the color for pixel (x,y) on the target surface.
function surf.pixel(x, y, color) end
---@class map
map = {}
---@return number surface
---Get tilemaps current surface
function map.surf() end
---@param surface number
---Set surface as the current tilemap
function map.surf(surface) end
---Draw the tilemap, using the source surface as tile graphics source
function map.draw() end
---@param x number
---@param y number
---@return number tile
---Get tile at the position (x,y) in the current tilemap
function map.tile(x, y) end
---@param x number
---@param y number
---@param tile number
---Set the tile at the position (x,y) in the current tilemap
function map.tile(x, y, tile) end
---@class pal
pal = {}
---@param filename string
---@return table pal
---Load a palette from a GIF file and return it
function pal.load(filename) end
---@param pal table
---Set a specified palette as the current palette
function pal.set(pal) end
---@param index number
---@return number r, number g, number b
---Retrieve (r,g,b) color for the index specified in the current palette
function pal.color(index) end
---@param index number
---@param r number
---@param g number
---@param b number
---Set (r,g,b) color for the specified index in the current palette
function pal.color(index, r, g, b) end
---@param index number
---Set the index specified as transparent color
function pal.trans(index) end
---Reset all the subpalette indices to their default palette index
function pal.subpal() end
---@param index number
---Reset the specified subpalette index to its default palette index
function pal.subpal(index) end
---@param index number
---@param color number
---Set the specified subpalette index to the specified palette index
function pal.subpal(index, color) end
---@param index1 number
---@param index2 number
---@param color number
---Set the specified subpalette range to the specified palette index
function pal.subpal(index1, index2, color) end
---@class view
view = {}
---reset the current clipping region to the entire window
function view.clip() end
---@param x number
---@param y number
---@param w number
---@param h number
---Set the current clipping region
function view.clip(x, y, w, h) end
---@return number x, number y
---Get the current origin position
function view.origin() end
---@param x number
---@param y number
---Set the current origin position
function view.origin(x, y) end
---@param x number
---@param y number
---@return number x, number y
---Convert screen position to viewport position
function view.tolocal(x, y) end
---@class draw
draw = {}
---@param x1 number
---@param y1 number
---@param x2 number
---@param y2 number
---@param color number
---Draw a line from (x1,y1) to (x2,y2) with the given color
function draw.line(x1, y1, x2, y2, color) end
---@param x1 number
---@param y number
---@param x2 number
---@param color number
---Draw an horizontal line from (x1,y) to (x2,y) with the given color
function draw.hline(x1, y, x2, color) end
---@param x number
---@param y1 number
---@param y2 number
---@param color number
---Draw a vertical line from (x,y1) to (x,y2) with the givencolor
function draw.vline(x, y1, y2, color) end
---@param x number
---@param y number
---@param w number
---@param h number
---@param color number
---Draw the ouline of a rectangle at (x,y) of size (w,h) with the given color
function draw.rect(x, y, w, h, color) end
---@param x number
---@param y number
---@param w number
---@param h number
---@param color number
---Draw a filled rectangle at (x,y) of size (w,h) with the given color
function draw.rectf(x, y, w, h, color) end
---@param x number
---@param y number
---@param r number
---@param color number
---Draw the outline of a cicle at position(x,y) with radius r and the given color
function draw.circ(x, y, r, color) end
---@param x number
---@param y number
---@param r number
---@param color number
---Draw a filled cicle at position(x,y) with radius r and the given color
function draw.circf(x, y, r, color) end
---@param x number
---@param y number
---@param w number
---@param h number
---@param r number
---@param color number
---Draw the outline of a round rectangle at (x,y) of size (w,h) with border radius r and the given color
function draw.rrect(x, y, w, h, r, color) end
---@param x number
---@param y number
---@param w number
---@param h number
---@param r number
---@param color number
---Draw a filled round rectangle at (x,y) of size (w,h) with border radius r and the given color
function draw.rrectf(x, y, w, h, r, color) end
---@param x1 number
---@param y1 number
---@param x2 number
---@param y2 number
---@param color number
---Draw the outline of an oval enclosed in (x1,y1)-(x2,y2) and the given color
function draw.oval(x1, y1, x2, y2, color) end
---@param x1 number
---@param y1 number
---@param x2 number
---@param y2 number
---@param color number
---Draw a filled oval enclosed in (x1,y1)-(x2,y2) and the given color
function draw.ovalf(x1, y1, x2, y2, color) end
---@param pattern number
---Specify a pattern for the drawing functions
function draw.pattern(pattern) end
---Reset to no pattern for drawing functions
function draw.pattern() end
---@param sx number
---@param sy number
---@param sw number
---@param sh number
---@param dx number
---@param dy number
---@optional dw number
---@optional dh number
---@optional boolean flip_x
---@optional boolean flip_y
---@optional boolean invert
---Blit the region starting at (sx,sy) and size (sw, sh) from the source surface
---to the position (dx, dy) (and optionally of size (dw, dh)) to the target surface,
---optionally flipping it horizontally or vertically, or inverting x and y axes
function draw.surf(sx, sy, sw, sh, dx, dy, dw, dh, flip_x, flip_y, invert) end
---@param sx number
---@param sy number
---@param sw number
---@param sh number
---@param x number
---@param y number
---@param a number
---Blit the region starting at (sx,sy) and size (sw, sh) from the source surface
---to the position (dx, dy) of the target surface, rotating it by a degrees
function draw.surfrot(sx, sy, sw, sh, x, y, a) end
---@param text string
---@param x number
---@param y number
---@param color number
---Draw text to (x,y) using the specified color
function draw.text(text, x, y, color) end
---@param text number
---@param x number
---@param y number
---@param color number
---Draw text to (x,y) using the specified color
function draw.text(text, x, y, color) end
---@class shader
shader = {}
---Initialize shaders subsystem, still non functional without shaders
function shader.init() end
---@param shader string
---Initialize shaders subsystem, specifying a file that contains both vertex and fragment shader
function shader.init(shader) end
---@param vshader string
---@param fshader string
---Initialize shaders subsystem, specifying both a vertex shader file and a fragment shader file
function shader.init(vshader, fshader) end
---Enable previously loaded shader
function shader.enable() end
---Disable shaders
function shader.disable() end
---@class music
music = {}
---@param filename string
---Load and play the song in the specified OGG file
function music.play(filename) end
---@param filename string
---@param loop integer
---Load and play the song in the specified OGG file, loop number of times
function music.play(filename, loop) end
---Pause the currently playing song
function music.pause() end
---Resume the currently paused song
function music.resume() end
---Stop the currently playing song
function music.stop() end
---@return number pos
---Get the playing position of the currently loaded song
function music.pos() end
---@param pos number
---Set the playing position of the currently loaded song
function music.pos(pos) end
---@return boolean value
---Get if music is enabled
function music.enabled() end
---@param value boolean
---Set if music is enabled or not
function music.enabled(value) end
---@class sound
sound = {}
---@param filename string
---@return number snd
---Load a sound in WAV format from the specified file and return it
function sound.load(filename) end
---@param snd number
---Free the sound specified
function sound.free(snd) end
---@param snd number
---@return number chl
---Play the sound specified, returns the channel in which it's playing
function sound.play(snd) end
---@param snd number
---@param loop integer
---@return number chl
---Play the sound specified loop number of times, returns the channel in which it's playing
function sound.play(snd, loop) end
---@param chl number
---Stop the channel specified
function sound.stop(chl) end
---@return boolean value
---Get if sound is enabled
function sound.enabled() end
---@param value boolean
---Set if sound is enabled or not
function sound.enabled(value) end
---@class sys
sys = {}
---Get delta time from last update in seconds (with decimals)
function sys.delta() end
---Get current system timer in seconds (with decimals)
function sys.time() end
---@return boolean
---Query if a beat has already passed
function sys.beat() end
---@param bts number
---Set number of frames between beats
function sys.beat(bts) end
---@param mode number
---@param ms number
---Sets the update mode.
---UPDATE_ALWAYS: The game will call mini.update as fast as possible
---UPDATE_EVENTS: The game will call mini.update only when a keyboard, mouse or pad event fires
---UPDATE_TIMEOUT: The game will call mini.update on events or after the milliseconds specified passed
function sys.update(mode, ms) end
---@return table
---Gets a table in which each entry has a field "name" with the name and a field "dir" with a
---boolean specifying if it's a directory, for each file in the 'data' directory
function sys.dir() end
---@param path string
---@return table
---Gets a table in which each entry has a field "name" with the name and a field "dir" with a
---boolean specifying if it's a directory, for each file in the specified path
function sys.dir(path) end
---Exit the game
function sys.quit() end
---@return number
---Gets the frames per second
function sys.fps() end
---@return string
---Gets the content of the clipboard
function sys.clipboard() end
---@param value string
---Sets the content of the clipboard
function sys.clipboard(value) end
---@class win
win = {}
---@param value number
---Set the window zoom
function win.zoom(value) end
---@return number value
---Get the window zoom
function win.zoom() end
---@param value boolean
---Specifies if the window must display at fullscreen or not
function win.fullscreen(value) end
---@return boolean value
---Returns if the window is at fullscreen or not
function win.fullscreen() end
---@param value boolean
---Specifies if the cursor must be visible or not
function win.cursor(value) end
---@return number w, number h
---Returns the current window size
function win.res() end
---@param w number
---@param h number
---Sets the window size
function win.res(w, h) end
---@class config
config = {}
---@param key string
---@param value any
---Sets the value of a key in the configuration file
function config.key(key, value) end
---@param key string
---@return string value
---Gets the value of a key in the configuration file
function config.key(key) end
---@return string value
---Returns the folder in which the configuration file resides
function config.folder() end
---@class mouse
---@field mouse.LEFT number
---@field mouse.MIDDLE number
---@field mouse.RIGHT number
mouse = {}
---@return number x, number y
---Returns the current position of the mouse
function mouse.pos() end
---@return number value
---Returns the value of the mouse wheel
function mouse.wheel() end
---@param btn number
---@return boolean
---Returns whether the specified mouse button is down
function mouse.down(btn) end
---@param btn number
---@return boolean
---Returns whether the specified mouse button has just been pressed
function mouse.press(btn) end
---@return boolean
---Returns whether the user performed a double click
function mouse.dblclick() end
---Ignores current down button, effectively not raising the next "press" event
function mouse.discard() end
mouse.LEFT = 1
mouse.MIDDLE = 2
mouse.RIGHT = 3
---@class key
key = {}
---@param key number
---@return boolean
---Returns whether the specified keyboard key is down
function key.down(key) end
---@return number
---Returns which keyboard key has just been pressed
function key.press() end
---@param key number
---@return boolean
---Returns whether the specified keyboard key has just been pressed
function key.press(key) end
---@return boolean
---Returns whether any keyboard key has just been pressed
function key.any() end
---@class pad
---@field pad.INVALID number
---@field pad.A number
---@field pad.B number
---@field pad.X number
---@field pad.Y number
---@field pad.BACK number
---@field pad.GUIDE number
---@field pad.START number
---@field pad.LEFTSTICK number
---@field pad.RIGHTSTICK number
---@field pad.LEFTSHOULDER number
---@field pad.RIGHTSHOULDER number
---@field pad.UP number
---@field pad.DOWN number
---@field pad.LEFT number
---@field pad.RIGHT number
---@field pad.MISC1 number
---@field pad.PADDLE1 number
---@field pad.PADDLE2 number
---@field pad.PADDLE3 number
---@field pad.PADDLE4 number
---@field pad.TOUCHPAD number
pad = {}
---@param btn number
---@return boolean
---Returns whether the specified gamepad button is down
function pad.down(btn) end
---@return number
---Returns which gamepad button has just been pressed
function pad.press() end
---@param btn number
---@return boolean
---Returns whether the specified gamepad button has just been pressed
function pad.press(btn) end
---@return boolean
---Returns whether any gamepad button has just been pressed
function pad.any() end
pad.INVALID = -1
pad.A = 0
pad.B = 1
pad.X = 2
pad.Y = 3
pad.BACK = 4
pad.GUIDE = 5
pad.START = 6
pad.LEFTSTICK = 7
pad.RIGHTSTICK = 8
pad.LEFTSHOULDER = 9
pad.RIGHTSHOULDER = 10
pad.UP = 11
pad.DOWN = 12
pad.LEFT = 13
pad.RIGHT = 14
pad.MISC1 = 15
pad.PADDLE1 = 16
pad.PADDLE2 = 17
pad.PADDLE3 = 18
pad.PADDLE4 = 19
pad.TOUCHPAD = 20
---@class key
---@field key.UNKNOWN number
---@field key.A number
---@field key.B number
---@field key.C number
---@field key.D number
---@field key.E number
---@field key.F number
---@field key.G number
---@field key.H number
---@field key.I number
---@field key.J number
---@field key.K number
---@field key.L number
---@field key.M number
---@field key.N number
---@field key.O number
---@field key.P number
---@field key.Q number
---@field key.R number
---@field key.S number
---@field key.T number
---@field key.U number
---@field key.V number
---@field key.W number
---@field key.X number
---@field key.Y number
---@field key.Z number
---@field key.N1 number
---@field key.N2 number
---@field key.N3 number
---@field key.N4 number
---@field key.N5 number
---@field key.N6 number
---@field key.N7 number
---@field key.N8 number
---@field key.N9 number
---@field key.N0 number
---@field key.RETURN number
---@field key.ESCAPE number
---@field key.BACKSPACE number
---@field key.TAB number
---@field key.SPACE number
---@field key.MINUS number
---@field key.EQUALS number
---@field key.LEFTBRACKET number
---@field key.RIGHTBRACKET number
---@field key.BACKSLASH number
---@field key.NONUSHASH number
---@field key.SEMICOLON number
---@field key.APOSTROPHE number
---@field key.GRAVE number
---@field key.COMMA number
---@field key.PERIOD number
---@field key.SLASH number
---@field key.CAPSLOCK number
---@field key.F1 number
---@field key.F2 number
---@field key.F3 number
---@field key.F4 number
---@field key.F5 number
---@field key.F6 number
---@field key.F7 number
---@field key.F8 number
---@field key.F9 number
---@field key.F10 number
---@field key.F11 number
---@field key.F12 number
---@field key.PRINTSCREEN number
---@field key.SCROLLLOCK number
---@field key.PAUSE number
---@field key.INSERT number
---@field key.HOME number
---@field key.PAGEUP number
---@field key.DELETE number
---@field key.END number
---@field key.PAGEDOWN number
---@field key.RIGHT number
---@field key.LEFT number
---@field key.DOWN number
---@field key.UP number
---@field key.NUMLOCKCLEAR number
---@field key.KP_DIVIDE number
---@field key.KP_MULTIPLY number
---@field key.KP_MINUS number
---@field key.KP_PLUS number
---@field key.KP_ENTER number
---@field key.KP_1 number
---@field key.KP_2 number
---@field key.KP_3 number
---@field key.KP_4 number
---@field key.KP_5 number
---@field key.KP_6 number
---@field key.KP_7 number
---@field key.KP_8 number
---@field key.KP_9 number
---@field key.KP_0 number
---@field key.KP_PERIOD number
---@field key.NONUSBACKSLASH number
---@field key.APPLICATION number
---@field key.LCTRL number
---@field key.LSHIFT number
---@field key.LALT number
---@field key.LGUI number
---@field key.RCTRL number
---@field key.RSHIFT number
---@field key.RALT number
---@field key.RGUI number
key.UNKNOWN = 0
key.A = 4
key.B = 5
key.C = 6
key.D = 7
key.E = 8
key.F = 9
key.G = 10
key.H = 11
key.I = 12
key.J = 13
key.K = 14
key.L = 15
key.M = 16
key.N = 17
key.O = 18
key.P = 19
key.Q = 20
key.R = 21
key.S = 22
key.T = 23
key.U = 24
key.V = 25
key.W = 26
key.X = 27
key.Y = 28
key.Z = 29
key.N1 = 30
key.N2 = 31
key.N3 = 32
key.N4 = 33
key.N5 = 34
key.N6 = 35
key.N7 = 36
key.N8 = 37
key.N9 = 38
key.N0 = 39
key.RETURN = 40
key.ESCAPE = 41
key.BACKSPACE = 42
key.TAB = 43
key.SPACE = 44
key.MINUS = 45
key.EQUALS = 46
key.LEFTBRACKET = 47
key.RIGHTBRACKET = 48
key.BACKSLASH = 49
key.NONUSHASH = 50
key.SEMICOLON = 51
key.APOSTROPHE = 52
key.GRAVE = 53
key.COMMA = 54
key.PERIOD = 55
key.SLASH = 56
key.CAPSLOCK = 57
key.F1 = 58
key.F2 = 59
key.F3 = 60
key.F4 = 61
key.F5 = 62
key.F6 = 63
key.F7 = 64
key.F8 = 65
key.F9 = 66
key.F10 = 67
key.F11 = 68
key.F12 = 69
key.PRINTSCREEN = 70
key.SCROLLLOCK = 71
key.PAUSE = 72
key.INSERT = 73
key.HOME = 74
key.PAGEUP = 75
key.DELETE = 76
key.END = 77
key.PAGEDOWN = 78
key.RIGHT = 79
key.LEFT = 80
key.DOWN = 81
key.UP = 82
key.NUMLOCKCLEAR = 83
key.KP_DIVIDE = 84
key.KP_MULTIPLY = 85
key.KP_MINUS = 86
key.KP_PLUS = 87
key.KP_ENTER = 88
key.KP_1 = 89
key.KP_2 = 90
key.KP_3 = 91
key.KP_4 = 92
key.KP_5 = 93
key.KP_6 = 94
key.KP_7 = 95
key.KP_8 = 96
key.KP_9 = 97
key.KP_0 = 98
key.KP_PERIOD = 99
key.NONUSBACKSLASH = 100
key.APPLICATION = 101
key.LCTRL = 224
key.LSHIFT = 225
key.LALT = 226
key.LGUI = 227
key.RCTRL = 228
key.RSHIFT = 229
key.RALT = 230
key.RGUI = 231