I designed a parametric hinged box because I couldn't find one that maintained integrity when parameters were adjusted. This model includes a latch for convenient locking, which you can toggle on or off. Additionally, you have the option to add text on the lid. For multicolor prints, you can switch to a secondary model that includes only the text object.
If one of the assertions fails, it indicates that an invalid parameter combination was attempted.
Please let me know if you can apply a set of parameters that results in a broken model.
It uses the Belfry OpenScad Library v2 (BOSL2), check this link for download and install instructions:
https://github.com/BelfrySCAD/BOSL2?tab=readme-ov-file#installation