Scrimbles Posted August 13, 2019 Share Posted August 13, 2019 (edited) I want to accomplish something to the effect of: if TheWorld.entityexists("toadstool") then stuff else stuff end Is there any line that would detect this both above and underground? Edited August 13, 2019 by Ogrecakes Link to comment Share on other sites More sharing options...
Thomas Die Posted August 13, 2019 Share Posted August 13, 2019 i'm pretty sure there's an command which sees how many this could still work Link to comment Share on other sites More sharing options...
Ultroman Posted August 13, 2019 Share Posted August 13, 2019 (edited) I think this'll work. if c_countprefabs("prefab") > 0 then Edited August 13, 2019 by Ultroman Link to comment Share on other sites More sharing options...
Scrimbles Posted August 14, 2019 Author Share Posted August 14, 2019 (edited) 18 hours ago, Ultroman said: I think this'll work. if c_countprefabs("prefab") > 0 then I think it MOSTLY works, but it needs to constantly be updating the number. Currently, if the world is loaded and that prefab does NOT exist, the prefab count will be 0, regardless of if it spawns in later. If the world is loaded WITH that prefab, the prefab counter will be > 0, regardless of if the prefab ceases to exist. I probably have to create some timed task to keep on checking the prefab count... I vaguely have an idea of how that would be done, but not exactly. Edited August 14, 2019 by Ogrecakes Link to comment Share on other sites More sharing options...
Ultroman Posted August 14, 2019 Share Posted August 14, 2019 You need some instance to start a task on. If it's a world-thing, you can just do: GLOBAL.TheWorld:DoPeriodicTask(5.0, function(inst) if c_countprefabs("prefab") > 0 then -- react to there being one end end) If it's something specific to a character, you should start the task on the character instance instead. 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