Hello, just trying to learn more about the api.
As of now I'm working on a simple cannon script but I don't know the best way to go about fixing the cannon incase it breaks. The cannon goes from "Dwarf multicannon" to "Broken multicannon" and I don't know how to interact with the Broken multicannon optimally.
I declare the working cannon as cannon = getObjects().closest("Dwarf multicannon")
But this only works assuming the working cannon does actually exist. If it doesn't exist, the script crashes.
So, for example, if I'm trying to check if the Broken multicannon exists, I can't use getObjects().closest("Broken multicannon") in anyway else bad stuff goes down.
So, my question is, is there a safer way of checking if something exists without everything breaking if it does not?
Thank you for your time.