"Optional arguments are baked into the caller (they're not really optional once compiled) so if you add optional arguments to a function called by another script the game will complain until you've re-compiled the other script so the proper number of arguments are baked in."
Could you elaborate on this a bit more? I don't fully understand. Does this mean it is not possible with Papyrus to have a function with optional arguments if the function is called from another script (such as a dialog fragment)? Or are you trying to say that there is some way to do it?
The situation is that there are two mods (one of them is mine) that have modified the rentroomscript. My script adds one function--FreeRoom()--to the bottom of the script to avoid messing with the vanilla rentroom function but piggyback on certain other things (like knowing which bed to use, and already being attached to all the innkeeper actors). The freeroom() function is called from a dialog fragment, just like the rentroom() function.
The other mod makes more extensive changes to the rentroom script, and to the dialog fragment that calls the rentroom() function in the vanilla game. An easy way to make the two compatible would be to add my standalone function to that other script, recompile, and offer that as a patch to use both mods--and that works fine. But I prefer to handle compatibility behind the scenes like I do with other mods, so the separate patch bugs me.
It's easy enough to use getformfromfile() to check if the other mod is loaded. Then, within the various functions, I can go in one direction (vanilla) if the mod is not loaded and another direction if it is. The ONLY problem is that I cannot get one of the functions, the rentroom() function, to work because one of the changes the other mod makes is adding another parameter to the rentroom() function. I gave the second one a default value of 0, but when I test it, if I have the other mod installed (both variables are passed) everything works fine. Without the other mod installed, I get the Incorrect number of arguments passed error.
Also, the hello world function above is the actual function I am using to test. I don't know how to post a full script with the formatting and such.