ChaiLove API
0.28.0
|
This module provides all the global functions and events that are called. More...
Public Member Functions | |
void | conf (config &t) |
Modify some configuration options. More... | |
void | load () |
This function is called exactly once at the beginning of the game. More... | |
void | update (float delta) |
Callback function used to update the state of the game every frame. More... | |
void | draw () |
Callback function used to draw on the screen every frame. More... | |
void | reset () |
Called when the game is requested to be reset. More... | |
void | joystickpressed (int joystick, const std::string &button) |
Called when a joystick button is pressed. More... | |
void | joystickreleased (int joystick, const std::string &button) |
Called when a joystick button is released. More... | |
void | mousepressed (int x, int y, const std::string &button) |
Called when a mouse button is pressed. More... | |
void | mousereleased (int x, int y, const std::string &button) |
Called when a mouse button is released. More... | |
void | mousemoved (int x, int y, int dx, int dy) |
Called when the mouse is moved. More... | |
void | keypressed (const std::string &key, int scancode) |
Called when a key on the keyboard has been pressed. More... | |
void | keyreleased (const std::string &key, int scancode) |
Called when a key on the keyboard is released. More... | |
std::string | savestate () |
Called when requested to save the current state. More... | |
bool | loadstate (const std::string &data) |
Called when requested to load a state. More... | |
void | cheatreset () |
Called when requested to reset the state of all the cheats to their default state. More... | |
void | cheatset (int index, bool enabled, const std::string &code) |
Called when requested to enable or disable a cheat. More... | |
void | exit () |
Callback function triggered when the game is closed. More... | |
This module provides all the global functions and events that are called.
The following main.chai
is an example of some of these callbacks being used in unison.
void love::script::cheatreset | ( | ) |
Called when requested to reset the state of all the cheats to their default state.
void love::script::cheatset | ( | int | index, |
bool | enabled, | ||
const std::string & | code | ||
) |
Called when requested to enable or disable a cheat.
index | The index of the cheat. |
enabled | Whether the cheat is to be enabled or disabled. |
code | The code for the cheat. |
void love::script::conf | ( | config & | t | ) |
Modify some configuration options.
t | The config object to modify. |
void love::script::draw | ( | ) |
Callback function used to draw on the screen every frame.
Draw an image that was loaded in script::load (putting graphics.newImage in script::draw would cause the image to be reloaded every frame, which would cause issues).
void love::script::exit | ( | ) |
Callback function triggered when the game is closed.
void love::script::joystickpressed | ( | int | joystick, |
const std::string & | button | ||
) |
Called when a joystick button is pressed.
joystick | The joystick number. |
button | The name of which button was released. |
void love::script::joystickreleased | ( | int | joystick, |
const std::string & | button | ||
) |
Called when a joystick button is released.
joystick | The joystick number. |
button | The name of which button was released. |
void love::script::keypressed | ( | const std::string & | key, |
int | scancode | ||
) |
Called when a key on the keyboard has been pressed.
key | The name of the key that was pressed. |
scancode | The scancode of the key that was pressed. |
void love::script::keyreleased | ( | const std::string & | key, |
int | scancode | ||
) |
Called when a key on the keyboard is released.
key | The name of the key that was released. |
scancode | The scancode of the key that was released. |
void love::script::load | ( | ) |
This function is called exactly once at the beginning of the game.
Establish some variables/resources on the game load, so that they can be used repeatedly in other functions (such as script::draw).
bool love::script::loadstate | ( | const std::string & | data | ) |
void love::script::mousemoved | ( | int | x, |
int | y, | ||
int | dx, | ||
int | dy | ||
) |
Called when the mouse is moved.
x | The mouse position on the x-axis. |
y | The mouse position on the y-axis. |
dx | The amount moved along the x-axis since the last time love.mousemoved was called. |
dy | The amount moved along the y-axis since the last time love.mousemoved was called. |
void love::script::mousepressed | ( | int | x, |
int | y, | ||
const std::string & | button | ||
) |
Called when a mouse button is pressed.
x | The mouse position on the x-axis. |
y | The mouse position on the y-axis. |
button | The mouse button name of which was pressed. |
void love::script::mousereleased | ( | int | x, |
int | y, | ||
const std::string & | button | ||
) |
Called when a mouse button is released.
x | The mouse position on the x-axis. |
y | The mouse position on the y-axis. |
button | The mouse button name of which was released. |
void love::script::reset | ( | ) |
std::string love::script::savestate | ( | ) |
void love::script::update | ( | float | delta | ) |
Callback function used to update the state of the game every frame.
delta | Time since the last update in seconds. |
Change a variable var at a constant rate (+/- 3 per second in this example).