Optotriac+triac: how do I calculate the gate resistor
The 180&Omega; resistor will probably need to be altered for 12VAC, what value it needs to be depends on the minimum trigger/latching current needed for the main triac. Also, a 0.25W resistor is only suitable if the wattage doesn't exceed 0.25W, so you need to calculate max voltage across it times current through it.

This Fairchild app note is worth a read for deciding on the values of components to use. 

For a resistive load the circuit shown below:



The relevant part of this note with the formulas is:

Triac Driving Requirements  

Figure 2 shows a simple triac driving circuit using the 
MOC3011M. The maximum surge current rating of the MOC3011M sets the minimum value of R1 through the equation:  

R1 (min) = Vin(pk)/1.2A  

If we are operating on the 115 Vac nominal line voltage, Vin (pk) = 180 V, then:
R1(min) = Vin(pk)/1.2A = 150 ohms.
In practice, this would be a 150 or 180 ohm resistor. 

If the triac has IGT = 100 mA and VGT = 2 V, then the voltage Vin necessary to trigger the triac will be given by:
VinT = R1 * IGT + VGT + VTM = 20 V.