It returns true if it was day time, and false if it was night time. This function will enable every ObjectReference in an array if it is called at night time (anywhere between 10 PM and 6 AM), and disable all of the ObjectReferences in the array if it is called at day time (anywhere within the range of 6 AM-10 PM). (No, not getting if an actor is the player's lover, but a bool function like this is pretty common.) Now I'm going to give an example of a more complex function. This is a pretty common application of returning functions. The function IsActorCool will return true if the actor I'm calling it on is the player's lover, and false if they are not. This means that we called CountFunction with its parameter as 2."ĭebug.Notification("See how this could be useful? While it still processes the same amount of code, it's much cleaner.")ĭebug.Notification("I recommend putting functions at the bottom of your code. Don't use debugs in actual releases, use messages and message properties!"ĭebug.Notification("PrintWhat is 2. So if you wanted something different to be printed to the screen based on a variable, you could try something like this: Scriptname ThatBetterScript Extends Questįunction CountFunction(Int PrintWhat) parameters we can set so we can define what the function will doĭebug.Notification("PrintWhat is 1. However, you could use some parameters to make it more custom. The size of that is significantly reduced, as you can see. So instead of typing this needlessly long script: Scriptname ThatScript Extends Questĭebug.Notification("Don't use debugs in actual releases, use messages and message properties!"ĭebug.Notification("Be descriptive with names! This script has an awful name!")ĭebug.Notification("Other useful stuff.")
Well, the most basic of custom functions can be used to enclose certain bits of code that you use often in a script, so you can later call on them. So some of you might be wondering what the purpose of this is.