Skip to content

Latest commit

 

History

History
932 lines (562 loc) · 15.4 KB

modules.md

File metadata and controls

932 lines (562 loc) · 15.4 KB

Table of contents

Classes

Type aliases

Variables

Functions

Type aliases

brush_callback

Ƭ brush_callback: callback<(brush: script_brush, event: script_brush_event) => void>

The type of callback used for brush events.

note In lua, the first argument becomes "self" argument if using colon notation


callback

Ƭ callback<T>: T | nil

Callback functions are unassigned by default, but may be assigned to by the user

Type parameters:

Name
T

nil

Ƭ nil: undefined

This is the documentation for the Noggit scripting API. Functions not connected to a class are global and can be called from anywhere in a script.

Variables

procedures

Const procedures: procedures_class

singleton

Functions

abs

abs(arg: number): any

Parameters:

Name Type
arg number

Returns: any


acos

acos(a: number): any

Parameters:

Name Type
a number

Returns: any


acosh

acosh(a: number): any

Parameters:

Name Type
a number

Returns: any


add_m2

add_m2(filename: string, pos: vector_3d, scale: number, rotation: vector_3d): void

Spawns an m2 model in the world.

Parameters:

Name Type
filename string
pos vector_3d
scale number
rotation vector_3d

Returns: void


add_wmo

add_wmo(filename: string, pos: vector_3d, rot: vector_3d): void

Spawns a wmo model in the world.

note wmo models cannot be scaled.

Parameters:

Name Type
filename string
pos vector_3d
rot vector_3d

Returns: void


append_file

append_file(file: string, content: string): void

Appends text to a file

note This operation REQUIRES explicit permission from the user, or it will throw an error.

Parameters:

Name Type
file string
content string

Returns: void


asin

asin(a: number): any

Parameters:

Name Type
a number

Returns: any


asinh

asinh(a: number): any

Parameters:

Name Type
a number

Returns: any


atan

atan(a: number): any

Parameters:

Name Type
a number

Returns: any


atanh

atanh(a: number): any

Parameters:

Name Type
a number

Returns: any


brush

brush(name: string): script_brush

Creates a new script brush

Parameters:

Name Type
name string

Returns: script_brush


cam_pitch

cam_pitch(): number

Returns the cameras pitch rotation (the one you almost NEVER want)

Returns: number


cam_yaw

cam_yaw(): number

Returns the cameras yaw rotation (the one you almost ALWAYS want)

Returns: number


camera_pos

camera_pos(): vector_3d

Returns the current camera position

Returns: vector_3d


cbrt

cbrt(a: number): any

Parameters:

Name Type
a number

Returns: any


ceil

ceil(a: number): any

Parameters:

Name Type
a number

Returns: any


cos

cos(a: number): any

Parameters:

Name Type
a number

Returns: any


cosh

cosh(a: number): any

Parameters:

Name Type
a number

Returns: any


create_image

create_image(width: number, height: number): image

Creates a new blank image

Parameters:

Name Type
width number
height number

Returns: image


dist_2d

dist_2d(from: vector_3d, to: vector_3d): any

Returns the 2d distance (ignoring y) between two vectors

Parameters:

Name Type
from vector_3d
to vector_3d

Returns: any


dist_2d_compare

dist_2d_compare(from: vector_3d, to: vector_3d, dist: number): number

Compares the 2d distance (ignoring y value) between two vectors to a given distance. This operation is significantly faster than manually comparing to the result of dist_2d

Parameters:

Name Type
from vector_3d
to vector_3d
dist number

Returns: number


exp

exp(a: number): any

Parameters:

Name Type
a number

Returns: any


floor

floor(a: number): any

Parameters:

Name Type
a number

Returns: any


get_area_id

get_area_id(pos: vector_3d): number

Returns the area id at a specific position.

The 'y' value is ignored for this operation.

Parameters:

Name Type
pos vector_3d

Returns: number


get_chunk

get_chunk(position: vector_3d): chunk

Returns the chunk at a given position. The tile at the position must be loaded into memory for the operation to be successful.

Parameters:

