Anchor Keybind!

Discussion in 'Open' started by Lost Ninja, Aug 13, 2018.

  1. Lost Ninja

    Lost Ninja Well-Known Member

    Joined:
    Jul 17, 2015
    Messages:
    1,192
    Likes Received:
    848
    I was rather hoping that some of the customisation that I assume was added for the console release especially for key-bindings (controllers have more buttons than are I think currently in the PC version) would trickle down to the PC version for the 1.0 release. But was disappointed... In fact was disappointed by the 1.0 release as there seemed to be no "BANG!!!" just a live stream (which we get anyway).

    Still I love the game and am looking forward until the dev when such basic functionality of even the most basic of games appears in this one. Until then however I decided that not having a button to press to anchor/un-anchor was something I couldn't play without any more so decided to make my own.

    However I'm no AutoHotKey Wizard so I was wondering if anyone else has solved the issue in this manner and how you did so? Is it better than my own (can't be much worse).

    Comments are after the semi-colon ";".
    (Save position is untested, by me. But I see no reason why it wouldn't work.)
    Code:
    ^z::
    {
      MouseGetPos x, y  ; CTRL+Z saves position
    }
    
    ^j:: ; Ctrl+J
     {
       mousegetpos, start_x, start_y        ; Sets the start position of your cursor
       mouseclick, left, %x%, %y%, 1, 0    ;  Clicks at the coordinates set above
       mousemove, %start_x%, %start_y%, 0 ; Returns mouse to the start position.
     }
    return
    
    Save position by @layer1 with thanks... :)

    It has issues:
    1. If you're holding the right button down to look around your view point jumps
    2. It's not easy to release for other people to use because you have to manually set the coordinates.
    3. This one only works in Campaign and while you could make a creative/R&D version the two aren't interchangeable.


     
    #1 Lost Ninja, Aug 13, 2018
    Last edited: Aug 14, 2018
    ZeroGravitas and AstraTheDragon like this.
  2. Lost Ninja

    Lost Ninja Well-Known Member

    Joined:
    Jul 17, 2015
    Messages:
    1,192
    Likes Received:
    848
    If like me you have a Logitech keyboard with G keys (or a mouse), then the following can be used as well. I assume that the AutoHotKey Script above can be modified in a similar way but I'm less familiar with it than LUA.

    Currently I'm using a G13 (little keyboard thing resembling a cut down real keyboard but just the WASD + keys round about it), if you open up the software (LGS) and right click on the profile that you use for TerraTech, then click Scripting. Now choose two G keys that you can use to set the location of the anchor button. In my case I use the button I also use as CTRL plus another that is by my thumb (G15 + G24). If you press these buttons the Scripting window that popped up when you clicked scripting will show you what the numbers of the buttons you just pressed are (in case you don't know). Now choose a button to use to anchor/un-anchor, it can be one of the two you already selected (or an entirely different one, but still a G-Key).

    Next copy this code into the scripting window replacing the existing text:
    Code:
    aX = 0;
    aY = 0;
    
    function OnEvent(event, arg)
        OutputLogMessage("event = %s, arg = %s\n", event, arg)
        if(event == "G_PRESSED" and arg == 24) and (event == "G_PRESSED" and arg == 15) then  -- Change 24 & 15 to the selected keys*
            aX, aY = GetMousePosition()
        end
        if(event == "G_PRESSED" and arg == 24) then  -- Change 24 to the selected key to anchor/un-anchor**
            mX, mY = GetMousePosition();
            Sleep(3);
            if (IsMouseButtonPressed(2)) then
                m2 = 1
                ReleaseMouseButton(2);
            else
                m2 = 0
            end
            MoveMouseTo(aX,aY);
            PressMouseButton(1);
            ReleaseMouseButton(1);
            Sleep(3);
            MoveMouseTo(mX, mY);
            if(m2 == 1) then
                PressMouseButton(2);
            end
        end
    end
    * Two G-Keys that can be pressed together to set the location of the anchor button.
    ** One G-Key that will be used to trigger the anchor button.

    This fixes from the AutoHotKey version the fact that it would only work (without editing the script) in Campaign as now you can move the anchor button press location. It also seems to be a little more responsive.

    Still have some issues:
    1. Can only be used with a Logitech gaming peripheral (must have G Keys).
    2. If you are looking around when you press the button the view jumps.


     
    ZeroGravitas likes this.
  3. layer1

    layer1 Well-Known Member

    Joined:
    Jun 14, 2017
    Messages:
    227
    Likes Received:
    264
    You can add another key combo to modify x/y in game so you don't have to mess with editing the file. IIRC it would be as simple as something like this:

    Code:
    ^z:: { MouseGetPos x, y } ; CTRL+Z saves position
    You may not need the {braces} - maybe. I don't remember offhand.

     
    Lost Ninja likes this.

Share This Page