Math.round() won't help - call it on something which isn't a number, and it'll return NaN, which is exactly what you don't want. Decimal places aren't the problem anyway.
Code: Select all
parseInt(this.ec_contractactualprice + (this.ec_missionkills * this.ec_killsbonus))
would guarantee that the value was an integer, but it might still be integer NaN, so that doesn't necessarily help here (and shouldn't be necessary)
I suspect the problem is that while the mission is running,
ec_contractactualprice
is (supposed to be) a number, but the F4 mission screen puts an array into the same variable name. Similarly for
ec_killsbonus
. The result of doing this (two element ec_cap array, two element ec_kb array) is ...
is ... 287,211NaN.
I would advise rewriting the script a bit so that you use different
this.
variables on the F4 screen and for the in-mission parameters, and don't save them to the same mission variables either. The F4 screen is only saving to mission variables for string expansion when printed: you can use some temporary mission variables for that - or, better, use the option to pass a custom dictionary to
expandMissionText
and don't touch mission variables at all at that stage.
Having a variable that's sometimes a number and sometimes an array is going to cause problems. I suspect there's something going on with the array variable being saved to the mission variable in playerWillSaveGame (which converts it to a string) and then being read back as a string which can't properly be treated as a number, but it'll be easier to rename the variables than to try to debug that.