Hscript Output Even Only

   3185   2   0
User Avatar
Member
44 posts
Joined: 4月 2017
Offline
Made my first hscript which only allows parameter output of even numbers and just wanted to share it in case anyone else could use it.

if ((($OV + 1) % 2), $OV, $OV+1)

Used it to control the number of sides on a gear HDA so the spokes would always have a gap between them. Not super useful but a fun challenge for my first hscript and adds a bit of user friendliness.

Can it be optimized? Would it be better to write it in VEX or Python maybe?
Image Not Found

Attachments:
hscript_even_only.hipnc (67.4 KB)

User Avatar
Member
38 posts
Joined: 7月 2019
Offline
Well if you change it to:
if(($OV%2), $OV + 1, $OV)
that would be one calculation fewer I suppose.
I wouldn't worry about efficiency for such simple things; Python is not as quick as Vex but it can allow you to do things Vex can't do (File IO, creation of nodes, starting sub processes, &c.), and only when you are doing things multiple times over would you worry about such things.
User Avatar
Member
8532 posts
Joined: 7月 2007
Online
safer would be something like this
rint($OV*.5)*2
especially if you allow float numbers as your input
Tomas Slancik
FX Supervisor
Method Studios, NY
  • Quick Links