Table of Contents

vci.me.GetAxisInput() (Key input)


Receive keyboard input with VCI.


List of keys

VCI control key Default key bind Script Available value
Forward Up Arrow vci.me.GetAxisInput().z Z = +1
Backward Down Arrow vci.me.GetAxisInput().z Z = -1
Left Left Arrow vci.me.GetAxisInput().x X = -1
Right Right Arrow vci.me.GetAxisInput().x X = +1
Up U vci.me.GetAxisInput().y Y = +1
Down I vci.me.GetAxisInput().y Y = -1
Key1 1 (Numeral 1) vci.me.GetButtonInput(1) true,false
Key2 2 (Numeral 2) vci.me.GetButtonInput(2) true,false
Key3 3 (Numeral 3) vci.me.GetButtonInput(3) true,false
Key4 4 (Numeral 4) vci.me.GetButtonInput(4) true,false

Summary of key input


GetButtonInput()

Argument: number Return value: bool
Returns true when the button corresponding to the argument is being pressed. If not, false is returned.

main.lua
    -- Show a message on console when Key1 is pressed
    if  vci.me.GetButtonInput(1) then
        print(" Button1 pushed")
    end

GetAxisInput()

return value: Vector3
Returns Vector3 that represents the state when the corresponding key is pressed for Forward, Backward, Left, Right, Up and Down.
When not pressed, the value is 0. When pressed, the value is either -1 or 1.

main.lua
    -- The state of key is stored in the axis as Vector3
    local axis = vci.me.GetAxisInput()
 
    -- Show on console    
    print(" axis : "..tostring(axis))

Example script

main.lua
function update()
 
    -- Get the axis input.
    local axis = vci.me.GetAxisInput()
 
    if axis.x ~= 0 then
        print(" X : "..tostring(axis.x))
    end
 
    if axis.y ~= 0 then
        print(" Y : "..tostring(axis.y))
    end
 
    if axis.z ~= 0 then
        print(" Z : "..tostring(axis.z))
    end
 
    if  vci.me.GetButtonInput(1) then
        print(" Button1 pushed")
    end
 
    if  vci.me.GetButtonInput(2) then
        print(" Button2 pushed")
    end
 
    if  vci.me.GetButtonInput(3) then
        print(" Button3 pushed")
    end
 
    if  vci.me.GetButtonInput(4) then
        print(" Button4 pushed")
    end
 
end

An example that displays the result of each key being pushed on the console.


Example VCI