doukutsu-rs/src/scripting/doukutsu.d.ts

123 lines
3.0 KiB
TypeScript
Raw Normal View History

2021-01-16 13:51:52 +00:00
declare type EventHandler<T> = (this: void, param: T) => void;
2021-02-12 10:05:28 +00:00
/**
2021-02-24 08:28:47 +00:00
* Represents an in-game player.
2021-02-12 10:05:28 +00:00
*/
2021-01-16 13:51:52 +00:00
declare interface DoukutsuPlayer {
2021-02-12 10:05:28 +00:00
/**
* The ID of player.
*/
id(): number;
/**
* Current position of player in X axis (as floating point, not internal fixed point representation).
*/
2021-01-16 13:51:52 +00:00
x(): number;
2021-02-12 10:05:28 +00:00
/**
* Current position of player in Y axis (as floating point, not internal fixed point representation).
*/
2021-01-16 13:51:52 +00:00
y(): number;
2021-02-12 10:05:28 +00:00
/**
* Current velocity of player in X axis (as floating point, not internal fixed point representation).
*/
2021-01-16 13:51:52 +00:00
velX(): number;
2021-02-12 10:05:28 +00:00
/**
* Current velocity of player in Y axis (as floating point, not internal fixed point representation).
*/
2021-01-16 13:51:52 +00:00
velY(): number;
/**
2021-02-24 08:28:47 +00:00
* Sets the position of player in X axis (as floating point, not internal fixed point representation).
2021-01-16 13:51:52 +00:00
*/
2021-02-24 08:28:47 +00:00
setX(value: number): void;
2021-01-16 13:51:52 +00:00
/**
2021-02-24 08:28:47 +00:00
* Sets the position of player in Y axis (as floating point, not internal fixed point representation).
2021-01-16 13:51:52 +00:00
*/
2021-02-24 08:28:47 +00:00
setY(value: number): void;
2021-02-05 09:47:30 +00:00
/**
2021-02-24 08:28:47 +00:00
* Sets the velocity of player in X axis (as floating point, not internal fixed point representation).
2021-02-05 09:47:30 +00:00
*/
2021-02-24 08:28:47 +00:00
setVelX(value: number): void;
2021-02-05 09:47:30 +00:00
/**
2021-02-24 08:28:47 +00:00
* Sets the velocity of player in Y axis (as floating point, not internal fixed point representation).
*/
setVelY(value: number): void;
}
declare interface DoukutsuStage {
/**
* Returns the tick of current stage.
2021-02-05 09:47:30 +00:00
*/
2021-02-24 08:28:47 +00:00
tick(): number;
/**
* Returns a list of players on current map.
*/
players(): DoukutsuPlayer[];
2021-02-05 09:47:30 +00:00
/**
* Returns player with specified id.
*/
player(id: number): DoukutsuPlayer | null;
2021-02-12 10:05:28 +00:00
}
2021-01-16 13:51:52 +00:00
declare namespace doukutsu {
/**
* Plays a PixTone sound effect with specified ID.
*/
function playSfx(id: number): void;
/**
* Changes current music to one with specified ID.
* If ID equals 0, the music is stopped.
*/
function playMusic(id: number): void;
2021-02-24 08:28:47 +00:00
/**
* Returns the value of a certain TSC flag.
* @param id the flag number
*/
function getFlag(id: number): boolean;
/**
* Returns a list of players connected to current game.
*/
function onlinePlayers(): DoukutsuPlayer[];
/**
* Returns the id of local player.
*/
function localPlayerId(): number;
2021-02-13 23:08:25 +00:00
/**
* Sets an implementation-defined game setting.
* @param name
* @param value
*/
function setSetting(name: string, value: any): void;
/**
* Registers an event handler called after all scripts are loaded.
* @param event event name
* @param handler event handler procedure
*/
function on(event: "init", handler: EventHandler<void>): EventHandler<void>;
/**
* Registers an event handler called on each tick.
* @param event event name
* @param handler event handler procedure
*/
2021-02-24 08:28:47 +00:00
function on(event: "tick", handler: EventHandler<DoukutsuStage>): EventHandler<DoukutsuStage>;
2021-01-16 13:51:52 +00:00
function on<T>(event: string, handler: EventHandler<T>): EventHandler<T>;
2021-02-12 10:05:28 +00:00
}