Modding Help Setting Boomerang handGrip to "wrap" (SOLVED)

Discussion in 'Starbound Modding' started by tGMP, Feb 28, 2023.

  1. tGMP

    tGMP Void-Bound Voyager

    Odd request, but is there a way to set the handGrip on a boomerang to wrap? Setting it in the activeitem file did nothing.
     
  2. Rezetrx

    Rezetrx Void-Bound Voyager

    Hey there, I've looked into the handGrip part and found something. (As you already made this post, I'll write it here.)

    Make a copy of "boomerang.lua" and rename it, then in the update you add the following line.
    Code:
    activeItem.setOutsideOfHand(true)
    
    Then in your weapon change "scripts" : ["boomerang.lua"] to your new script.

    upload_2023-3-1_9-11-41.png
    upload_2023-3-1_9-11-45.png
     
  3. tGMP

    tGMP Void-Bound Voyager

    where do i add that line? it changed nothing for me.
     
  4. Rezetrx

    Rezetrx Void-Bound Voyager

    Within the update code block
    If nothing changed, make sure you actually change the LUA file reference inside the .activeitem

    Attached is the "mod" that contains my changed files.
     

    Attached Files:

  5. tGMP

    tGMP Void-Bound Voyager

    ok, so that DOES work. however, that sets it to only outside of the hand. when handGrip is set to wrap, the weapon is to always be covering the hand. after applying the corrected code myself, the weapon's arm wouldnt move or shoot
     
  6. Rezetrx

    Rezetrx Void-Bound Voyager

    Try using this instead. (just replace the other "activeItem.setOutsideOfHand(true)" line
    Code:
    activeItem.setOutsideOfHand( ((activeItem.hand() == "primary" and -1 or 1) == mcontroller.facingDirection()))
    

    Here an explanation of what each component does and the logic behind it:
    • activeItem.hand() returns "primary" if in left slot and "alt" if in right slot.
      (Two handed weapons always return "primary" but that is not important for us now)
    • mcontroller.facingDirection() returns 1 when player is facing right and -1 if player is facing left
    • When facing right, the "primary" hand is in the back.
      When facing left, the "primary" hand is in the front.
      (Inverted for "alt" hand slot)
    • activeItem.setOutsideOfHand(true) -> render outside
      activeItem.setOutsideOfHand(false) -> render inside

    When facing "right" and the hand is "primary" the weapon should be rendered inside
    -> facingdirection = 1, primary = -1 -> 1 =/= -1 -> false
    When facing "left" and the hand is "primary" the weapon should be rendered outside
    -> facingdirection = -1, primary = -1 -> -1 == -1 -> true​

    In case this happens to do the opposite, just switch around the -1/1 in the code line.

    As for your weapon not rotation/firing, that always happens when there is an error within LUA. (In short, your weapon script crashed)

    Edit: removed mistake from the code line
     
    Last edited: Mar 3, 2023
  7. tGMP

    tGMP Void-Bound Voyager

    it remained unchanged, unfortunately. even after switching the positive and negative values
     
  8. Rezetrx

    Rezetrx Void-Bound Voyager

    My bad, remove the "or true" part at the end, that should do the trick.
     
  9. tGMP

    tGMP Void-Bound Voyager

    my friend, you have done it again. finally have an arm cannon with a properly returning boomerang projectile. greatly appreciated!
     
    Last edited: Mar 5, 2023

Share This Page