The template you mentioned is an include template. It's included in the createscript.lpt template (line 127). This means that the project object is available to you, as _currentProject.
In scope you have the project (as _currentProject) and the table (as table). What you need to obtain is all mappings which target the table. There's no public method to directly obtain this information, as everything is focused the other way around or internal.
You can obtain this information however, by obtaining the DatabaseMappingData object for the DriverId in the executingGenerator. Do this by using var databaseMappingData = _currentProject.MappingData.MappingDataPerDriverID.FindByKey( _executingGenerator.DriverID).FirstOrDefault();
If it returns a value, there are mappings for the driverid. You can assume this is the case. Then, in this object, simply do a linear search using a linq query:
var mappings = databaseMappingData.EntityMappings.Cast<GroupableModelElementMapping>().Where(m=>m.MappedTarget == table).Union(databaseMappingData.TypedViewMappings.Cast<GroupableModelElementMapping>().Where(m=>m.MappedTarget==table);
now you have the mappings for this table. You can then traverse the FieldMappings in this mapping to obtain all mapped fields, and thus skip ones which aren't mapped.
It is of course logical you should do this a bit more clever than I did above, i.e. cache the mappings perhaps in a dictionary so you don't have to traverse the mappings every time you handle a table, but perhaps it's quick enough for your project.