wiki.sine.space | sinespace

Difference between revisions of "Scripting/SInput"

From wiki.sine.space
Jump to: navigation, search
(Added and defined .Vibrate Clicktowalk AltFire Fire isVRActive isVRAvailable MouseLook TurnAxis VRLeftControllerPosition VRLeftControllerRotation VRRightControllerPosition VRRightControllerRotation)
(Added simple example .Vibrate Clicktowalk AltFire Fire isVRActive isVRAvailable MouseLook TurnAxis VRLeftControllerPosition VRLeftControllerRotation VRRightControllerPosition VRRightControllerRotation)
Line 14: Line 14:
  
 
==Members==
 
==Members==
{{ScriptFunction|bool|GetKeyDown|(string key);|Returns true if 'key' was pressed during this frame. }}
+
{{ScriptFunction|bool|GetKeyDown|(string key);|Returns true if 'key' was pressed during this frame. |5=<pre></pre> }}
  
{{ScriptFunction|bool|GetKey|(string key);|Returns true if 'key' is being held pressed. }}
+
{{ScriptFunction|bool|GetKey|(string key);|Returns true if 'key' is being held pressed. |5=<pre></pre> }}
  
{{ScriptFunction|bool|GetKeyUp|(string key);|Returns true if 'key' is no longer pressed during this frame (but was in the last). }}
+
{{ScriptFunction|bool|GetKeyUp|(string key);|Returns true if 'key' is no longer pressed during this frame (but was in the last). |5=<pre></pre> }}
  
{{ScriptFunction|bool|GetMouseDown|(int button);|Returns true if mouse 'button' was pressed during this frame. }}
+
{{ScriptFunction|bool|GetMouseDown|(int button);|Returns true if mouse 'button' was pressed during this frame. |5=<pre>if Space.Input.GetMouseDown(1) then
 +
  Space.Log("Right Mouse button pressed in this frame")
 +
end</pre> }}
  
{{ScriptFunction|bool|GetMouseHold|(int button);|Returns true if mouse 'button' is being held pressed. }}
+
{{ScriptFunction|bool|GetMouseHold|(int button);|Returns true if mouse 'button' is being held pressed.|5=<pre>if Space.Input.GetMouseHold(1) then
 +
  Space.Log("Right Mouse button being held")
 +
end</pre> }}
  
{{ScriptFunction|bool|GetMouseUp|(int button);|Returns true if mouse 'button' is no longer pressed during this frame (but was in the last). }}
+
{{ScriptFunction|bool|GetMouseUp|(int button);|Returns true if mouse 'button' is no longer pressed during this frame (but was in the last).|5=<pre>if Space.Input.GetMouseUp(1) then
 +
  Space.Log("Right Mouse button was just unpressed")
 +
end</pre>}}
  
{{ScriptFunction|void|Vibrate|()|Vibrates the controller (or phone, or gamepad) if a rumble device is present.|5=<pre></pre>}}
+
{{ScriptFunction|void|Vibrate|(float intensity, float duration, bool leftHand)|Vibrates the controller (or phone, or gamepad) if a rumble device is present.
 +
intensity: intensity from 0 to 1.0
 +
duration: duration (max 1.0 sec)
 +
leftHand: Rumble on the left hand (false = right hand), where applicable.|5=<pre>Space.Input.Vibrate(1,1,false)</pre>}}
  
  
 
==Properties==
 
==Properties==
  
{{ScriptFunction|float|ScrollWheel|{ get; }|Returns a non-0 value if the mouse wheel is being scrolled, value usually ranges from -1 to 1}}
+
{{ScriptFunction|float|ScrollWheel|{ get; }|Returns a non-0 value if the mouse wheel is being scrolled, value usually ranges from -1 to 1|5=<pre>if Space.Input.ScrollWheel> 0 then
 +
Space.Log("mouse wheel is being scrolled up")
 +
end</pre>}}
  
{{ScriptFunction|SVector|MousePosition|{ get; }|Returns the current position of the mouse in screen pixels. If on a touch screen device, this will also return the location of the first finger being pressed. }}
+
{{ScriptFunction|SVector|MousePosition|{ get; }|Returns the current position of the mouse in screen pixels. If on a touch screen device, this will also return the location of the first finger being pressed.|5=<pre>currentMousePos = Space.Input.MousePosition</pre> }}
  
