1
0
Fork 0
mirror of https://github.com/doukutsu-rs/doukutsu-rs synced 2024-10-01 23:09:38 +00:00
doukutsu-rs/src/scripting/doukutsu.d.ts

95 lines
2.3 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
/**
* Represents a
*/
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-12 10:05:28 +00:00
}
2021-01-16 13:51:52 +00:00
declare interface DoukutsuScene {
/**
* Returns the tick of current scene.
*/
tick(): number;
/**
2021-02-05 09:47:30 +00:00
* Returns a list of players connected to current game.
2021-01-16 13:51:52 +00:00
*/
2021-02-05 09:47:30 +00:00
onlinePlayers(): DoukutsuPlayer[];
/**
* Returns a list of players on current map.
*/
mapPlayers(): DoukutsuPlayer[];
/**
* Returns the id of local player.
*/
localPlayerId(): number;
/**
* 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-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-01-16 13:51:52 +00:00
function on(event: "tick", handler: EventHandler<DoukutsuScene>): EventHandler<DoukutsuScene>;
function on<T>(event: string, handler: EventHandler<T>): EventHandler<T>;
2021-02-12 10:05:28 +00:00
}