FelixTheJudge Posted May 25, 2016 Share Posted May 25, 2016 I know there is c_countprefabs("prefab") for server commands. But how would I in the middle of a function check how many of a prefab is in the world. I want to make sure only 1 of a custom mob exists in the world at a time. Or at least 1 per spawn statue that summons them. I don't want the players to walk up to a pile of clock queens chilling out. Link to comment Share on other sites More sharing options...
DarkXero Posted May 25, 2016 Share Posted May 25, 2016 c_countprefabs is a global function. It prints the count of the prefab you specify, and it also returns the count number of such prefab. You can call it in the middle of a function to use it. Link to comment Share on other sites More sharing options...
Maris Posted May 25, 2016 Share Posted May 25, 2016 local SPAWN_COUNTER = 0 AddPrefabPostInit("mobprefab",function(inst) SPAWN_COUNTER = SPAWN_COUNTER + 1 inst:ListenForEvent("onremove", function(inst) SPAWN_COUNTER = SPAWN_COUNTER - 1 end) end) Link to comment Share on other sites More sharing options...
FelixTheJudge Posted May 26, 2016 Author Share Posted May 26, 2016 Thank you guys for your quick reply. This will be useful later, but for now I found a different method of spawning for the custom entity. <3 Always so helpful though. Link to comment 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