Sir_Kasalott Posted October 9, 2017 Share Posted October 9, 2017 Hey I'm trying to make a Char that can only hold one item. Right now I'm testing it out with an axe, but I don't know how to do it. Can someone please tell me what I'm doing wrong? -- Drop Items local function drop(inst) local hand = inst.components.inventory:GetEquippedItem(EQUIPSLOTS.HANDS) if hand ~= "axe" then inst:DoTaskInTime(0.0, function() local item = inst.components.inventory:Unequip(EQUIPSLOTS.HANDS) inst.components.inventory:DropItem(item) inst.components.talker:Say(GetString(inst, "ANNOUNCE_UNEQUIP_TOOL")) inst.AnimState:ClearOverrideSymbol("swap_object") end) end I know that this part is wrong, I just guessed what goes there. if hand ~= "axe" then Link to comment Share on other sites More sharing options...
w00tyd00d Posted October 9, 2017 Share Posted October 9, 2017 What you'll want to do (if it's going to be a DST exclusive mode) is change the "hand" variable to this instead: local hand = inst.replica.inventory:GetEquippedItem(EQUIPSLOTS.HANDS) because "replica" is essentially a wrapper component that returns the "component" information if the player is the host or the "classified" information if the player is a client But to solve the problem you're having, that function gets the entity of the item in your hand, but you want to check specifically what prefab it is which is a value in the entity's table. So just change the check to this and it should identify it properly: if hand.prefab ~= "axe" then Hope this helps Link to comment Share on other sites More sharing options...
w00tyd00d Posted October 9, 2017 Share Posted October 9, 2017 It's only important to replace the "component" to "replica" when it comes to checking the data in the inventory component, so with the actual command to do whatever you want to do you can just use "inst.components.inventory" and the game will automatically do what it has to do to apply it to clients. Also you will need to either need to call "EQUIPSLOTS" from the global table in your function there or write a local variable referring to the global table, like this: local EQUIPSLOTS = GLOBAL.EQUIPSLOTS Link to comment Share on other sites More sharing options...
Sir_Kasalott Posted October 9, 2017 Author Share Posted October 9, 2017 (edited) Thank you so much w00tyd00d, I haven't tried it yet. but I'll let you know how it goes. EDIT: OMG it works perfectly, it's exactly how I wanted it. Thank you so so soo much! Edited October 10, 2017 by Sir_Kasalott Link to comment Share on other sites More sharing options...
Seilakk Posted October 11, 2017 Share Posted October 11, 2017 On 09/10/2017 at 3:29 PM, w00tyd00d said: Also you will need to either need to call "EQUIPSLOTS" from the global table in your function there or write a local variable referring to the global table, like this: where should i place this part? Link to comment Share on other sites More sharing options...
w00tyd00d Posted October 12, 2017 Share Posted October 12, 2017 16 hours ago, Seilakk said: where should i place this part? Usually it's good to declare it at the top of your modmain since it must be declared before anything else that uses it in your modmain. Same rule applies for any variable that's local to a script. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now