Naev

Module vn

Visual Novel API for Naev

Based on Love2D API

Functions

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

Tables

Character A visual novel character.


Functions

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)
draw ()
Drawing function for the VN. Has to be called each loop in "love.draw".
update (dt)
Main updating function. Has to be called each loop in "love.update"

Parameters:

  • dt number Update tick in seconds.
resize (_w, _h)
Handles resizing of the windows.

Parameters:

  • _w number New width.
  • _h number New height.
keypressed (key, isrepeat)
Key press handler.

Parameters:

  • key string Name of the key pressed.
  • isrepeat boolean Whether or not the string is repeating.
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.
wheelmoved (dx, dy)
Mouse wheel handler.

Parameters:

  • dx
  • dy
textinput (str)
Text input handler.

Parameters:

  • str
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.
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.
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.
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.
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:

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 )
    
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:

scene ()
Starts a new scene.
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)
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)
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:

jump (label)
Inserts a jump. This skips to a certain label.

Parameters:

  • label string Name of the label to jump to.

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:

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.
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.
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.
done (...)
Finishes the VN.

Parameters:

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

See also:

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.
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:

func (func)
Runs a specified function and continues execution.

Parameters:

  • func func Function to run.
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)
sfxMoney (params)
Plays a money sound.

Parameters:

  • params
sfxVictory (params)
Plays a victory sound.

Parameters:

  • params
sfxBingo (params)
Plays a bingo sound.

Parameters:

  • params
sfxEerie (params)
Plays an eerie sound.

Parameters:

  • params
custom ()
Custom states. Only use if you know what you are doing.
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:

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.
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.
setUpdateFunc (updatefunc)
Sets a custom update function. This gets run every frame.

Parameters:

  • updatefunc func Update function to run every frame.
isDone ()
Checks to see if the VN is done running or not.

Returns:

    bool true if it is done running, false otherwise
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.

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

Note Leaves customization to colours and positions untouched.

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

Note This automatically does vn.clear() too.

Tables

Character
A visual novel character.
generated by LDoc 1.5.0 Last updated 2024-12-21 08:10:17