Scroll commands with mouse wheel in both directions?

  • #1, by JoemcrSaturday, 10. January 2015, 00:04 10 years ago
    I'm using an MI1 style verb system, but I also want to be able to scroll through commands with the mouse wheel. I can set 'mouse wheel down' to 'set next command', but can't find a 'set previous command' option. Is there an easy way I'm missing to get 'mouse wheel up' to scroll through the commands in the opposite direction?

    Thanks

    Newbie

    96 Posts


  • #2, by afrlmeSaturday, 10. January 2015, 01:13 10 years ago
    Hmm I guess you could use a small Lua script function.

    1. create a new script & add this to it.
    --[[
    Command cycler (ASC|DESC) [v1] (10/01/2015)
    Written by AFRLme [Lee Clarke]
    -- + --
    afrlme@outlook.com | skype @ AFRLme
    -- + --
    This script is donation optional. In game credit is non-negotiable.
    You are free to: ¹ use it in your game(s). ² modify the script.
    Do not remove - or edit - this comment block.
    --]]
    
    -- * local variables * --
    local cmd_id -- empty variable
    
    -- * tables * --
    local t = { "left_click", "right_click", "middle_click" } -- replace with actual command names in order you created them (case sensitive)
    
    -- * cycle commands (true = increment, false = decrement) * --
    function cycle_commands(int, v)
     cmd_id = (game.ActiveCommand:getId().id + 1)
     if v then -- if true then change to next command
      if cmd_id ~= #t then setCommand( int, t[cmd_id + 1] ) else setCommand( int, t[1] ) end
     else -- change to previous command
      if cmd_id ~= 1 then setCommand( int, t[cmd_id - 1] ) else setCommand( int, t[#t] ) end
     end
    end
    
    -- * little workflow function to make it easier/faster to set command * --
    function setCommand(int, cmd)
     game.ActiveCommand = getObject("Interfaces[" .. int .. "].InterfaceButtons[" .. cmd .. "]")
    end
    

    2. inside of mouse wheel up actions: add an execute a script action containing...
    cycle_commands("name_of_interface", false)
    

    3. inside of mouse wheel down actions: add an execute a script action containing...
    cycle_commands("name_of_interface", true)
    


    I have also included a small workflow function I wrote for quickly updating the current active command. You should make sure that the commands are added to interface first, before any non-command buttons.

    Quick note: the initial index id is 0, which is why I added + 1 to the game.ActiveCommand:getId().id value, whereas tables in lua script start with an index value of 1.

    Imperator

    7278 Posts