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!
Solved Dropping spawned item on ground? (Lua)
Discussion in 'Rust Development' started by goldy2451, Oct 19, 2016.
-
Does player.GetDropVelocity() not exist/work in LUA?
-
Thanks for the suggestion. I do get error - getdropvelocity requires a non null object. Player is not null.
-
Wulf Community Admin
player:GetDropVelocity() -
Thanks, originally tried that too only to get - failed to convert parameters. Is the problem with the first parameter?
-
Wulf Community Admin
I'd need to see the full error. -
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
-
Wulf Community Admin
What is on line 43?
I'd try printing each argument out. -
The drop line posted above is 43 right under when the item is created.
-
Wulf Community Admin
Did you try printing them individually to see what they return? -
Sorry, missed that.
player.transform.position returns (-320.1, 0.7, 263.3)
player : GetDropVelocity returns (-1.7, -3.8, 0.2) -
Wulf Community Admin
Do you have spaces between item and Drop like your example has? -
No did that to prevent emoticons.
-
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.
-
Thanks. Do you mean item : Drop(player.transform.position, player:GetDropVelocity(), nil). With that I get line 43 invalid arguments to method: Item.Drop
-
Wulf Community Admin
Yeah, that should be it. Maybe try setting a zero vector for the third? -
Same error with 0 and everything else I have tried so far.
-
Have you tried to just use the player's rotation as 3rd argument?
Code:item:Drop(player:GetDropPosition(), player:GetDropVelocity(), player.transform.rotation)
-
That worked perfectly. Thanks for the help wulf and mughisi.
