1. Hi, I'm working on a private plugin and want to drop a spawned item on the ground. I create the item and can move it to a container but can't seem to get the dropping to work. I use item: Drop(player.transform.posistion, velocity) I'm having a problem getting the velocity in lua. Any ideas? Thanks!
     
    Last edited by a moderator: Oct 19, 2016
  2. Does player.GetDropVelocity() not exist/work in LUA?
     
  3. Thanks for the suggestion. I do get error - getdropvelocity requires a non null object. Player is not null.
     
  4. Wulf

    Wulf Community Admin

    player:GetDropVelocity()
     
  5. Thanks, originally tried that too only to get - failed to convert parameters. Is the problem with the first parameter?
     
  6. Wulf

    Wulf Community Admin

    I'd need to see the full error.
     
  7. Sure, this is the error using - item : Drop(player.transform.position, player:GetDropVelocity())

    Code:
    File: drop.lua Line: 43 failed to convert parameters:
      at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invoke
    Attr, System.Reflection.Binder binder, System.Object[] parameters, System.Global
    ization.CultureInfo culture) [0x00000] in <filename unknown>:0
      at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] par
    ameters) [0x00000] in <filename unknown>:0
      at NLua.Method.LuaMethodWrapper.Call (LuaState luaState) [0x00000] in <filenam
     
  8. Wulf

    Wulf Community Admin

    What is on line 43?

    I'd try printing each argument out.
     
  9. The drop line posted above is 43 right under when the item is created.
     
  10. Wulf

    Wulf Community Admin

    Did you try printing them individually to see what they return?
     
  11. Sorry, missed that.

    player.transform.position returns (-320.1, 0.7, 263.3)
    player : GetDropVelocity returns (-1.7, -3.8, 0.2)
     
  12. Wulf

    Wulf Community Admin

    Do you have spaces between item and Drop like your example has?
     
  13. No did that to prevent emoticons.
     
  14. Wulf

    Wulf Community Admin

    Ahh, I see the issue... Because you are using Lua, you'd need to give the 3rd argument too. You should be able to pull nil for it though.
     
  15. Thanks. Do you mean item : Drop(player.transform.position, player:GetDropVelocity(), nil). With that I get line 43 invalid arguments to method: Item.Drop
     
  16. Wulf

    Wulf Community Admin

    Yeah, that should be it. Maybe try setting a zero vector for the third?
     
  17. Same error with 0 and everything else I have tried so far.
     
  18. Have you tried to just use the player's rotation as 3rd argument?
    Code:
    item:Drop(player:GetDropPosition(), player:GetDropVelocity(), player.transform.rotation)
     
  19. That worked perfectly. Thanks for the help wulf and mughisi.