icantevenname Posted June 24, 2020 Share Posted June 24, 2020 I want to make a weapon that is only usable by characters with certain tags (like how only Woody can pick up Lucy) and regains a "use" of durability after a certain amount of time. I'm sure I can do everything else on my own. I just need to figure those two things out. Link to comment Share on other sites More sharing options...
Thomas Die Posted June 30, 2020 Share Posted June 30, 2020 inst:ListenForEvent("onputininventory", function(inst, owner) inst:DoTaskInTime(0, function(inst, owner) if owner.components.inventory ~= nil and not owner:HasTag("The_Tag") then owner.components.inventory:DropItem(inst, true, true) end end, owner) if owner.components.talker then owner.components.talker:Say(GetActionFailString(owner, "PICKUP")) end end) Go crazy, also this code is from zarklard. Also if this crashed message me Link to comment Share on other sites More sharing options...
icantevenname Posted July 3, 2020 Author Share Posted July 3, 2020 On 6/30/2020 at 3:13 PM, thomas4846 said: inst:ListenForEvent("onputininventory", function(inst, owner) inst:DoTaskInTime(0, function(inst, owner) if owner.components.inventory ~= nil and not owner:HasTag("The_Tag") then owner.components.inventory:DropItem(inst, true, true) end end, owner) if owner.components.talker then owner.components.talker:Say(GetActionFailString(owner, "PICKUP")) end end) Go crazy, also this code is from zarklard. Also if this crashed message me It didn't crash, but there's two hitches, one of which is my own fault. Characters without the tag needed say they can't pick up the weapon and don't, but characters with the tag can pick it up, yet say they can't. When the weapon runs out of uses and isn't told to remove itself, I thought it wouldn't be usable. I was wrong, the numbers dip into the negatives and I keep swinging it like nothing's wrong. Link to comment Share on other sites More sharing options...
Thomas Die Posted July 3, 2020 Share Posted July 3, 2020 inst:ListenForEvent("onputininventory", function(inst, owner) inst:DoTaskInTime(0, function(inst, owner) if owner.components.inventory ~= nil and not owner:HasTag("The_Tag") then owner.components.inventory:DropItem(inst, true, true) if owner.components.talker then owner.components.talker:Say(GetActionFailString(owner, "PICKUP"))--I'm not sure about them not saying it ---inst.component.talker:Say("i can't pick that up") end end end, owner) end) -----And for the finite uses inst:AddComponent("finiteuses") inst.components.finiteuses:SetOnFinished(inst.Remove) Link to comment Share on other sites More sharing options...
icantevenname Posted July 4, 2020 Author Share Posted July 4, 2020 50 minutes ago, thomas4846 said: And for the finite uses inst:AddComponent("finiteuses") inst.components.finiteuses:SetOnFinished(inst.Remove) I don't want it to be removed. Link to comment Share on other sites More sharing options...
Thomas Die Posted July 4, 2020 Share Posted July 4, 2020 local function NoUse (inst) inst:RemoveComponent("equippable") end inst.components.finiteuses:SetOnFinished(NoUse) maybe this then or if something goes wrong use local function onequip(inst, owner) if inst:HasTag("no_uses") then inst.components.equippable:Unequip(owner) end end inst.components.finiteuses:SetOnFinished(inst:AddTag("no_uses")) This is very basic sorry Link to comment Share on other sites More sharing options...
icantevenname Posted July 4, 2020 Author Share Posted July 4, 2020 13 minutes ago, thomas4846 said: local function NoUse (inst) inst:RemoveComponent("equippable") end inst.components.finiteuses:SetOnFinished(NoUse) maybe this then I changed it to remove the Weapon tag instead, removing Equippable still made it useable until unequipped, but since I want the weapon to regain uses, it'd be pointless if it doesn't regain the Weapon tag. 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