Name Type
position vector_3d

Returns: chunk


get_map_id

get_map_id(): number

Returns the id of the currently open map

Returns: number


holding_alt

holding_alt(): boolean

Returns true if the user is currently pressing the alt key

Returns: boolean


holding_ctrl

holding_ctrl(): boolean

Returns true if the user is currently pressing the ctrl key

Returns: boolean


holding_left_mouse

holding_left_mouse(): boolean

Returns true if the user is currently pressing the left mouse button

Returns: boolean


holding_right_mouse

holding_right_mouse(): boolean

Returns true if the user is currently pressing the right mouse button

Returns: boolean


holding_shift

holding_shift(): boolean

Returns true if the user is currently pressing the shift key

Returns: boolean


holding_space

holding_space(): boolean

Returns true if the user is currently pressing the spacebar

Returns: boolean


lerp

lerp(from: number, to: number, ratio: number): number

Returns the value at some percentage between two values.

Parameters:

Name Type Description
from number the minimum range value
to number the maximum range value
ratio number the percentage to take (typically between 0-1)

Returns: number


load_png

load_png(path: string): image

Loads a png file into an in-memory image.

Parameters:

Name Type
path string

Returns: image


log

log(a: number): any

Parameters:

Name Type
a number

Returns: any


log10

log10(a: number): any

Parameters:

Name Type
a number

Returns: any


make_noise

make_noise(start_x: number, start_y: number, width: number, height: number, frequency: number, algorithm: string, seed: string): any

Creates a new noisemap

Parameters:

Name Type
start_x number
start_y number
width number
height number
frequency number
algorithm string
seed string

Returns: any


path_exists

path_exists(path: string): boolean

Returns true if a pathname exists already

Parameters:

Name Type
path string

Returns: boolean


pow

pow(a1: number, a2: number): any

Parameters:

Name Type
a1 number
a2 number

Returns: any


print

print(): void

Returns: void

print(...args: any[]): any

Prints out a message to the script window. (sometimes, with errors, print messages will be suppressed)

Parameters:

Name Type
...args any[]

Returns: any


random_from_seed

random_from_seed(seed: string): random

Creates a new random generator from a specific seed.

Parameters:

Name Type
seed string

Returns: random


random_from_time

random_from_time(): random

Creates a new random generator from the current system time.

Returns: random


read_file

read_file(file: string): string

Reads a file from the file system.

note This operation does NOT require explicit permission from the user.

Parameters:

Name Type
file string

Returns: string


rotate_2d

rotate_2d(point: vector_3d, origin: vector_3d, angle: number): vector_3d

Returns a 3d point around an origin, ignoring the y value.

Parameters:

Name Type
point vector_3d
origin vector_3d
angle number

Returns: vector_3d


round

round(a: number): any

Parameters:

Name Type
a number

Returns: any


select_between

select_between(point1: vector_3d, point2: vector_3d): selection

Makes and returns a rectangular selection between two points.

Parameters:

Name Type
point1 vector_3d
point2 vector_3d

Returns: selection


select_origin

select_origin(origin: vector_3d, xRadius: number, zRadius: number): selection

Makes and returns a rectangular selection around an origin point

Parameters:

Name Type Description
origin vector_3d The center point of the selection
xRadius number
zRadius number

Returns: selection

selection


sin

sin(a: number): any

Parameters:

Name Type
a number

Returns: any


sinh

sinh(a: number): any

Parameters:

Name Type
a number

Returns: any


sqrt

sqrt(arg: number): any

Parameters:

Name Type
arg number

Returns: any


tan

tan(a: number): any

Parameters:

Name Type
a number

Returns: any


tanh

tanh(a: number): any

Parameters:

Name Type
a number

Returns: any


vec

vec(x: number, y: number, z: number): vector_3d

Creates a new vector from its components

Parameters:

Name Type
x number
y number
z number

Returns: vector_3d


write_file

write_file(file: string, content: string): void

Writes text to a file

note This operation REQUIRES explicit permission from the user, or it will throw an error.

Parameters:

Name Type
file string
content string

Returns: void