Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * @OnlyCurrentDoc
- */
- function exportToAvrae() {
- var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
- var locations = {
- "Weapons": {
- "Rows": [3, 1034],
- "Columns": [0, 12],
- "Title": 0, // Name
- "Body": {
- "Base": {
- "Unique": 12,
- "Class": 1,
- "Cost": 11,
- },
- "Meta": {
- "Crit Range": 2,
- "Multiplier": 3,
- "Attack Modifier": {
- "Melee": 4,
- "Range": 5,
- },
- "Damage Roll": {
- "Melee": 6,
- "Range": 7,
- },
- "Max Range": 8,
- "Attachments": 9,
- },
- },
- "Description": 10, // Function
- },
- "Light Houses": {
- "Rows": [2, 1005],
- "Columns": [0, 10],
- "Title": 0, // Name
- "Body": {
- "Base": {
- "Unique": 10,
- "Class": 1,
- "Cost": 9,
- },
- "Meta": {
- "QP": 2,
- "Range": 3,
- },
- },
- "Description": 4,
- },
- "Reels": {
- "Rows": [2, 1001],
- "Columns": [0, 10],
- "Title": 0, // Name
- "Body": {
- "Base": {
- "Unique": 10,
- "Class": 1,
- "Cost": 9,
- },
- "Meta": {
- "QP": 2,
- "Range": 3,
- },
- },
- "Description": 5,
- },
- "Observers": {
- "Rows": [2, 1001],
- "Columns": [0, 14],
- "Title": 0, // Name
- "Body": {
- "Base": {
- "Unique": 10,
- "Class": 1,
- "Cost": 14,
- },
- "Meta": {
- "QP": 2,
- "Attachment 1": 7,
- "Attachment 2": 9,
- "Attachment 3": 11,
- }
- },
- "Description": 3,
- },
- "Armor Inventories": {
- "Rows": [2, 1007],
- "Columns": [0, 13],
- "Title": 0, // Name
- "Body": {
- "Base": {
- "Unique": 13,
- "Class": 1,
- "Cost": 12,
- },
- "Meta": {
- "PR Bonus": 2,
- "SR Bonus": 3,
- "Movement Penalty": 4,
- "Physical Reduction": 5,
- "Shinsoo Reduction": 6,
- },
- },
- "Description": 7,
- },
- "Pockets": {
- "Rows": [2, 1000],
- "Columns": [0, 4],
- "Title": 0,
- "Body": {
- "Base": {
- "Unique": 4,
- "Class": 1,
- "Cost": 3,
- },
- "Meta": {
- "Floors": 2,
- },
- }
- },
- "Armor Inventories": {
- "Rows": [2, 1004],
- "Columns": [0, 5],
- "Title": 0, // Name
- "Body": {
- "Base": {
- "Unique": 5,
- "Class": 1,
- "Cost": 4,
- },
- "Meta": {
- "Slots": 2,
- },
- },
- "Description": 7,
- },
- "Misc Items": {
- "Rows": [2, 999],
- "Columns": [0, 11],
- "Title": 0, // Name
- "Body": {
- "Base": {
- "Unique": 11,
- "Class": 1,
- "Cost": 10,
- },
- },
- "Description": 2,
- },
- }
- var rows = [];
- for (var key in locations) {
- var sheet = spreadsheet.getSheetByName(key);
- var data = locations[key];
- var startRow = data["Rows"][0];
- var endRow = data["Rows"][1];
- var startColumn = data["Columns"][0];
- var endColumn = data["Columns"][1];
- var dataRange = sheet.getRange(startRow, startColumn + 1, endRow - startRow + 1, endColumn - startColumn + 1);
- var values = dataRange.getValues();
- for (var i = 0; i < dataRange.getNumRows(); i++) {
- var row = values[i];
- var title = row[data["Title"] - startColumn];
- if (title == "" || row[1] === "") {
- continue;
- }
- var description = row[data["Description"] - startColumn];
- description = isEmpty(description) ? "" : description;
- var body = data["Body"];
- var base = body["Base"];
- var bodyMeta = body["Meta"];
- var unique = row[base["Unique"] - startColumn];
- var class = row[base["Class"] - startColumn];
- var cost = row[base["Cost"] - startColumn];
- var bodyText = "";
- if (unique === "y") {
- bodyText += "**Unique Item**\n"
- }
- if (!isEmpty(class)) {
- bodyText += "**Class:** " + class + "\n";
- }
- if (!isEmpty(String(cost))) {
- bodyText += "**Cost:** " + cost + "\n";
- }
- if (base != null) {
- for (var key in bodyMeta) {
- var item = String(row[bodyMeta[key] - startColumn]);
- if (!isEmpty(item)) {
- bodyText += "**" + key + ":** " + item + "\n";
- }
- }
- }
- rows.push({"name": title, "meta": bodyText, "desc": description});
- }
- }
- var ui = SpreadsheetApp.getUi();
- ui.alert("Exported Items", JSON.stringify(rows), ui.ButtonSet.OK);
- }
- function isEmpty(text) {
- if (text == null) {
- return true;
- }
- text = text.trim().toLowerCase();
- return text == "undefined" || text === "null" || text == null || text === "" || text === "-" || text === "none" || text === "n/a" || text === "tbd" || text === "n/a | tbd";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement