function disenchanter()
{
//Global variables
var ss = SpreadsheetApp.getActiveSpreadsheet(); //Declares Google Spreadsheets
var sheet = ss.getSheets()[0]; //Declares active sheets
var row = sheet.getRange(“C10:L32”).getLastRow(); //Declares the Materials Section
var COLUMNS = [3,4,5,6,7,8,9,10,11,12]; //donates the columns needed to be populated and used
var num = sheet.getRange(“B10”).getValue(); //grabs how many materials are going to be generated
var packs = sheet.getRange(“B6”).getValue()+10; //grabs how many cards are going to be broken down
for (var a = 0; a < 10; a++) //grabs availalbe Recipe Materials
{
COLUMNS[a] = sheet.getRange(2,a + 3).getValue();
}
for (var z = 0; z < 10; z++)
{
Logger.log(COLUMNS[z]);
}
for (var d = 10; d < packs; d++) //Begins adding materials to the Materials Section
{
for (var b = 0; b < num;)
{
var c = Math.floor(Math.random()*10)
var cell = sheet.getRange(d,c + 3).getValue();
if (COLUMNS[c] == “”)
{
sheet.getRange(d,c + 3).setValue(“”);
Logger.log(“I made it blank”) //Declares that a Materia was added
}
else if (COLUMNS[c] !== “” && typeof COLUMNS[c] === ‘string’ || COLUMNS[c] instanceof String)
{
if (cell < 1)
{
sheet.getRange(d,c + 3).setValue(1); //Adds a Materia to the Column
Logger.log(“I added one materia”) //Declares that a Materia was added
b++
}
else
{
Logger.log(“I did nothing here”) //Declares that a Materia was not added
}
}
else if (typeof COLUMNS[c] == ‘number’ && cell < COLUMNS[c])
{
sheet.getRange(d,c + 3).setValue(cell + 1); //Adds a component to the Column
Logger.log(“I added a component”) //Declares that a component was added
b++
}
else
{
Logger.log(“I did nothing here”) //Declares that a material was not added
}
}
}
}
function GetTheLastRow() //looks for the last row in the Materials Section on the Disenchanter Sheet
{
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
var num = sheet.getRange(“A10”).getValue();
Browser.msgBox(“amount is ” + num);
}