Code: Select all
var pid := CInt(GetObjProperty(mobile, "#TimerControlPID")); var process := GetProcess( pid );
pid is looking to grab a cprop off the character, "#TimerControlPID" and using the CInt function will return the integer value of that cprop. Then you have process, which uses the GetProcess function to grab a script process using the pid variable. Simple and should work 100% of the time and it does, except what I can only speculate as unforeseen consequences have arisen!
In the event that in this case GetObjProperty does not find the "#TimerControlPID" property on the mobile and because it has been wrapped in the loving arms of CInt, the variable pid becomes equal to 0. When this is then passed onto GetProcess because pid is equal to 0, the GetProcess function returns the process id of the currently running script instead of an error or some other such nonsense.
I have written to Dev via Discord with the problem and while I am not too certain if my solution would be feasible, because GetProcess' default parameter of pid is equal to 0, in cases such as I describe above (and this was not a lone isolated instance mind you) instead of being equal to 0, it be changed equal to -1. This is generally what I do if I have a function with a default value on a parameter and I know the parameter would never be lesser than 0 and unfortunately or fortunately with the way CInt works, a failed conversion of an object returns 0, this could be something worth doing since CInt would be a much more laborious, tedious function to "fix" to change it's behavior. I am also speculating that a process id would or should never be lesser than 0 so at any rate, I leave you with this tale of woe and something new for the POL-Boffins to fix.