fs2open.github.com icon indicating copy to clipboard operation
fs2open.github.com copied to clipboard

FR: Allow SEXPs to take floating point numbers

Open Kiloku opened this issue 3 years ago • 2 comments

"Number" SEXP parameters are actually "integer" parameters.

This means that there's an infinite amount of values that cannot be passed as parameters in SEXPs.

Introducing such a change would be an ∞% upgrade to FRED and FSO

Kiloku avatar Sep 14 '22 13:09 Kiloku

To be more serious, I have a real world scenario:

My Minimap script takes a "scale" value for the size of an object in the minimap. There's a noticeable difference between 1 and 2, for example. Since the script and its related dynamic SEXPs are already in use in a mod, I'd not like to make it 10x in the SEXP, or something like that, as the modder would need to update all of their missions for it.

Kiloku avatar Sep 14 '22 13:09 Kiloku

There's a reason floating-point support hasn't been added to the SEXP system by now: it's completely intractable. Updating the missions to use a SEXP that has a 10x, 100x, or 1000x multiplier would be by far the easier option. By at least two and possibly three orders of magnitude.

Merely allowing a floating point to be passed as a return value would require a fundamental redesign. You'd need to have either some sort of metadata associated with the node that could contain a float, or you would have to actually store the floating-point bytes in the integer bytes, and convert them on both input and output.

And then every single SEXP operator that uses a number would have to be made aware of this new potential data type and modified to accommodate it.

Goober5000 avatar Sep 14 '22 15:09 Goober5000