8/14/2023 0 Comments Neiblr work timer safe![]() Now, if I wanted to affect all the random floats in all my spell scripts at once, I could alter the function in the library, which all of those scripts are using, whereas, if each spell script had their own instance of the function, I’d have to open each spell script and put the edits to the function in one at a time. Like this RandomFloat function here I’m mostly using that for delays and ranges across spell scripts. The advantage of a script library is that you’ve only got a single instance of the function. If you’re going to be reusing the function across other scripts, it’d make sense to put it in a library, but if you’re only going to be using it within a single script, then keep it in that one. I’d love to get some how-to-write-optimally-clean-code tips, too.Įither is fine. That’d spare players the effort of clicking bushes that can’t currently be harvested.Ī “Can this code be optimized for cleanness and readability?”-topic where we post somewhat convoluted code and help one another minimize it actually sounds like a really great idea. In the case of usable objects like harvestable bushes, you could also temporarily set them unusable via SetUseableFlag. If the delayed command to remove a flag on a placeable is assigned to the player, and the player logs out before the timer is up, I think the flag might get stuck - whereas, if the flagged object no longer exists, it doesn’t matter that the flag on it doesn’t get removed. It’d be a good idea to assign the delayed command to remove the flag to the flagged object, in cases where the caller of the script is not (edit: corrected nonsense) the flagged object. In the case of the dead boss, I’ve personally done it the same way, just triggering a time-delayed respawn function rather than removing an integer. Random-float function, for getting a random time: // Returns a random float between fMin and fMax.įloat CBS_RandomFloat(float fMax=3.5, float fMin=0.0) įloat CBS_RandomFloat(float fMax=3.5, float fMin=0.0) Then, you can add an abort check based on the flag at the beginning of the script, aborting before anything happens: if (GetLocalInt(OBJECT_SELF, "RECENTLY_USED")) SetLocalInt(OBJECT_SELF, "RECENTLY_USED", 1) ĭela圜ommand(60.0, DeleteLocalInt(OBJECT_SELF, "RECENTLY_USED")) In examples 1 and 2, it’s as simple as flagging the bush/trigger, such as by setting an integer on them, and then randomly delaying the removal of the flag.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |