OpenRCT2/distribution/openrct2.d.ts

354 lines
7.6 KiB
TypeScript
Raw Normal View History

2018-03-17 19:37:46 +01:00
/*****************************************************************************
* Copyright (c) 2014-2018 OpenRCT2 developers
*
* For a complete list of all authors, please refer to contributors.md
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
*
* OpenRCT2 is licensed under the GNU General Public License version 3.
*****************************************************************************/
// OpenRCT2 Scripting API definition file
2018-03-18 02:55:12 +01:00
// To enable IntelliSense for your scripts in Visual Studio or Visual Studio Code,
// add the following line to the top of your script and change the path appropriately.
//
// /// <reference path="/path/to/openrct2.d.ts" />
//
2018-03-17 19:37:46 +01:00
export interface Console {
2018-03-18 02:55:12 +01:00
clear(): void;
2018-03-17 19:37:46 +01:00
log(message?: any, ...optionalParams: any[]): void;
}
export interface Configuration {
getAll(pattern: string): { [name: string]: any };
get<T>(key: string): T | undefined;
get<T>(key: string, defaultValue: T): T;
set<T>(key: string, value: T): void;
has(key: string): boolean;
}
2019-07-25 23:59:26 +02:00
export type HookType =
"interval.tick" | "interval.day" |
"network.chat";
2018-03-17 19:37:46 +01:00
export interface Context {
/**
* The user's current configuration.
*/
configuration: Configuration;
2018-03-20 20:40:38 +01:00
2020-02-06 14:23:04 +01:00
/**
* Shared generic storage for all plugins.
*/
sharedStorage: Configuration;
/**
* Local generic storage for a each plugin.
*/
localStorage: Configuration;
2018-03-20 20:40:38 +01:00
/**
* Registers a new intent (command) that can be mapped to a shortcut.
*/
registerIntent(desc: IntentDesc);
2018-03-17 19:37:46 +01:00
/**
* Subscribes to the given hook.
*/
2019-07-25 23:59:26 +02:00
subscribe(hook: HookType, callback: Function): IDisposable;
2018-03-19 00:35:58 +01:00
}
2018-03-20 20:40:38 +01:00
export interface IntentDesc
{
key: string;
title?: string;
shortcut?: string;
action: Function;
}
2018-03-19 00:35:58 +01:00
export interface IDisposable {
dispose(): void;
2018-03-17 19:37:46 +01:00
}
2018-03-20 20:40:38 +01:00
export type TileElementType =
2018-08-12 23:08:39 +02:00
"surface" | "footpath";
2018-03-20 20:40:38 +01:00
export interface TileElement {
type: TileElementType;
2018-08-12 23:08:39 +02:00
baseHeight: number;
clearanceHeight: number;
2018-03-20 20:40:38 +01:00
broken: boolean;
/**
* Gets the element as a specific type to access its properties
*/
asSurface(): SurfaceElement;
2018-08-12 23:08:39 +02:00
asFootpath(): FootpathElement;
asTrack(): TrackElement;
asSmallScenery(): SmallSceneryElement;
asEntrance(): EntranceElement;
asWall(): WallElement;
asLargeScenery(): LargeSceneryElement;
asBanner(): BannerElement;
asCorruptElement(): CorruptElement;
}
export interface SurfaceElement extends TileElement {
slope: number;
terrain: number;
waterHeight: number;
grassLength: number;
ownership: number;
parkFences: number;
}
export interface FootpathAdditionStatus {
north: number;
east: number;
south: number;
west: number;
}
2018-08-12 23:08:39 +02:00
export interface FootpathAddition {
type: number;
isBin: boolean;
isBench: boolean;
isLamp: boolean;
isBreakable: boolean;
isJumpingFountainWater: boolean;
isJumpingFountainSnow: boolean;
allowedOnQueue: boolean;
allowedOnSlope: boolean;
isQueueScreen: boolean;
status: FootpathAdditionStatus;
2018-08-12 23:08:39 +02:00
/**
* Remove the path addition
*/
remove(): void;
}
export interface FootpathElement extends TileElement {
footpathType: number;
2018-08-12 23:08:39 +02:00
isSloped: boolean;
2018-08-14 02:02:43 +02:00
isQueue: boolean;
2018-08-12 23:08:39 +02:00
addition: FootpathAddition;
2018-08-14 02:02:43 +02:00
edges: number;
corners: number;
rideIndex: number;
2018-08-12 23:08:39 +02:00
}
export interface TrackElement extends TileElement {
}
export interface SmallSceneryElement extends TileElement {
}
export interface EntranceElement extends TileElement {
}
export interface WallElement extends TileElement {
}
export interface LargeSceneryElement extends TileElement {
}
export interface BannerElement extends TileElement {
}
export interface CorruptElement extends TileElement {
2018-03-20 20:40:38 +01:00
}
export interface Tile {
2019-07-25 21:45:38 +02:00
readonly x: number;
readonly y: number;
2018-03-20 20:40:38 +01:00
elements: TileElement[];
getElement(index: number): TileElement;
2018-03-20 20:40:38 +01:00
}
2018-03-17 19:37:46 +01:00
export interface Ride {
name: string;
excitement: number;
intensity: number;
nausea: number;
totalCustomers: number;
}
2019-07-25 21:45:38 +02:00
export type ThingType =
2018-03-20 20:40:38 +01:00
"car" | "duck" | "peep";
export interface Thing {
2020-02-06 14:26:40 +01:00
readonly type: ThingType;
2018-03-20 20:40:38 +01:00
x: number;
y: number;
z: number;
2020-02-06 14:26:40 +01:00
asPeep(): Thing | null;
}
export interface Peep extends Thing {
2018-03-20 20:40:38 +01:00
tshirt: number;
trousers: number;
}
2018-03-17 19:37:46 +01:00
export interface Map {
2019-07-25 21:45:38 +02:00
readonly size: { x: number; y: number; };
readonly rides: number;
readonly things: number;
2018-03-20 20:40:38 +01:00
2018-03-17 19:37:46 +01:00
getRide(id: number): Ride;
2018-03-20 20:40:38 +01:00
getTile(x: number, y: number): Tile;
getThing(id: number): Thing;
2018-03-17 19:37:46 +01:00
}
export type ParkMessageType =
"attraction" | "peep_on_attraction" | "peep" | "money" | "blank" | "research" | "guests" | "award" | "chart";
export interface ParkMessage {
type: ParkMessageType;
text: string;
}
export interface Park {
cash: number;
rating: number;
bankLoan: number;
maxBankLoan: number;
2018-03-25 23:04:36 +02:00
postMessage(message: string): void;
2018-03-17 19:37:46 +01:00
postMessage(message: ParkMessage): void;
}
export interface Window {
id: number;
classification: string;
x: number;
y: number;
width: number;
height: number;
title: string;
2018-03-24 01:40:51 +01:00
isSticky: boolean;
close(): void;
2018-03-17 19:37:46 +01:00
}
2018-03-25 23:04:36 +02:00
export type WidgetType =
"button" | "dropdown";
export interface Widget {
type: WidgetType;
x: number;
y: number;
width: number;
height: number;
}
export interface ButtonWidget extends Widget {
text: string;
onClick: () => void;
}
export interface DropdownWidget extends Widget {
items: string[];
selectedIndex: number;
onChanged: (index: number) => void;
}
2018-03-17 19:37:46 +01:00
export interface WindowDesc {
classification: string;
x?: number;
y?: number;
width: number;
height: number;
title: string;
id?: number;
2018-03-25 19:23:24 +02:00
minWidth?: number;
minHeight?: number;
2018-03-25 23:04:36 +02:00
widgets?: Widget[];
2018-03-17 19:37:46 +01:00
}
export interface Ui {
2019-07-25 21:45:38 +02:00
readonly width: number;
readonly height: number;
readonly windows: number;
2018-03-24 01:40:51 +01:00
getWindow(id: number): Window;
getWindow(classification: string, id?: number): Window;
2018-03-17 19:37:46 +01:00
openWindow(desc: WindowDesc): Window;
closeWindows(classification: string, id?: number): void;
closeAllWindows(): void;
}
2019-07-24 22:08:03 +02:00
export interface Player {
2019-07-25 21:45:38 +02:00
readonly id: number;
readonly name: string;
group: number;
readonly ping: number;
readonly commandsRan: number;
readonly moneySpent: number;
}
export type PermissionType =
"chat" |
"terraform" |
"set_water_level" |
"toggle_pause" |
"create_ride" |
"remove_ride" |
"build_ride" |
"ride_properties" |
"scenery" |
"path" |
"clear_landscape" |
"guest" |
"staff" |
"park_properties" |
"park_funding" |
"kick_player" |
"modify_groups" |
"set_player_group" |
"cheat" |
"toggle_scenery_cluster" |
"passwordless_login" |
"modify_tile" |
"edit_scenario_options";
export interface PlayerGroup {
readonly id: number;
2019-07-24 22:08:03 +02:00
name: string;
2019-07-25 21:45:38 +02:00
permissions: PermissionType[];
}
export interface ServerInfo {
readonly name: string;
readonly description: string;
readonly greeting: string;
readonly providerName: string;
readonly providerEmail: string;
readonly providerWebsite: string;
2019-07-24 22:08:03 +02:00
}
export interface Network {
2019-07-25 21:45:38 +02:00
readonly groups: number;
readonly players: number;
defaultGroup: number;
2019-07-24 22:08:03 +02:00
2019-07-25 21:45:38 +02:00
getServerInfo(): ServerInfo;
getGroup(index: number): PlayerGroup;
setGroups(groups: PlayerGroup[]): void;
2019-07-24 22:08:03 +02:00
getPlayer(index: number): Player;
2019-07-25 21:45:38 +02:00
sendMessage(message: string): void;
sendMessage(players: number[], message: string): void;
2019-07-24 22:08:03 +02:00
}
2018-03-18 02:55:12 +01:00
declare global {
var console: Console;
var context: Context;
var map: Map;
2019-07-24 22:08:03 +02:00
var network: Network;
2018-03-18 02:55:12 +01:00
var park: Park;
var ui: Ui;
}