Page 1 of 1

Return type mismatch with String [ZScript]

Posted: Wed Oct 11, 2023 10:47 am
by SPZ1
Can somebody tell me why this code will not run?

String SPZ_GetWeaponString(weapon paramWeapon){ if (paramWeapon is "ColdFlame_Sword"){ return "\cgCold\ctFlame \chSword"; } else if (paramWeapon is "ExorSword"){ return "\cgE\cmx\cgo\cmr \ccSword"; } else if (paramWeapon is "IceyStaff"){ return "\cnIcey Staff"; } else if (paramWeapon is "FireyStaff"){ return "\cgFirey Staff"; } else if (paramWeapon is "Cerebral_Displacer_Staff"){ return "\ceCerebral Displacer"; } else if (paramWeapon is "Lightning_Staff"){ return "\ckLightning Staff"; } }

Re: Return type mismatch with String [ZScript]

Posted: Wed Oct 11, 2023 11:14 am
by 22alpha22
You don't have a return value outside of your if and else if statements, meaning that if all the if and else if statements failed, there wouldn't be anything for the function to return. You just need to add a return outside of your if and else if statements. It can be a simple empty string like return "".

Re: Return type mismatch with String [ZScript]

Posted: Wed Oct 11, 2023 11:33 am
by SPZ1
Thank you for the tip! All is working now. :)