Naev

Module vn

Visual Novel API for Naev

Based on Love2D API

Functions

animation (seconds, func, drawfunc, transition, initfunc, drawoverride) Allows doing arbitrary animations.
appear (c[, name="fade"], seconds[, transition="linear"]) Makes a character appear in the VN.
clear () Clears the fundamental running variables.
custom () Custom states.
disappear (c[, name="fade"], seconds[, transition="linear"]) Makes a character disappear in the VN.
done (...) Finishes the VN.
draw () Drawing function for the VN.
func (func) Runs a specified function and continues execution.
isDone () Checks to see if the VN is done running or not.
jump (label) Inserts a jump.
keypressed (key, isrepeat) Key press handler.
label (label) Inserts a label.
menu (items[, handler=vn.jump]) Opens a menu the player can select from.
mousemoved (mx, my, dx, dy) Mouse move handler.
mousepressed (mx, my, button) Mouse press handler.
mousereleased (mx, my, button) Mouse released handler.
move (c[, pos="center"]) Moves a character to another position.
music (filename, params, dontstop) Plays music.
musicPitch (data, p) Sets the pitch for playing music.
musicStop (filename) Stops certain playing music.
musicVolume (data, p) Sets the volume for playing music.
na (what, noclear, nowait) Makes the narrator say something.
newCharacter (who, params) Creates a new character.
reset () Fully resets the VN environment to default values.
resize (_w, _h) Handles resizing of the windows.
run () Runs the visual novel environment.
say (who, what[, noclear=false[, nowait=false]]) Has a character say something.
scene () Starts a new scene.
setBackground (drawfunc) Sets the background drawing function.
setColour (col[, alpha=1]) Sets the current drawing colour of the VN.
setForeground (drawfunc) Sets the foreground drawing function.
setMiddle (drawfunc) Sets the middle drawing function.
setShader (shader) Sets the shader to be used for post-processing the VN.
setUpdateFunc (updatefunc) Sets a custom update function.
sfx (sfx[, params]) Plays a sound.
sfxBingo (params) Plays a bingo sound.
sfxEerie (params) Plays an eerie sound.
sfxMoney (params) Plays a money sound.
sfxVictory (params) Plays a victory sound.
textinput (str) Text input handler.
transition ([name="fade"[, seconds[, transition="linear"]]]) Creates a transition state.
update (dt) Main updating function.
vn.Character.new (who, params) Creates a new character without adding it to the VN.
vn.Character:rename (newname) Renames a character on the fly.
vn.Character:say (what, noclear, nowait) Makes a character say something.
wheelmoved (dx, dy) Mouse wheel handler.

Tables

Character A visual novel character.


Functions

animation (seconds, func, drawfunc, transition, initfunc, drawoverride)
Allows doing arbitrary animations.

Parameters:

  • seconds number Seconds to perform the animation
  • func func Function to call when progress is being done.
  • drawfunc func Function to call when drawing.
  • transition string or table A CSS transition to use. Can be one of "ease", "ease-in", "ease-out", "ease-in-out", "linear", or a table defining the bezier curve parameters.
  • initfunc func Function run once at the beginning.
  • drawoverride func Function that overrides the drawing function for the VN.
appear (c[, name="fade"], seconds[, transition="linear"])
Makes a character appear in the VN.

Parameters:

  • c Character or table Character or table of Characters to make appear.
  • name string Name of the transition effect to use (see vn.transition) (default "fade")
  • seconds number Seconds to do the transition.
  • transition string Name of the CSS transition to use. (default "linear")

See also:

clear ()
Clears the fundamental running variables. Run before starting a new VN instance.

Note Leaves customization to colours and positions untouched.

custom ()
Custom states. Only use if you know what you are doing.
disappear (c[, name="fade"], seconds[, transition="linear"])
Makes a character disappear in the VN.

The way it works is that the transition is played backwards, so if you want the character to slide left, use "slideright"!

Parameters:

  • c Character Character to make disappear.
  • name string Name of the transition effect to use (see vn.transition) (default "fade")
  • seconds number Seconds to do the transition.
  • transition string Name of the CSS transition to use. (default "linear")

See also:

Usage:

    vn.disappear( c, "fade", 3 )
    
done (...)
Finishes the VN.

Parameters:

  • ... Uses the parameters as vn.transition.

See also:

draw ()
Drawing function for the VN. Has to be called each loop in "love.draw".
func (func)
Runs a specified function and continues execution.

Parameters:

  • func func Function to run.
isDone ()
Checks to see if the VN is done running or not.

Returns:

    bool true if it is done running, false otherwise
jump (label)
Inserts a jump. This skips to a certain label.

Parameters:

  • label string Name of the label to jump to.

See also:

keypressed (key, isrepeat)
Key press handler.

Parameters:

  • key string Name of the key pressed.
  • isrepeat boolean Whether or not the string is repeating.
label (label)
Inserts a label. This does nothing but serve as a reference for vn.jump

Parameters:

  • label string Name of the label to insert.

See also:

menu (items[, handler=vn.jump])
Opens a menu the player can select from.

Parameters:

  • items table Table of items to select from, they should be of the form "{text, label}" where "text" is what is displayed and "label" is what is passed to the handler.
  • handler function Function to handle what happens when an item is selecetdd. Defaults to vn.jump. (default vn.jump)
mousemoved (mx, my, dx, dy)
Mouse move handler.

Parameters:

  • mx
  • my
  • dx
  • dy
