. . . Posted September 19, 2016 Share Posted September 19, 2016 (edited) Hello, I need help if someone could help me with this it really would be so gracious & amazing of you ! So, what I want is I want my entity to get a 25% external speed boost when his leader has the tag "perfect" & his leader has "inst.flawless_mode == true", does anyone know how I would do that for my entity by putting something in its entity.lua? PS. If someone wants to help me & want a event to trigger this the event that triggers this could be hungerdelta then it keeps always updates what the entity's speed should be since I wanna do lots more speeds thingies for my entity but I don't know how to start ... Edited September 21, 2016 by SuperDavid Link to comment https://forums.kleientertainment.com/forums/topic/70251-solved-how-to-make-something-happen-for-entity-when-something-happens-to-entity-leader/ Share on other sites More sharing options...
Aquaterion Posted September 19, 2016 Share Posted September 19, 2016 well if this tag comes and goes, then you find where you add the tag "perfect", and below it just add the code to find the followers and boost them. Same for removing the boost. Link to comment https://forums.kleientertainment.com/forums/topic/70251-solved-how-to-make-something-happen-for-entity-when-something-happens-to-entity-leader/#findComment-815575 Share on other sites More sharing options...
. . . Posted September 19, 2016 Author Share Posted September 19, 2016 4 hours ago, Aquaterion said: add the code to find the followers and boost them. Same for removing the boost. The problem is I don't know the code to call the followers or the leader ... Link to comment https://forums.kleientertainment.com/forums/topic/70251-solved-how-to-make-something-happen-for-entity-when-something-happens-to-entity-leader/#findComment-815635 Share on other sites More sharing options...
Aquaterion Posted September 19, 2016 Share Posted September 19, 2016 1 hour ago, SuperDavid said: The problem is I don't know the code to call the followers or the leader ... --apparently its something like this for k,v in pairs(inst.components.leader.followers) do if k and k.components and k.components.locomotor then k.components.locomotor.???? --i forgot how to do speed boosts end end Link to comment https://forums.kleientertainment.com/forums/topic/70251-solved-how-to-make-something-happen-for-entity-when-something-happens-to-entity-leader/#findComment-815658 Share on other sites More sharing options...
. . . Posted September 19, 2016 Author Share Posted September 19, 2016 (edited) Well I did something like this inst:ListenForEvent("attacked", function(inst, data) for k,v in pairs(inst.components.leader.followers) do if k and k.components and k.components.locomotor then k.components.locomotor.runspeed = 32 k.components.locomotor.walkspeed = 32 end end inst.components.talker:Say("I don't feel so good...") end) And it crashes saying "attempt to index field 'leader' (a nil value)" and I don't know what to do Also, what does k & v stand for? Is k the entity & v the leader? Sorry for being a bother ... Edited September 19, 2016 by SuperDavid Link to comment https://forums.kleientertainment.com/forums/topic/70251-solved-how-to-make-something-happen-for-entity-when-something-happens-to-entity-leader/#findComment-815708 Share on other sites More sharing options...
. . . Posted September 21, 2016 Author Share Posted September 21, 2016 Does nobody know how I could do this ...? Link to comment https://forums.kleientertainment.com/forums/topic/70251-solved-how-to-make-something-happen-for-entity-when-something-happens-to-entity-leader/#findComment-816244 Share on other sites More sharing options...
DarkXero Posted September 21, 2016 Share Posted September 21, 2016 local function UpdateLocomotor(inst) local leader = inst.components.follower.leader if leader and leader:HasTag("perfect") and leader.flawless_mode == true then inst.components.locomotor:SetExternalSpeedMultiplier(inst, "flawless_leader", 1.25) else inst.components.locomotor:RemoveExternalSpeedMultiplier(inst, "flawless_leader") end end local function fn() -- etc. inst.entity:SetPristine() if not TheWorld.ismastersim then return inst end -- etc. inst:AddComponent("locomotor") inst:AddComponent("follower") inst:DoPeriodicTask(2, UpdateLocomotor) return inst end Link to comment https://forums.kleientertainment.com/forums/topic/70251-solved-how-to-make-something-happen-for-entity-when-something-happens-to-entity-leader/#findComment-816249 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