Verse Digest
Simulation
Simulation<public> := module:
Tags
Module import path: /Verse.org/Simulation/Tags
tag
A single gameplay tag, which represents a hierarchical name of the form x.y that is registered in the GameplayTagsManager You can filter the gameplay tags displayed in the editor.
tag<native><public> := class<abstract>:
tag_view
A queryable collection of gameplay tags.
tag_view<native><public> := interface<epic_internal>:
Has
Determine if TagToCheck is present in this container, also checking against parent tags {"A.1"}.Has("A") will return True, {"A"}.Has("A.1") will return False If TagToCheck is not Valid it will always return False.
Has<public>(TagToCheck:tag)<transacts><decides>:void
Checks if this container contains ANY of the tags in the specified container, also checks against parent tags {"A.1"}.HasAny({"A","B"}) will return True, {"A"}.HasAny({"A.1","B"}) will return False If InTags is empty/invalid it will always return False.
HasAny<public>(InTags:[]tag)<transacts><decides>:void
Checks if this container contains ALL of the tags in the specified container, also checks against parent tags {"A.1","B.1"}.HasAll({"A","B"}) will return True, {"A","B"}.HasAll({"A.1","B.1"}) will return False If InTags is empty/invalid it will always return True, because there were no failed checks.
HasAll<public>(InTags:[]tag)<transacts><decides>:void
tag_search
tag_search_sort_type<native><public> := enum:
Unsorted
Sorted
Advanced tag search criteria
tag_search_criteria<native><public> := class:
Tags required to be on the object.
RequiredTags<native><public>:[]tag = external {}
Tags that are used if no required tags are specified. These are treated as if any of them will do.
PreferredTags<native><public>:[]tag = external {}
Tags that may NOT be on the object. All items with these tags are excluded from the search.
ExclusionTags<native><public>:[]tag = external {}
Flag to request sorting the results by tag.
SortType<native><public>:tag_search_sort_type = external {}
@attribscope_class
@attribscope_struct
@attribscope_data
@customattribhandler
editable<public> := class(attribute):
agent<native><public> := class<unique><epic_internal>:
player<native><public> := class<unique><epic_internal>(agent):
Functions, Methods, and Getters
sleep
Waits specified number of seconds and then resumes. If
Seconds
= 0.0 then it waits until next tick/frame/update. IfSeconds
= Inf then it waits forever and only calls back if canceled - such as viarace
. IfSeconds
< 0.0 then it completes immediately and does not yield to other aysnc expressions.Waiting until the next update (0.0) is especially useful in a loop of a coroutine that needs to do some work every update and this yields to other coroutines so that it doesn't hog a processor's resources.
Waiting forever (Inf) will have any expression that follows never be evaluated. Occasionally it is desireable to have a task never complete such as the last expression in a
race
subtask where the task must never win the race though it still may be canceled earlier.Immediately completing (less than 0) is useful when you want programmatic control over whether an expression yields or not.
Sleep<native><public>(Seconds:float)<suspends>:void
Get the seconds that have elapsed since the world began simulating
GetSimulationElapsedTime<native><public>()<transacts>:float
team<native><public> := class<unique><epic_internal>:
Module import path: /Verse.org/Assets
Assets<public> := module:
array
Module import path: /Verse.org/Verse
Verse<public> := module:
Makes a flattened
array
by concatenating the elements ofArrays
.
Concatenate<public>(Arrays:[][]t where t:type)<computes>:[]t = external {}
Makes an
array
containingInput
's elements fromStartIndex
toStopIndex-1
.Fails unless
0 <= StartIndex <= StopIndex <= Input.Length
.
(Input:[]t where t:type).Slice<public>(StartIndex:int, StopIndex:int)<computes><decides>:[]t = external {}
Makes an
array
containingInput
's elements fromStartIndex
toInput.Length-1
.Succeeds if
0 <= StartIndex <= Input.Length
.
(Input:[]t where t:type).Slice<public>(StartIndex:int)<computes><decides>:[]t = external {}
Makes an
array
by insertingElementsToInsert
intoInput
such that the first element ofElementsToInsert
is atInsertionIndex
.
(Input:[]t where t:type).Insert<public>(InsertionIndex:int, ElementsToInsert:[]t)<computes><decides>:[]t = external {}
Makes an
array
by removing the element atIndexToRemove
fromInput
.Succeeds if
0 <= IndexToRemove <= Input.Length-1
.
(Input:[]t where t:type).RemoveElement<public>(IndexToRemove:int)<computes><decides>:[]t = external {}
Makes an
array
by removing the element at the lowest index that equalsElementToRemove
fromInput
.Fails if
Input
did not contain any instances ofElementToRemove
.
(Input:[]t where t:subtype(comparable)).RemoveFirstElement<public>(ElementToRemove:t)<computes><decides>:[]t = external {}
Makes an
array
by removing all elements that equalElementToRemove
fromInput
.
(Input:[]t where t:subtype(comparable)).RemoveAllElements<public>(ElementToRemove:t)<computes>:[]t = external {}
Makes an
array
by replacing the element atIndexToReplace
withElementToReplaceWith
inInput
.Succeeds if
0 <= IndexToReplace <= Input.Length-1
.
(Input:[]t where t:type).ReplaceElement<public>(IndexToReplace:int, ElementToReplaceWith:t)<computes><decides>:[]t = external {}
Makes an
array
by replacing the element at the lowest index that equalsElementToReplace
withElementToReplaceWith
inInput
.Fails if
Input
did not contain any instances ofElementToReplace
.
(Input:[]t where t:subtype(comparable)).ReplaceFirstElement<public>(ElementToReplace:t, ElementToReplaceWith:t)<computes><decides>:[]t = external {}
Makes an
array
by replacing all elements that equalElementToReplace
withElementToReplaceWith
inInput
.
(Input:[]t where t:subtype(comparable)).ReplaceAllElements<public>(ElementToReplace:t, ElementToReplaceWith:t)<computes>:[]t = external {}
Makes an
array
by replacing all ranges of elements that equalElementsToReplace
withReplacement
inInput
.When there are multiple overlapping instances of
ElementsToReplace
inInput
, only the position with the lowest index is replaced.
(Input:[]t where t:subtype(comparable)).ReplaceAll<public>(ElementsToReplace:[]t, Replacement:[]t)<transacts>:[]t = external {}
Makes an
array
by removingInput
's elements fromStartIndex
toStopIndex-1
.Succeeds if
0 <= StartIndex <= StopIndex <= Input.Length
.
(Input:[]t where t:type).Remove<public>(StartIndex:int, StopIndex:int)<computes><decides>:[]t = external {}
Returns the first index whose element in
Input
equalsElementToFind
.Fails if ElementToFind does not exist in the array.
(Input:[]t where t:subtype(comparable)).Find<public>(ElementToFind:t)<computes><decides>:int = external {}
cancelable
Implemented by classes that allow users to cancel an operation. For example, calling
subscribable.Subscribe
with a callback returns acancelable
object. CallingCancel
on the return object unsubscribes the callback.
cancelable<native><public> := interface:
Prevents any current or future work from completing.
Cancel<public>()<transacts>:void
disposable
Implemented by classes whose instances have limited lifetimes.
disposable<native><public> := interface:
Cleans up this object.
Dispose<public>():void
err
Halts the Verse runtime with error
Message
.
Err<native><public>(Message:[]char)<computes>:false
event
A recurring, successively signaled parametric
event
with apayload
allowing a simple mechanism to coordinate between concurrent tasks:Await
suspends tasks to wait on thisevent
,another task
Signal
s thisevent
and resumes the suspended tasks in FIFO order.
event<native><public>(t:type)<computes> := class(signalable(t), awaitable(t)):
Suspends the current task until another task calls
Signal
. If called during another invocation ofSignal
, the the task will still suspend and resume during the next call toSignal
.
Await<native><override>()<suspends>:t
Concurrently resumes the tasks that were suspended by
Await
calls before this call toSignal
.
signal
Tasks are resumed in the order they were suspended. Each task will perform as much work as it can until it encounters a blocking call, whereupon it will transfer control to the next suspended task.
Signal<native><override>(Val:t):void
A recurring, successively signaled event allowing a simple mechanism to coordinate between concurrent tasks.
event<public>()<computes> := event(tuple())
Ceil
Returns the smallest
int
that is greater than or equal toVal
.Fails if
not IsFinite(Val)
.
Ceil<native><public>(Val:float)<varies><decides>:int
Floor
Returns the largest
int
that is less than or equal toVal
.Fails if
not IsFinite(Val)
.
Floor<native><public>(Val:float)<varies><decides>:int
Round
Returns
Val
rounded to the nearestint
. When the fractional part ofVal
is0.5
,rounds to the nearest even
int
(per the IEEE-754 default rounding mode).Fails if
not IsFinite(Val)
.
Round<native><public>(Val:float)<varies><decides>:int
Int
Returns the
int
that equalsVal
without the fractional partFails if
not IsFinite(val)
.
Int<native><public>(Val:float)<varies><decides>:int
ToString
Makes a
string
representation ofVal
.
ToString<native><public>(Val:float)<varies>:[]char
Makes a printable
string
representation ofVal
.
ToString<native><public>(Val:int)<computes>:[]char
IsValid
Implemented by classes whose instances can become invalid at runtime.
invalidatable<native><public> := interface(disposable):
Succeeds if this object is still valid.
IsValid<public>()<transacts><decides>:void
listenable
A parametric interface combining
awaitable
andsubscribable
.
listenable<public>(payload:type)<computes> := interface(awaitable(payload), subscribable(payload)):
A parameterless interface combining
awaitable
andsubscribable
.
listenable<public>()<computes> := listenable(tuple())
message localization
Used for message localization.
locale<native><public> := struct<computes><epic_internal>:
A localizable text message.
message<native><public> := class<computes><epic_internal>:
Makes a
string
by localizingMessage
based on the currentlocale
.
Localize<native_callable><public>(Message:message)<varies>:[]char = external {}
localizable_value<epic_internal> := interface:
localizable_string<epic_internal> := class<computes><internal>(localizable_value):
MakeLocalizableValue<epic_internal>(V:[]char)<computes>:localizable_string = external {}
localizable_int<epic_internal> := class<computes><internal>(localizable_value):
MakeLocalizableValue<epic_internal>(V:int)<computes>:localizable_int = external {}
localizable_float<epic_internal> := class<computes><internal>(localizable_value):
MakeLocalizableValue<epic_internal>(V:float)<computes>:localizable_float = external {}
MakeMessageInternal<native><epic_internal>(K:[]char, D:[]char, S:[[]char]localizable_value)<converges>:message
pi
Pi, the ratio of the circumference of a circle to its diameter.
PiFloat<public>:float = external {}
clamp
Constrains the value of
Val
betweenA
andB
. Robustly handles different argument orderings.Returns the median of
Val
,A
, andB
, such that comparisons withNaN
operate as ifNaN > +Inf
.
Clamp<public>(Val:float, A:float, B:float)<computes>:float = external {}
Constrains the value of
Val
betweenA
andB
. Robustly handles different argument orderings.Returns the median of
Val
,A
, andB
.
Clamp<native><public>(Val:int, A:int, B:int)<computes>:int
min_max
Returns the minimum of
X
andY
.
Min<public>(X:int, Y:int)<computes>:int = external {}
Returns the maximum of
X
andY
.
Max<public>(X:int, Y:int)<computes>:int = external {}
Returns the minimum of
X
andY
unless either areNaN
.Returns
NaN
if eitherX
orY
areNaN
.
Min<public>(X:float, Y:float)<computes>:float = external {}
Returns the maximum of
X
andY
unless either areNaN
.Returns
NaN
if eitherX
orY
areNaN
.
Max<public>(X:float, Y:float)<computes>:float = external {}
Sqrt
Returns the square root of
X
ifX >= 0.0
.Returns
NaN
ifX < 0.0
.
Sqrt<native><public>(X:float)<varies>:float
Sin
Returns the sine of
X
ifIsFinite(X)
.Returns
NaN
if `not IsFinite(X)
Sin<native><public>(X:float)<varies>:float
Cos
Returns the cosine of
X
ifIsFinite(X)
.Returns
NaN
if `not IsFinite(X)
Cos<native><public>(X:float)<varies>:float
Tan
Returns the tangent of
X
ifIsFinite(X)
.Returns
NaN
if `not IsFinite(X).
Tan<native><public>(X:float)<varies>:float
ArcSin
Returns the inverse sine (arcsine) of
X
if-1.0 <= X <= 1.0
.
ArcSin<native><public>(X:float)<varies>:float
ArcCos
Returns the inverse cosine (arccosine) of
X
if-1.0 <= X <= 1.0
.
ArcCos<native><public>(X:float)<varies>:float
ArcTan
Returns the inverse tangent (arctangent) of
X
such that:-PiFloat/2.0 <= ArcTan(x) <= PiFloat/2.0
.
ArcTan<native><public>(X:float)<varies>:float
Returns the angle in radians at the origin between a ray pointing to
(X, Y)
and the positive
X
axis such that-PiFloat < ArcTan(Y, X) <= PiFloat
.Returns 0.0 if
X=0.0 and Y=0.0
.
ArcTan<native><public>(Y:float, X:float)<varies>:float
Sinh
Returns the hyperbolic sine of
X
.Sinh<native><public>(X:float)<varies>:float
Cosh
Returns the hyperbolic cosine of
X
.Cosh<native><public>(X:float)<varies>:float
Tanh
Returns the hyperbolic tangent of
X
.Tanh<native><public>(X:float)<varies>:float
ArSinh
Returns the inverse hyperbolic sine of
X
ifIsFinite(X)
.
ArSinh<native><public>(X:float)<varies>:float
ArCosh
Returns the inverse hyperbolic cosine of
X
if1.0 <= X
.
ArCosh<native><public>(X:float)<varies>:float
ArTanh
Returns the inverse hyperbolic tangent of
X
ifIsFinite(X)
.
ArTanh<native><public>(X:float)<varies>:float
Pow
Returns
A
to the power ofB
.
Pow<native><public>(A:float, B:float)<varies>:float
Quotient
Returns
X
ifX
is finite.Fails if
X
is one of:`+Inf
-Inf
NaN
(X:float).IsFinite<public>()<computes><decides>:float = external {}
Returns the quotient
X/Y
as defined by Euclidean division, i.e.:Quotient[X/Y] = Floor[X/Y]
whenY > 0
Quotient[X/Y] = Ceil[X/Y]
whenY < 0
Quotient[X/Y] * Y + Mod[X,Y] = X
Fails if
Y = 0
.
Quotient<native><public>(X:int, Y:int)<computes><decides>:int
Mod
Returns the remainder of
X/Y
as defined by Euclidean division, i.e.:Mod[X,Y] = X - Quotient(X/Y)*Y
0 <= Mod[X,Y] < Abs(Y)
Fails if
Y=0
.
Mod<native><public>(X:int, Y:int)<computes><decides>:int
Exp
Returns the natural exponent of
X
.
Exp<native><public>(X:float)<varies>:float
Ln
Returns the natural logarithm of
X
.
Ln<native><public>(X:float)<varies>:float
Log
Returns the base
B
logarithm ofX
.
Log<public>(B:float, X:float)<varies>:float = external {}
Lerp
Used to linearly interpolate/extrapolate between
From
(whenParameter = 0.0
) andTo
(whenParameter = 1.0
). Expects that all arguments are finite.Returns
From*(1 - Parameter) + To*Parameter
.
Lerp<native><public>(From:float, To:float, Parameter:float)<varies>:float
Sgn
Returns the sign of
Val
:1
ifVal > 0
0
ifVal = 0
-1
ifVal < 0
Sgn<public>(Val:int)<computes>:int = external {}
Returns the sign of
Val
:1.0
ifVal > 0.0
0.0
ifVal = 0.0
-1.0
ifVal < 0.0
NaN
ifVal = NaN
Sgn<public>(Val:float)<computes>:float = external {}
AbsoluteTolerance
Succeeds if
Val
is withinAbsoluteTolerance
of0.0
.
(Val:float).IsAlmostZero<public>(AbsoluteTolerance:float)<computes><decides>:void = external {}
Succeeds if
Val1
andVal2
are withinAbsoluteTolerance
of each other.
IsAlmostEqual<public>(Val1:float, Val2:float, AbsoluteTolerance:float)<computes><decides>:void = external {}
Print
Writes
Message
to a dedicatedPrint
log while displaying it inColor
on the client screen forDuration
seconds. By default,Color
isNamedColors.White
andDuration
is2.0
seconds.
Print<native><public>(Message:[]char, ?Duration:float = external {}, ?Color:color = external {}):void
Signal
A parametric interface implemented by events with a
payload
that can be signaled.Can be used with
awaitable
,subscribable
, or both (see:listenable
).
signalable<public>(payload:type)<computes> := interface:
Concurrently resumes the tasks waiting for this event in
awaitable.Await
and synchronously invokes any callbacks added to this event bysubscribable.Subscribe
.
Signal<public>(Val:payload):void
Join
Makes a
string
by concatenatingSeparator
between the elements ofStrings
.Join<native><public>(Strings:[][]char, Separator:[]char)<computes>:[]char
ToString
Returns
String
without modification.ToString<public>(String:[]char)<computes>:[]char = external {}
Makes a
string
fromCharacter
.ToString<native><public>(Character:char)<computes>:[]char
Subscribe
A parametric interface implemented by events with a
payload
that can be subscribed to.Matched with
signalable.
subscribable<public>(t:type)<computes> := interface:
Registers
Callback
to be invoked on matching calls tosignable.Signal
.Returns an unsubscriber object. Call
cancelable.Cancel
on the unsubscriber to unregisterCallback
.
Subscribe<public>(Callback:type {__(:t):void})<transacts>:cancelable
A parameterless interface implemented by events that can be subscribed to.
subscribable<public>()<computes> := subscribable(tuple())
Random
Module import path: /Verse.org/Random
Random<public> := module:
Float
Returns a random
float
betweenLow
andHigh
, inclusive.
GetRandomFloat<native><public>(Low:float, High:float)<varies>:float
Int
Returns a random
int
betweenLow
andHigh
, inclusive.
GetRandomInt<native><public>(Low:int, High:int)<varies>:int
Shuffle
Makes an
array
with the same elements asInput
shuffled in a random order.
Shuffle<public>(Input:[]t where t:type)<transacts>:[]t = external {}
Colors
Module import path: /Verse.org/Colors
Colors<public> := module:
Represents colors as RGB triples in the ACES 2065-1 color space.
Component values are linear (i.e.
*gamma* = 1.0
).
color<native><public> := struct<computes>:
Red component of this
color
.
R<native><public>:float = external {}
Green component of this
color
.
G<native><public>:float = external {}
Blue component of this
color
.
B<native><public>:float = external {}
Makes an ACES 2065-1
color
from the component-wise sum ofc0
andc1
.
operator'+'<native><public>(c0:color, c1:color)<converges>:color
Makes an ACES 2065-1
color
from the component-wise difference ofc0
andc1
.
operator'-'<native><public>(c0:color, c1:color)<converges>:color
Makes an ACES 2065-1
color
from the component-wise product ofc0
andc1
.
operator'*'<native><public>(c0:color, c1:color)<converges>:color
Makes an ACES 2065-1
color
from each component ofc
scaled byfactor
.
operator'*'<native><public>(c:color, factor:float)<converges>:color
Makes an ACES 2065-1
color
from each component ofc
scaled byfactor
.
operator'*'<native><public>(c:color, factor:int)<converges>:color
Makes an ACES 2065-1
color
from each component ofc
scaled byfactor
.
operator'*'<native><public>(factor:float, c:color)<converges>:color
Makes an ACES 2065-1
color
from each component ofc
scaled byfactor
.
operator'*'<native><public>(factor:int, c:color)<converges>:color
Makes an ACES 2065-1
color
from each component ofc
divided byfactor
.
operator'/'<native><public>(c:color, factor:float)<computes><decides>:color
Makes an ACES 2065-1
color
from each component ofc
divided byfactor
.
operator'/'<native><public>(c:color, factor:int)<computes><decides>:color
MakeColor
Makes an ACES 2065-1
color
from sRGB componentsRed
,Green
, andBlue
.Normal sRGB component values are between
0.0
and1.0
, but this can handle larger values.
MakeColorFromSRGB<native><public>(Red:float, Green:float, Blue:float)<converges>:color
MakeSRGB
Makes an sRGB
tuple
by convertingInColor
from an ACES 2065-1color
to sRGB.
MakeSRGBFromColor<native><public>(InColor:color)<converges>:tuple(float, float, float)
Makes an ACES 2065-1
color
from the integer sRGB componentsRed
,Green
, andBlue
.Valid sRGB component values are between '0' and '255', inclusive.
MakeColorFromSRGBValues<native><public>(Red:int, Green:int, Blue:int)<converges>:color
FromHex
Makes an ACES 2065-1
color
from a CSS-style sRGBhexString
. Supported formats are:RGB
RRGGBB
RRGGBBAA
#RGB
#RRGGBB
#RRGGBBAA
An invalid hex string will return
Black
.
MakeColorFromHex<native><public>(hexString:[]char)<converges>:color
FromHSV
Makes an ACES 2065-1
color
fromHue
,Saturation
, andValue
components.Components use the HSV color model in the sRGB color space. Expected ranges:
0.0 <= Hue <= 360.0
0.0 <= Saturation <= 1.0
0.0 <= Value <= 1.0
Values out of expected ranges will undergo range reduction and conversion.
MakeColorFromHSV<native><public>(Hue:float, Saturation:float, Value:float)<converges>:color
Makes an HSV
tuple
by convertingInColor
from an ACES 2065-1color
to sRGB and applying the HSV color model.
MakeHSVFromColor<native><public>(InColor:color):tuple(float, float, float)
FromTemperature
Makes an ACES 2065-1
color
from the chromaticty of a blackbody radiator atTemperature
Kelvin.Temperature
is clamped such that0 <= Temperature
.
MakeColorFromTemperature<native><public>(Temperature:float)<converges>:color
NamedColors
Module import path: /Verse.org/Colors/NamedColors
Color presets from CSS Color Module 3 Extended color keywords.
NamedColors<public> := module:
Native
Module import path: /Verse.org/Native
Native<public> := module:
@attribscope_class
@attribscope_struct
import_as_attribute<epic_internal> := class(attribute):
import_as<epic_internal>(importName:[]char)<computes>:import_as_attribute
Concurrency
Module import path: /Verse.org/Concurrency
Concurrency<public> := module:
await
A parametric interface implemented by events with a
payload
that can be waited on. Matched withsignalable.
awaitable<public>(payload:type)<computes> := interface:
Suspends the current task until resumed by a matching call to
signalable.Signal
. Returns the eventpayload
.
Await<public>()<suspends>:payload
awaitable<public>()<computes> := awaitable(void)
task<native><public>(t:type)<computes> := class<abstract><final>(awaitable(t)): Await<native><override>()<suspends>:t
Was this helpful?