Modding Help Can tech lua get the mouse click event?

Discussion in 'Starbound Modding' started by helloLateNight, Oct 30, 2014.

  1. helloLateNight

    helloLateNight Subatomic Cosmonaut

    I want to create a teach, and when player click his mouse button, the tech will do something. But I don't know how to get the mouse click event. Can anybody help me, thanks a lot~
     
  2. AstralGhost

    AstralGhost Pangalactic Porcupine

    Yes, I think so.

    I believe you get it like so:
    Code:
    function input(args)
        if args.moves["primaryFire"] == true then
          return something
        end
    end
    If you don't already know, the input function is a preset API function like init() and update(args).
    args.moves is a table passed down to this function with various input. I believe "primaryFire" holds the mouse state. I think "altFire" is for the right mouse button.
    I believe this is correct but could be wrong, though. I didn't test it to be sure, and I haven't yet done a tech mod myself. Let me know if it doesn't work and I'll check again and test some things out.

    It's not really a logical or common-sense process and there doesn't seem to be any sort of documentation by the admins. As you can tell it's obviously not very mod-friendly despite that being their goal here. So I'd give you more info, but I don't have any at the moment.

    As a side note, I do know you can also get the mouse's position in the update function using this: args.aimPosition. Though that's not helpful if you want a click event, I know.
    And also for reference, You can collect the mouse click event in the new GUI API by using this:
    Code:
    function canvasClickEvent(position, button)
    This one makes a bit more sense, obviously.
     
    helloLateNight likes this.
  3. helloLateNight

    helloLateNight Subatomic Cosmonaut

    I use args.moves["primaryFire"], and it works!
    Thanks a lot!~
     
    AstralGhost likes this.
  4. AstralGhost

    AstralGhost Pangalactic Porcupine

    No problem.
    Thanks for confirming that it works. :)
     

Share This Page