{{ScriptFunction|SVector|MovementAxis|{ get; }|Returns left/right (A/D) movement on X, forward/back (W/S) on Y, and up/down (E/C) on Z}}
+
{{ScriptFunction|SVector|MovementAxis|{ get; }|Returns left/right (A/D) movement on X, forward/back (W/S) on Y, and up/down (E/C) on Z|5=<pre>moveAxis  = Space.Input.MovementAxis</pre>}}
  
{{ScriptFunction|bool|ClickToWalk|{ get; set; }|Enable or disable Click To Walk feature which allows movement of avatar by clicking the ground.|5= <pre></pre>}}
+
{{ScriptFunction|bool|ClickToWalk|{ get; set; }|Enable or disable Click To Walk feature which allows movement of avatar by clicking the ground.|5= <pre>Space.Input.ClickToWalk = true</pre>}}
  
{{ScriptFunction|bool|AltFire|{ get; }|Return true if alternative fire is pressed|5= <pre></pre>}}
+
{{ScriptFunction|bool|AltFire|{ get; }|Return true if alternative fire is pressed|5= <pre>if Space.Input.AltFire == true then
 +
  Space.Log("AltFire pressed")
 +
end</pre>}}
  
{{ScriptFunction|bool|Fire|{ get; }|Return true if primary fire is pressed|5= <pre></pre>}}
+
{{ScriptFunction|bool|Fire|{ get; }|Return true if primary fire is pressed|5= <pre>if Space.Input.Fire == true then
 +
  Space.Log("Fire pressed")
 +
end</pre>}}
  
{{ScriptFunction|bool|IsVRActive|{ get; }|Returns true if VR is active|5= <pre></pre>}}
+
{{ScriptFunction|bool|IsVRActive|{ get; }|Returns true if VR is active|5= <pre>if Space.Input.IsVRActive == true then
 +
  Space.Log("VR is active")
 +
end</pre>}}
  
{{ScriptFunction|bool|IsVRAvailable|{ get; }|Returns true if VR is available|5= <pre></pre>}}
+
{{ScriptFunction|bool|IsVRAvailable|{ get; }|Returns true if VR is available|5= <pre>if Space.Input.IsVRAvailable == true then
 +
  Space.Log("VR is available")
 +
end</pre>}}
  
{{ScriptFunction|bool|MouseLook|{ get;set; }|Enable or disable Mouse Look feature|5= <pre></pre>}}
+
{{ScriptFunction|bool|MouseLook|{ get;set; }|Enable or disable Mouse Look feature|5= <pre>Space.Input.MouseLook = true</pre>}}
  
{{ScriptFunction|SVector|TurnAxis|{ get; }|Returns the position of the axis of turning|5= <pre></pre>}}
+
{{ScriptFunction|SVector|TurnAxis|{ get; }|Returns the position of the axis of turning|5= <pre>turnAxis = Space.Input.TurnAxis</pre>}}
  
{{ScriptFunction|SVector|VRLeftControllerPosition|{ get; }|Returns position of Left VR Controller|5= <pre></pre>}}
+
{{ScriptFunction|SVector|VRLeftControllerPosition|{ get; }|Returns position of Left VR Controller|5= <pre>posVRleft = Space.Input.VRLeftControllerPosition</pre>}}
  
{{ScriptFunction|SQuaternion|VRLeftControllerRotation|{ get; }|Return rotation of Left VR Controller|5= <pre></pre>}}
+
{{ScriptFunction|SQuaternion|VRLeftControllerRotation|{ get; }|Return rotation of Left VR Controller|5= <pre>rotVRleft = Space.Input.VRLeftControllerRotation</pre>}}
  
{{ScriptFunction|SVector|VRRightControllerPosition|{ get; }|Returns position of Right VR Controller|5= <pre></pre>}}
+
{{ScriptFunction|SVector|VRRightControllerPosition|{ get; }|Returns position of Right VR Controller|5= <pre>posVRright = Space.Input.VRRightControllerPosition</pre>}}
  
{{ScriptFunction|SQuaternion|VRRightControllerRotation|{ get; }|Return rotation of Right VR Controller|5= <pre></pre>}}
+
{{ScriptFunction|SQuaternion|VRRightControllerRotation|{ get; }|Return rotation of Right VR Controller|5= <pre>rotVRright = Space.Input.VRRightControllerRotation</pre>}}
  
  
 
