C# variant (universal)
public int craft(string profession, string matherial) {
SpellManager.CastSpellByNameLUA(profession);
Lua.LuaDoString("CloseTradeSkill()");
string command = String.Format(
"toCraft=0 local q,n,_,a=\"{0}\" "+
"for i=1,GetNumTradeSkills() do n,_,a=GetTradeSkillInfo(i) if(n==q) then toCraft=a DoTradeSkill(i,a) break end end",
matherial);
int result = Lua.LuaDoString<int>(command,"toCraft");
return result;
}