Return type mismatch with String [ZScript]

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Post Reply
User avatar
SPZ1
Posts: 388
Joined: Wed Aug 02, 2017 3:01 pm
Location: Illinois
Contact:

Return type mismatch with String [ZScript]

Post 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"; } }
User avatar
22alpha22
Posts: 308
Joined: Fri Feb 21, 2014 5:04 pm
Graphics Processor: nVidia with Vulkan support
Location: Montana, USA

Re: Return type mismatch with String [ZScript]

Post 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 "".
User avatar
SPZ1
Posts: 388
Joined: Wed Aug 02, 2017 3:01 pm
Location: Illinois
Contact:

Re: Return type mismatch with String [ZScript]

Post by SPZ1 »

Thank you for the tip! All is working now. :)
Post Reply

Return to “Scripting”