goatt Posted May 6, 2023 Share Posted May 6, 2023 I know you can use c_countprefab() in console. Can you also use it in mod file? What is "prefab" short for? Link to comment https://forums.kleientertainment.com/forums/topic/147640-how-to-count-the-number-of-an-item-in-the-world/ Share on other sites More sharing options...
_zwb Posted June 9, 2023 Share Posted June 9, 2023 Prefab is short for prefabricated. I think TheSim:FindEntities(...) might work for counting prefabs, butI'm not sure. I'll check it later. 1 Link to comment https://forums.kleientertainment.com/forums/topic/147640-how-to-count-the-number-of-an-item-in-the-world/#findComment-1640044 Share on other sites More sharing options...
_zwb Posted June 10, 2023 Share Posted June 10, 2023 Spoiler local function count_prefab(prefab) if not prefab then return end local count = 0 for _, v in pairs(GLOBAL.Ents) do if v.prefab == prefab then count= count+1 end end return count end This function should work for counting the number of prefabs. Note that if not used in modmain.lua then change GLOBAL.Ents to Ents. 1 Link to comment https://forums.kleientertainment.com/forums/topic/147640-how-to-count-the-number-of-an-item-in-the-world/#findComment-1640243 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