let player = pn != -1 ? players[pn] : players[consoleplayer];
let mo = player.mo;
// the below works, the above gives a script error
//let mo = pn != -1 ? players[pn].mo : players[consoleplayer].mo;
//let player = mo.player;
See zscript.zsc, line 17
You do not have the required permissions to view the files attached to this post.
The 'issue' is that 'players' is an array of structs and the ternary operator cannot deal with non-scalars. In this particular case the internal conversion to a pointer type occurs too late. Sadly this is not something easily fixed with how the entire system works.
Damn. Then you have to give it an explicit type (i.e. replace 'let' with 'PlayerInfo'. There's a few issues in the entire system with global instance variables of native struct types because to the compiler their type is ambiguous.
I wish this had gone differently but when discussing these issues with Randi nothing came out of it. The mere idea of types that can both be used by value and by reference never was part of ZScript's design, although a necessity, so it led to some not so nice problems.