{{Scripting Navbox}}
 
{{Scripting Navbox}}

Revision as of 18:43, 24 December 2020

The SInput class returns the current state of input devices connected to the players device.

Keys

To ensure a cross-platform experience that works with Game Pads, Keyboards, Mouse and Mobile devices - as well as foreign language keyboards, we do not allow you to listen for specific keyboard keys, instead you may listen to predefined key groups which are consistent across devices. These can be used where ever a function argument is named 'key'.

Keys

  • Jump (usually spacebar)
  • Fly (usually f)
  • Run (usually left shift)
  • Submit (usually return key)
  • Cancel (usually escape)
  • Tab Horiz (usually tab key)
  • Tab Vert (gamepad only)

Members

GetKeyDown

bool GetKeyDown (string key);

Returns true if 'key' was pressed during this frame.


GetKey

bool GetKey (string key);

Returns true if 'key' is being held pressed.


GetKeyUp

bool GetKeyUp (string key);

Returns true if 'key' is no longer pressed during this frame (but was in the last).


GetMouseDown

bool GetMouseDown (int button);

Returns true if mouse 'button' was pressed during this frame.

if Space.Input.GetMouseDown(1) then
  Space.Log("Right Mouse button pressed in this frame")
end


GetMouseHold

bool GetMouseHold (int button);

Returns true if mouse 'button' is being held pressed.

if Space.Input.GetMouseHold(1) then
  Space.Log("Right Mouse button being held")
end


GetMouseUp

bool GetMouseUp (int button);

Returns true if mouse 'button' is no longer pressed during this frame (but was in the last).

if Space.Input.GetMouseUp(1) then
  Space.Log("Right Mouse button was just unpressed")
end


Vibrate

void Vibrate (float intensity, float duration, bool leftHand)

No documentation

Space.Input.Vibrate(1,1,false)



Properties

ScrollWheel

float ScrollWheel { get; }

Returns a non-0 value if the mouse wheel is being scrolled, value usually ranges from -1 to 1

if Space.Input.ScrollWheel> 0 then 
Space.Log("mouse wheel is being scrolled up")
end


MousePosition

SVector MousePosition { get; }

Returns the current position of the mouse in screen pixels. If on a touch screen device, this will also return the location of the first finger being pressed.

currentMousePos = Space.Input.MousePosition


MovementAxis

SVector MovementAxis { get; }

Returns left/right (A/D) movement on X, forward/back (W/S) on Y, and up/down (E/C) on Z

moveAxis  = Space.Input.MovementAxis


ClickToWalk

bool ClickToWalk { get; set; }

Enable or disable Click To Walk feature which allows movement of avatar by clicking the ground.

Space.Input.ClickToWalk = true


AltFire

bool AltFire { get; }

Return true if alternative fire is pressed

if Space.Input.AltFire == true then
  Space.Log("AltFire pressed")
end


Fire

bool Fire { get; }

Return true if primary fire is pressed

if Space.Input.Fire == true then
  Space.Log("Fire pressed")
end


IsVRActive

bool IsVRActive { get; }

Returns true if VR is active

if Space.Input.IsVRActive == true then
  Space.Log("VR is active")
end


IsVRAvailable

bool IsVRAvailable { get; }

Returns true if VR is available

if Space.Input.IsVRAvailable == true then
  Space.Log("VR is available")
end


MouseLook

bool MouseLook { get;set; }

Enable or disable Mouse Look feature

Space.Input.MouseLook = true


TurnAxis

SVector TurnAxis { get; }

Returns the position of the axis of turning

turnAxis = Space.Input.TurnAxis


VRLeftControllerPosition

SVector VRLeftControllerPosition { get; }

Returns position of Left VR Controller

posVRleft = Space.Input.VRLeftControllerPosition


VRLeftControllerRotation

SQuaternion VRLeftControllerRotation { get; }

Return rotation of Left VR Controller

rotVRleft = Space.Input.VRLeftControllerRotation


VRRightControllerPosition

SVector VRRightControllerPosition { get; }

Returns position of Right VR Controller

posVRright = Space.Input.VRRightControllerPosition


VRRightControllerRotation

SQuaternion VRRightControllerRotation { get; }

Return rotation of Right VR Controller

rotVRright = Space.Input.VRRightControllerRotation