Game (functions)/Direction: Difference between revisions

From PMDOWiki
Imbion (talk | contribs)
Created page with "== GAME:VectorToDirection(RogueElements.Loc) == Turns a vector (preferably a unit vector) into a cardinal or diagonal direction. === Arguments === * <code>v</code>: The vector. === Returns === The direction as one of 8 values. == GAME:VectorToDirection(System.Double,System.Double) == Convenience function to get a vector's components from lua numbers(doubles) === Arguments === * <code>X</code>: The X value of the vector * <code>Y</code>: The Y value of the ve..."
 
Imbion (talk | contribs)
No edit summary
 
Line 1: Line 1:
== GAME:VectorToDirection(RogueElements.Loc) ==
== VectorToDirection ==


Returns either an integer or a vector as an 8-directional direction.


Turns a vector (preferably a unit vector) into a cardinal or diagonal direction.
=== Context 1 ===
Takes in an integer.
{| class="wikitable"
{{ArgHeader}}
{{ArgRow
|name=num
|type=Integer
|techt=System.Int32
|purp=The integer to convert to a direction.
}}
|}


=== Context 2 ===
Takes in two doubles and finds the closest direction to that vector.


=== Arguments ===
{| class="wikitable"
{{ArgHeader}}
{{ArgRow
|name=x
|type=Double
|techt=(undocumented)
|purp=The X value of the vector
}}
{{ArgRow
|name=y
|type=Double
|techt=(undocumented)
|purp=The Y value of the vector
}}
|}


* <code>v</code>: The vector.
== RandomDirection ==


=== Returns ===
Generates a random direction. Returns an 8-directional direction.
 
The direction as one of 8 values.
 
== GAME:VectorToDirection(System.Double,System.Double) ==
 
 
Convenience function to get a vector's components from lua numbers(doubles)
 
 
=== Arguments ===
 
* <code>X</code>: The X value of the vector
* <code>Y</code>: The Y value of the vector
 
=== Returns ===
 
The direction the vector points to as one of 8 values.
 
== GAME:RandomDirection ==
 
 
Generates a random direction.
 
 
=== Returns ===
 
An 8-directional direction.
 
== GAME:SetupLuaFunctions(RogueEssence.Script.LuaEngine) ==
 
 
Setups any extra functionalities for this object written on the lua side.

Latest revision as of 00:20, 18 January 2026

VectorToDirection

Returns either an integer or a vector as an 8-directional direction.

Context 1

Takes in an integer.

Name Type Technical Type Purpose
num Integer System.Int32 The integer to convert to a direction.

Context 2

Takes in two doubles and finds the closest direction to that vector.

Name Type Technical Type Purpose
x Double (undocumented) The X value of the vector
y Double (undocumented) The Y value of the vector

RandomDirection

Generates a random direction. Returns an 8-directional direction.