Modem

A part that allows you to send messages cross-region and make HTTP requests to the web. It is a craftable and spawnable non-flammable solid.
It consumes 10 power per tick.
It cannot be resized.
At its default size (4x5x2) it has a durability of 1.
By default, its colour is #000000.
Methods
GetAsync(url, nocache, headers) → response
Identical to HttpService:GetAsync
.
The parameters for GetAsync
are as follows:
- The url parameter is a
string
. - The nocache parameter is a
boolean
. It can also benil
. - The headers parameter is a dictionary with keys that are
string
s and values that areany
s. It can also benil
.
The response return is a string
.
PostAsync(url, data, contentType, compress, headers) → response
Identical to HttpService:PostAsync
.
The parameters for PostAsync
are as follows:
- The url parameter is the destination address for the data. It is a
string
. - The data parameter is the data being sent. It is a
string
. - The contentType parameter is modifies the value in the
Content-Type
header sent with the request. It is anEnum.HttpContentType
. It can also benil
. - The compress parameter is determines whether the data is compressed (gzipped) when sent. It is a
boolean
. It can also benil
. - The headers parameter is used to specify some HTTP request headers. It is a dictionary with keys that are
string
s and values that areany
s. It can also benil
.
The response return is the HTTP response sent back indicating the request result. It is a string
.
RequestAsync(options) → response
Identical to HttpService:RequestAsync
.
The options parameter is a ModemRequest
.
The response return is a ModemRequestResponse
.
SendLocalMessage(data, id)
Sends a message to all modems in the same region of the same NetworkID
.
The parameters for SendLocalMessage
are as follows:
- The data parameter can be anything.
- The id parameter is a
string
. It can also benil
.
SendMessage(data, id)
The parameters for SendMessage
are as follows:
- The data parameter is a
JSON
. - The id parameter is a
string
. It can also benil
.
UrlEncode(input) → encodedUrl
The UrlEncode
function percent-encodes a given string so that reserved characters properly encoded with '%' and two hexadecimal characters.
Identical to HttpService:UrlEncode
.
The input parameter is a string
.
The encodedUrl return is a string
.
GetRequest(domain) → response
This method is deprecated. This function still 'exists', but has no effect.
The domain parameter is a string
.
The response return is a string
.
PostRequest(domain, data)
This method is deprecated. This function still 'exists', but has no effect.
The parameters for PostRequest
are as follows:
- The domain parameter is a
string
. - The data parameter is a
string
.
RealPostRequest(domain, data, asyncBool, transformFunction, optionalHeaders) → response
This method is deprecated. Use Modem:PostAsync
instead.
The parameters for RealPostRequest
are as follows:
- The domain parameter is a
string
. - The data parameter is a
string
. - The asyncBool parameter is a
boolean
. - The transformFunction parameter is a function of type
(...any) -> ()
. - The optionalHeaders parameter is a dictionary with keys that are
string
s and values that areany
s. It can also benil
.
The response return is a dictionary:
response
is astring
.success
is aboolean
.
Configurables
NetworkID
The ID of the network this modem should connect to. It is a string
.
Events
Loop(tickInterval)
Fires when the object is updated by the game loop.
The tickInterval parameter is the inverse of the tick rate. For example, if the tick rate is 20
, this will be 1 / 20
(or just 0.05
). If the tick rate commands are accessible, running them will change this value. It is a number
.
MessageSent(data)
The data parameter can be anything.