Squirrel/Client/Functions/Misc/WorldPosToScreen

From Liberty Unleashed Wiki
(Difference between revisions)
Jump to: navigation, search
(Created page with "== Syntax == <code>VectorScreen WorldPosToScreen( Vector Position )</code>")
 
(Syntax)
 
Line 2: Line 2:
  
 
<code>VectorScreen WorldPosToScreen( Vector Position )</code>
 
<code>VectorScreen WorldPosToScreen( Vector Position )</code>
 +
 +
== Arguments ==
 +
 +
* '''Vector''' - A 3D vector value from a world position.
 +
 +
== Example ==
 +
 +
This code will get a position on the screen (for GUI) from a 3D position in the game.
 +
 +
<code lang="squirrel">
 +
function onClientCommand(cmd, text)
 +
{
 +
    if(cmd == "myscreenpos")
 +
    {
 +
local LocalPlayer = FindLocalPlayer( );
 +
local myScreenPos = WorldPosToScreen ( LocalPlayer.Pos );
 +
        Message ( "The screen position is " + myScreenPos.x + ", " + myScreenPos.y );
 +
    }
 +
}
 +
</code>
 +
 +
=== Notes ===
 +
 +
The event [[Squirrel/Client/Events/Player/onClientCommand|onClientCommand]] and function [[Squirrel/Client/Functions/Players/FindLocalPlayer|FindLocalPlayer]] was used in this example. More information is available on its corresponding page.

Latest revision as of 21:10, 2 April 2017

Contents

[edit] Syntax

  1. VectorScreen WorldPosToScreen( Vector Position )

[edit] Arguments

  • Vector - A 3D vector value from a world position.

[edit] Example

This code will get a position on the screen (for GUI) from a 3D position in the game.

  1.  
  2. function onClientCommand(cmd, text)
  3. {
  4. if(cmd == "myscreenpos")
  5. {
  6. local LocalPlayer = FindLocalPlayer( );
  7. local myScreenPos = WorldPosToScreen ( LocalPlayer.Pos );
  8. Message ( "The screen position is " + myScreenPos.x + ", " + myScreenPos.y );
  9. }
  10. }
  11.  

[edit] Notes

The event onClientCommand and function FindLocalPlayer was used in this example. More information is available on its corresponding page.

Personal tools
Namespaces

Variants
Actions
Navigation
scripting
Toolbox