mousepressed (mx, my, button)
Mouse press handler.

Parameters:

  • mx number X position of the click.
  • my number Y position of the click.
  • button number Button that was pressed.
mousereleased (mx, my, button)
Mouse released handler.

Parameters:

  • mx number X position of the click.
  • my number Y position of the click.
  • button number Button that was pressed.
move (c[, pos="center"])
Moves a character to another position.

Parameters:

  • c Character Character to move.
  • pos string or number Position to move to. Can be either a [0,1] value, "center", "left", "right", "farleft", or "farright". (default "center")

See also:

music (filename, params, dontstop)
Plays music. This will stop all other playing music unless dontstop is set to true.

This gets automatically reset when the VN finishes.

Parameters:

  • filename string or nil Name of the music to play. If nil, it tries to restore the music again.
  • params tab Same as lmusic.play()
  • dontstop boolean Don't stop other music.

See also:

musicPitch (data, p)
Sets the pitch for playing music.

Parameters:

  • data table, string or nil Name of the music to change pitch of or all if nil. Passing the table returned from vn.music can also be done to specify the music.
  • p number Pitch to set.
musicStop (filename)
Stops certain playing music.

Parameters:

  • filename string or nil Name of the music to stop. If nil, it tries to stop all playing music.
musicVolume (data, p)
Sets the volume for playing music.

Parameters:

  • data table, string or nil Name of the music to change volume of or all if nil. Passing the table returned from vn.music can also be done to specify the music.
  • p number Volume to set.
na (what, noclear, nowait)
Makes the narrator say something.

Parameters:

  • what string What is being said.
  • noclear bool Whether or not to clear the text buffer.
  • nowait bool Whether or not to wait for player input when said.
newCharacter (who, params)
Creates a new character.

Parameters:

  • who string Name (or previously created character) to add.
  • params tab Parameter table.

Returns:

    Character New character.
reset ()
Fully resets the VN environment to default values.

Note This automatically does vn.clear() too.

resize (_w, _h)
Handles resizing of the windows.

Parameters:

  • _w number New width.
  • _h number New height.
run ()
Runs the visual novel environment.

Note You have to set up the states first. Note This function doesn't return until the VN is done running.

say (who, what[, noclear=false[, nowait=false]])
Has a character say something.

Note "You" and "Narrator" are special meta-characters.

Parameters:

  • who string The name of the character that is saying something.
  • what string What the character is saying.
  • noclear bool Whether or not to clear the text buffer. (default false)
  • nowait bool Whether or not to introduce a wait or just skip to the next text right away (defaults to false). (default false)
scene ()
Starts a new scene.
setBackground (drawfunc)
Sets the background drawing function. Drawn behind the VN stuff.

Parameters:

  • drawfunc func Function to call to draw the background or nil to disable.
setColour (col[, alpha=1])
Sets the current drawing colour of the VN.

Parameters:

  • col tab Colour table consisting of 3 or 4 number values.
  • alpha number Additional alpha to multiply by. (default 1)
setForeground (drawfunc)
Sets the foreground drawing function. Drawn in front the VN stuff.

Parameters:

  • drawfunc func Function to call to draw the foreground or nil to disable.
setMiddle (drawfunc)
Sets the middle drawing function. Drawn in right in front of the normal "namebox".

Parameters:

  • drawfunc func Function to call to draw the middle or nil to disable.
setShader (shader)
Sets the shader to be used for post-processing the VN.

Parameters:

  • shader Shader Shader to use for post-processing or nil to disable.

See also:

setUpdateFunc (updatefunc)
Sets a custom update function. This gets run every frame.

Parameters:

  • updatefunc func Update function to run every frame.
sfx (sfx[, params])
Plays a sound.

Parameters:

  • sfx Audio Sound to play.
  • params table Parameter values such as "effect" and "pitch". See audio package docs. (optional)
sfxBingo (params)
Plays a bingo sound.

Parameters:

  • params
sfxEerie (params)
Plays an eerie sound.

Parameters:

  • params
sfxMoney (params)
Plays a money sound.

Parameters:

  • params
sfxVictory (params)
Plays a victory sound.

Parameters:

  • params
textinput (str)
Text input handler.

Parameters:

  • str
transition ([name="fade"[, seconds[, transition="linear"]]])
Creates a transition state.

Parameters:

  • name string Name of the transition to use. (default "fade")
  • seconds number Seconds for the transition to last. The default value depends on the type of transition. (optional)
  • transition string The name of the CSS transition to use. See vn.animation. (default "linear")

See also:

update (dt)
Main updating function. Has to be called each loop in "love.update"

Parameters:

  • dt number Update tick in seconds.
vn.Character.new (who, params)
Creates a new character without adding it to the VN. Note The character can be added with vn.newCharacter.

Parameters:

  • who string Name of the character to add.
  • params tab Parameter table.

Returns:

    Character New character.
vn.Character:rename (newname)
Renames a character on the fly.

Parameters:

  • newname string New name to give the character.
vn.Character:say (what, noclear, nowait)
Makes a character say something.

Parameters:

  • what string What is being said.
  • noclear bool Whether or not to clear the text buffer.
  • nowait bool Whether or not to wait for player input when said.
wheelmoved (dx, dy)
Mouse wheel handler.

Parameters:

  • dx
  • dy

Tables

Character
A visual novel character.
generated by LDoc 1.5.0 Last updated 2025-05-18 01:00:15