Blockland Forums > Modification Help
Checking if an object is a vehicle
Unicide:
How do I check if an object is a vehicle? I want to check if the object a projectile has hit is a vehicle but I'm not sure how.
otto-san:
if(%obj.getClassName() $= "WheeledVehicle")
Unicide:
Thanks! One more thing - how would I check if a variable exists within the WheeledVehicleData block and if it does, retrieve it? It wouldn't just be col.<variablename>, would it?
Superb:
--- Quote from: Unicide on December 06, 2011, 04:17:49 PM ---Thanks! One more thing - how would I check if a variable exists within the WheeledVehicleData block and if it does, retrieve it? It wouldn't just be col.<variablename>, would it?
--- End quote ---
Should be %variable = %col.getDatablock().somevariable;
Amade:
--- Quote from: otto-san on December 06, 2011, 04:15:03 PM ---if(%obj.getClassName() $= "WheeledVehicle")
--- End quote ---
If you wanted to check if it was any vehicle - not just a wheeled one - you would use if(%col.getType() & $Typemasks::VehicleObjectType)