yeastwecan Posted September 25, 2024 Share Posted September 25, 2024 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 Link to comment https://forums.kleientertainment.com/forums/topic/159944-counting-loyal-merm-guards/ Share on other sites More sharing options...
Baguettes Posted September 25, 2024 Share Posted September 25, 2024 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. Link to comment https://forums.kleientertainment.com/forums/topic/159944-counting-loyal-merm-guards/#findComment-1750742 Share on other sites More sharing options...
yeastwecan Posted September 26, 2024 Author Share Posted September 26, 2024 (edited) 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 September 26, 2024 by yeastwecan Link to comment https://forums.kleientertainment.com/forums/topic/159944-counting-loyal-merm-guards/#findComment-1750817 Share on other sites More sharing options...
Baguettes Posted September 27, 2024 Share Posted September 27, 2024 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. Link to comment https://forums.kleientertainment.com/forums/topic/159944-counting-loyal-merm-guards/#findComment-1750942 Share on other sites More sharing options...
yeastwecan Posted September 27, 2024 Author Share Posted September 27, 2024 Works like a charm, thanks Link to comment https://forums.kleientertainment.com/forums/topic/159944-counting-loyal-merm-guards/#findComment-1750950 Share on other sites More sharing options...
yeastwecan Posted October 26, 2024 Author Share Posted October 26, 2024 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 Link to comment https://forums.kleientertainment.com/forums/topic/159944-counting-loyal-merm-guards/#findComment-1754728 Share on other sites More sharing options...
Baguettes Posted October 26, 2024 Share Posted October 26, 2024 @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. Link to comment https://forums.kleientertainment.com/forums/topic/159944-counting-loyal-merm-guards/#findComment-1754731 Share on other sites More sharing options...
yeastwecan Posted October 26, 2024 Author Share Posted October 26, 2024 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 Link to comment https://forums.kleientertainment.com/forums/topic/159944-counting-loyal-merm-guards/#findComment-1754750 Share on other sites More sharing options...
Baguettes Posted October 26, 2024 Share Posted October 26, 2024 (edited) 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 October 26, 2024 by Baguettes Link to comment https://forums.kleientertainment.com/forums/topic/159944-counting-loyal-merm-guards/#findComment-1754769 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