Jump to content

Recommended Posts

Hello, I need help if someone could help me with this it really would be so gracious & amazing of you :D!

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 :lol:...

 

Edited by SuperDavid

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.

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 :(...

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

 

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 by SuperDavid
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

 

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

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...