Jump to content

Recommended Posts

Hi, I hope this is the right place where put this question

Anyway, I want to write a simple mod to display on screen the number of merm guards and the number of merm guards loyal

For the first set I saw I can use in the console the command 

c_announce(c_countprefabs("mermguard"))

but this is only the total number of the merms. How to get the number of the ones loyal to wurt?

Thanks in advance

For console, you can try ThePlayer.components.leader:CountFollowers(tag) to count the number of entities that are loyal to you and has the specified tag.

ThePlayer.components.leader:CountFollowers("mermguard") will count merm guards (and only guards) on you.

If you're in your modding environment, replace ThePlayer with, well, something that represents your player character's instance.

Thanks, I've tried with console the command

ThePlayer.components.leader:CountFollowers("mermguard")

but nothing is displayed, any idea?

Thanks

P.S.

I've tried the following command

ThePlayer.components.inventory:DropEverything()

and it's work, I presume "ThePlayer" is the correct object that represent my character

Edited by yeastwecan

The function itself "returns" a number value of how many followers you have on you; without a way of displaying that value, you'd think nothing happened.

In the console, try: 

c_announce(ThePlayer.components.leader:CountFollowers("mermguard"))

And your result should show in chat as a server announcement.

Hi, sorry if I bother you again but I want to improve my mod and I need an hint

In caves, in particular, Wurt have the bad habit to loose his mermguard when they loose the loyalty. I want to implement a button to move all the "not loyal" merms near the ThePlayer

I know there is the command like

c_move(c_find('something'))

but how to enumerate all the mermguards and iterate the move command? If is a silly idea, can you suggest me a way to regroup all the guards?

Thanks in advance

@yeastwecan

I think you can possibly try to do a for loop iterating over every follower you have on you using the same Leader component.

The component also has followers as a table (inst.components.followers) and there is also a function you can use to get followers of a specific tag, very similar to how CountFollowers work above.

You can try:

for k, v in pairs(yourinstance.components.leader:GetFollowersByTag(tag)) do
	local x, y, z = yourinstance.Transform:GetWorldPosition()
	k.Transform:SetPosition(x, y, z)
end

GetFollowersByTag returns a table. GetWorldPosition returns 3 values, x y z, for your merms to teleport to you with. SetPosition is self-explanatory.
This has not been tested. If issues occur, you could possibly switch around k or v in the for loop.

Thanks for the reply but I need to iterate with mermguards that not following me (if I well understood you code)

The problem is, during the wurt exploration some mermguards loose the loyal status and sometime they are stuck somewhere and the player dont know where they are to regain the loyalty. I wish to bring the "no more loyal" near ThePlayer to feed them.

Thanks in advance

You may have to try TheSim:FindEntities() in this case.
 

local ents = TheSim:FindEntities(x, y, z, RANGE, {MUST_TAGS})

for k, v in ipairs(ents) do
  	if v.components.follower and v.components.follower:GetLeader() == nil then
		--Put teleport codes here
	end
end

x, y, z should be your GetWorldPosition's coords.
RANGE is how big the search range is for entities that has MUST_TAGS within your current position. Is also an integer.
MUST_TAGS is a table. Put tags in there to make the function include entities with that tag in the search. (e.g. {"mermguard"})

In this one, I use the merm guards' follower component to find a leader; if they don't already have a leader (nil), then they should teleport to you.
(This also means if a merm guard is already loyal to someone else, they won't be teleported.)

Edited by Baguettes

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