Berwin Posted November 17, 2017 Share Posted November 17, 2017 Hi I'm having problems with this script I'm trying to make. I want it to do the following. When you pick up an object either normal loot or the big carrying items, and it's not a normal perishing item, I want a tag put onto the inventory item so that when it's dropped it becomes perishable. Then if items with this tag are picked up, the perishing stops and becomes a regular non-perishing item again. I can't seem to get my head round this. The 60 seconds was just for testing purposes. Second part, I would like to add just the perishable part to structures built. local old_action_drop = GLOBAL.ACTIONS.DROP.fn GLOBAL.ACTIONS.DROP.fn = function(act) if act.doer ~= nil and act.doer:HasTag("player") then if act.invobject and act.invobject.components.perishable == nil then act.invobject:AddComponent("perishable") act.invobject.components.perishable:SetPerishTime(60) act.invobject.components.perishable:StartPerishing() act.invobject.components.perishable.onperishreplacement = "ash" act.invobject:AddTag("natural") end end return old_action_drop(act) end local old_action_drop_strfn = GLOBAL.ACTIONS.DROP.strfn GLOBAL.ACTIONS.DROP.strfn = function(act) if act.doer ~= nil and act.doer:HasTag("player") then if act.invobject and act.invobject.components.perishable == nil then act.invobject:AddComponent("perishable") act.invobject.components.perishable:SetPerishTime(60) act.invobject.components.perishable:StartPerishing() act.invobject.components.perishable.onperishreplacement = "ash" act.invobject:AddTag("natural") end end return old_action_drop_strfn(act) end local old_action_pickup = GLOBAL.ACTIONS.PICKUP.fn GLOBAL.ACTIONS.PICKUP.fn = function(act) if act.doer ~= nil and act.doer:HasTag("player") then if act.invobject and act.invobject:HasTag("natural") then act.invobject.components.perishable:StopPerishing() act.invobject:RemoveComponent("perishable") end end return old_action_pickup(act) end local old_action_pickup_strfn = GLOBAL.ACTIONS.PICKUP.strfn GLOBAL.ACTIONS.PICKUP.strfn = function(act) if act.doer ~= nil and act.doer:HasTag("player") then if act.invobject and act.invobject:HasTag("natural") then act.invobject.components.perishable:StopPerishing() act.invobject:RemoveComponent("perishable") end end return old_action_pickup_strfn(act) end Link to comment https://forums.kleientertainment.com/forums/topic/84346-help-needed-to-fix-perishing-script/ 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