Yes you can certainly do that. You have to do bit of coding though. For that, you can either code in TCL (Tool Command Language) or C++. In any case, those parameters in your code that will be used in simulation scripts, you have to make associations of those variables with TCL in case you code in C++. The final simulation script in NS2 will always be in the Tool Command Language.