Atena Posted March 3, 2015 Share Posted March 3, 2015 I try to write a mod let a player eat somthing increase speed temporarily. At time up, I want to reset the original speed of this player, How count I do? my code: this item. local function fn() ..... inst:AddComponent("edible") inst.components.edible.healthvalue = 0 inst.components.edible.hungervalue = 0 inst.components.edible.foodtype = "VEGGIE" inst.components.edible:SetOnEatenFn(oneaten) MakeHauntableLaunch(inst) return instendlocal function oneaten(inst, eater) if eater and eater.components.locomotor.runspeed < 20 then -- Speedup 30% eater.components.locomotor.runspeed = math.min(maxspeed, eater.components.locomotor.runspeed *1.3) eater:DoTaskInTime(100, normspeed) end endlocal function normspeed(eater) how to do? Reset eater's original speedend Thanks. Link to comment Share on other sites More sharing options...
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 account
Already have an account? Sign in here.Sign In Now