Hey Stwert, nice job for just beginning to figure out MEL!
Your script can be simplified a bit:
Code:
string $camera = "";
string $panel = `getPanel -wf`;
if (`getPanel -to $panel` == "modelPanel")
$camera = `modelEditor -q -camera $panel`;
int $isResGateEnabled = `camera -q -displayResolution $camera`;
float $ratio = 1.0;
if ($isResGateEnabled)
$ratio = 1.0;
else
$ratio = 1.3;
camera -e -displayResolution (!$isResGateEnabled) -overscan $ratio $camera;
Only little changes. One thing I did was changed the logic to determine if the resolution gate is shown. I saved it into an integer, as it only ever returns 0 or 1. Using that, below I used the logical not operator, "!", to invert this. (1 -> 0, 0 -> 1). So when it's false, we make it true, and vice-versa. I also broke up the ratio into it's own separate variable and if statement. This allows the user to quickly change it, and also minimizes the chances that they might break something. It also allows you to edit the camera once, instead of twice; allowing you to be able to change that code later, and only change it once.
Nice job
Imagination is more important than knowledge.