Based on the Visionaire Studio Guide by Chris Tikkos (Dionous Games), published here with his permission. The commands are described in the global commands reference.
Mouse setup
You define the mouse actions in Game Properties > Mouse Properties:

With the lightning button you add action parts that run on mouse events, for example left, right or double click and mouse wheel up or down. Here you also define whether the playable character walks to the clicked position, only walks when you click an object, or does not walk at all.
The same is possible with Lua:
-- left click does not send the character to the cursor position game.LeftClickBehaviour = eMouseActionBehaviourDoNotSendCharacter
For the other buttons use game.RightClickBehaviour, game.MiddleClickBehaviour and game.LeftHoldBehaviour. Instead of the names you can also use the numbers of the enum:
0=eMouseActionBehaviourDoNotSendCharacter: the character does not walk to the position.1=eMouseActionBehaviourSendCharacterToCursor: the character walks to the position.2=eMouseActionBehaviourSendCharacterToObjects: the character only walks there if the position is a scene object.
Handling mouse events with Lua
For full control, register an event handler for mouse events in a definition script:
function onMouseEvent(eventType, mousePosition)
if eventType == eEvtMouseWheelUp or eventType == eEvtMouseWheelDown then
-- the mouse wheel was used, do something
end
end
registerEventHandler("mouseEvent", "onMouseEvent", {eEvtMouseWheelUp, eEvtMouseWheelDown})
The handler function always gets two arguments: eventType, one of the events from the list you registered, and mousePosition, the current position (x, y). If you pass no list, the handler receives all mouse events. Supported events:
eEvtMouseMoveeEvtMouseLeftButtonDoubleClick,eEvtMouseLeftButtonDown,eEvtMouseLeftButtonUp,eEvtMouseLeftButtonHold,eEvtMouseLeftButtonHoldingeEvtMouseRightButtonDoubleClick,eEvtMouseRightButtonDown,eEvtMouseRightButtonUpeEvtMouseMiddleButtonDown,eEvtMouseMiddleButtonUpeEvtMouseWheelUp,eEvtMouseWheelDown
Repeating something while a button is held
Combine a mouse event handler with a mainLoop handler. Use one mouse event handler that checks the event type:
local buttonPressed = false
function onMainLoop()
if buttonPressed then
-- runs every frame while the left button is held
end
end
function onMouseButtons(eventType, mousePosition)
if eventType == eEvtMouseLeftButtonDown then
buttonPressed = true
elseif eventType == eEvtMouseLeftButtonUp then
buttonPressed = false
end
end
registerEventHandler("mouseEvent", "onMouseButtons", {eEvtMouseLeftButtonDown, eEvtMouseLeftButtonUp})
registerEventHandler("mainLoop", "onMainLoop")
Gamepads
Visionaire uses the SDL library, so every controller that SDL supports works. Download gamecontrollerdb.txt and place it in your game folder. It contains mappings for almost all controllers; you can add your own with mapping tools.
Gamepad buttons arrive as key events. The shoulder triggers can be detected like this inside your key event handler:
function keyboardHandler(eventType, character, keycode, modifiers)
if string.match(character, "TRIGGERLEFT") then
if keycode > 1 then print("left trigger pressed") else print("left trigger released") end
elseif string.match(character, "TRIGGERRIGHT") then
if keycode > 1 then print("right trigger pressed") else print("right trigger released") end
end
return false
end
registerEventHandler("keyEvent", "keyboardHandler")
There are two ways to control an adventure with a gamepad:
- Move the character directly. Use action areas or Lua to check whether the character is near an object it can interact with. When the action button is pressed, check whether the character is inside the area or within a certain radius.
- Move the cursor like a mouse.
Only one event handler per type is allowed (except mainLoop), so if your game already has a key event handler, add the trigger check there. See also preventing video and cutscene skipping for a complete key event handler.