Ships with Ramscoop gather up thin intersteller matter during movement, and convert that into fuel. This fuel is available after movement. It can not be used for movement. If the ship hits a web mine, it will first lose fuel to the webs, and then receive its ramscoop fuel (i.e. it will end the turn with fuel, even if the webs sucked it dry before).

Fuel_made_by_ramscoop =
   Trunc(RamScoopFuelPerLY
         * (Distance_moved_uncloaked + 0.5*Distance_moved_cloaked))

A ship can move a part of its journey cloaked and another part uncloaked if it hits a mine that brings it above the DamageLevelForCloakFail limit.

Only regular movement produces fuel. Hyperjumping, chunneling, and all movement not produced by the ship's engines (i.e. being towed, ion storm, etc.) do not cause fuel to be made. The ship can, however, tow another ship or intercept a ship. Reportedly, ships do not make fuel while intercepting in some HOST versions; hence in PHost up to 4.0e, they don't make fuel either. In current versions, this restriction no longer exists.