Skip to content

Instantly share code, notes, and snippets.

@BaldarSilveraxe
Last active February 10, 2019 02:56
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BaldarSilveraxe/fe582e5845d38d64d76a to your computer and use it in GitHub Desktop.
Save BaldarSilveraxe/fe582e5845d38d64d76a to your computer and use it in GitHub Desktop.
Complete Set of Sample Images to Make Your "Dungeon Ready" (Random Dungeon Generator and Dynamic Lighting for Walls and Doors with Editing UI)
// GIST: https://gist.github.com/BaldarSilveraxe/fe582e5845d38d64d76a
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~
!dungeonready
~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
var DungeonReady = DungeonReady || (function(){
'use strict';
var version = 0.2,
errorArray,
leadingURL = "https://s3.amazonaws.com/files.d20.io/images/",
mapName = "DungeonReady",
dungeonReadyTilesArray,
mapTileTracker = [],
lineColor = "#00ffff",
lineSize = 5,
opened = "https://s3.amazonaws.com/files.d20.io/images/6743577/YZp1vxxhRWgVMqySSZ6GpQ/thumb.png?1418743597",
swing = "https://s3.amazonaws.com/files.d20.io/images/6743730/OTbt2Yc7Srp2Pgm859H6JA/thumb.png?1418744374",
dungeonReadyMacros = [
{istokenaction: true, action: "!rght_5", name: "->>|"},
{istokenaction: true, action: "!rght_1", name: "->|"},
{istokenaction: true, action: "!left_1", name: "|<-"},
{istokenaction: true, action: "!left_5", name: "|<<-"},
{istokenaction: true, action: "!h_flip", name: "↔Flip-Horizontal"},
{istokenaction: true, action: "!v_flip", name: "↕Flip-Vertical"},
{istokenaction: true, action: "!left90", name: "↶Turn-Left-90-Degrees"},
{istokenaction: true, action: "!rght90", name: "↷Turn-Right-90-Degrees"},
{istokenaction: true, action: "!trn180", name: "↻Turn-180-Degrees"},
{istokenaction: true, action: "!double", name: "▓»▓-Paste-Selected"},
{istokenaction: false, action: "!mapdun", name: "♦1-Random-Map"},
{istokenaction: false, action: "!addfea", name: "♦2-Add-Map-Feature"},
{istokenaction: false, action: "!addGMf", name: "♦3-Add-GM-Feature"},
{istokenaction: false, action: "!addGMl ?{1-30, a-j, or L1-L10|1}", name: "♦4-Add-GM-Label"},
{istokenaction: false, action: "!lightW", name: "♦5-Add-Dynamic-Lighting-Walls"},
{istokenaction: false, action: "!lightf", name: "♦6-Light-Doors-Stairs"},
{istokenaction: false, action: "!tofrom", name: "♦7-Lighting-To-From-GM-Layer"},
{istokenaction: false, action: "!dltpth ?{Are you sure?|N}", name: "♦8-Delete-Lighting-Walls"}
],
dungeonReadyTiles = [
{name: "Geo_B_0001", edge: false, corner: false, entrance: false, connections: 0, side: 0, sample: "6394851/qTICq2-wIRiPAQLPKJPZxA/med.jpg?1416264499"},
{name: "Geo_B_0002", edge: false, corner: false, entrance: false, connections: 2, side: 1, sample: "6394853/g4WzTQB7_Vi2ESuBHRo2Fw/med.jpg?1416264511"},
{name: "Geo_B_0003", edge: false, corner: false, entrance: false, connections: 2, side: 2, sample: "6394855/1FZhOFWMOa3ytVsRvP9sWQ/med.jpg?1416264522"},
{name: "Geo_B_0004", edge: false, corner: false, entrance: false, connections: 2, side: 3, sample: "6394858/NMiQBhwXAGqJxf0DwXhNHQ/med.jpg?1416264533"},
{name: "Geo_B_0005", edge: false, corner: false, entrance: false, connections: 2, side: 4, sample: "6394860/K5gQosh6CK8FYlbpwWso0w/med.jpg?1416264542"},
{name: "Geo_B_0006", edge: false, corner: false, entrance: false, connections: 2, side: 5, sample: "6394862/nU7ENaTNQRk-D9NTeaK4rw/med.jpg?1416264550"},
{name: "Geo_B_0007", edge: false, corner: false, entrance: false, connections: 2, side: 6, sample: "6394863/zGMF2F25zYZlQr3Zybgdlw/med.jpg?1416264560"},
{name: "Geo_B_0008", edge: false, corner: false, entrance: false, connections: 3, side: 7, sample: "6394865/iBxWZk2OGh1oGVE60_okdQ/med.jpg?1416264572"},
{name: "Geo_B_0009", edge: false, corner: false, entrance: false, connections: 3, side: 8, sample: "6394866/Ar14JKls18qQ9twMUAiS_w/med.jpg?1416264580"},
{name: "Geo_B_0010", edge: false, corner: false, entrance: false, connections: 3, side: 9, sample: "6394869/xZbto2TwYI8Ze10TMme7BQ/med.jpg?1416264590"},
{name: "Geo_B_0011", edge: false, corner: false, entrance: false, connections: 3, side: 10, sample: "6394871/s2tyxxXDHA1eL9Mm9Pfr9w/med.jpg?1416264602"},
{name: "Geo_B_0012", edge: false, corner: false, entrance: false, connections: 3, side: 11, sample: "6394874/FSfrUDHz-89xHjHkv1m6Hw/med.jpg?1416264610"},
{name: "Geo_B_0013", edge: false, corner: false, entrance: false, connections: 3, side: 12, sample: "6394875/WCVGKNmIflPxZS2Gz8vsVA/med.jpg?1416264618"},
{name: "Geo_B_0014", edge: false, corner: false, entrance: false, connections: 3, side: 13, sample: "6394879/CNGc96KVkBH3V_T67g4a2A/med.jpg?1416264627"},
{name: "Geo_B_0015", edge: false, corner: false, entrance: false, connections: 8, side: 14, sample: "6394881/pvDaaRs2PdcoS5lpu_3kLA/med.jpg?1416264635"},
{name: "Geo_B_0016", edge: false, corner: false, entrance: false, connections: 4, side: 15, sample: "6394882/aZupq6IGWAyoKrZSUthdJQ/med.jpg?1416264645"},
{name: "Geo_B_0017", edge: false, corner: false, entrance: false, connections: 8, side: 16, sample: "6394884/5ex-f9n1R39GLiOiBqaNzA/med.jpg?1416264655"},
{name: "Geo_B_0018", edge: false, corner: false, entrance: false, connections: 8, side: 17, sample: "6394885/ZSdkHc_ROiCF02vP4-4y_A/med.jpg?1416264664"},
{name: "Geo_B_0019", edge: false, corner: false, entrance: false, connections: 4, side: 18, sample: "6394888/5YLKQBbwnbZWaXy4y0-LrQ/med.jpg?1416264671"},
{name: "Geo_B_0020", edge: false, corner: false, entrance: false, connections: 4, side: 19, sample: "6394891/HIEF2YbijQaWbbP5MWslUg/med.jpg?1416264682"},
{name: "Geo_B_0021", edge: false, corner: false, entrance: false, connections: 8, side: 20, sample: "6394893/jKaZyj-3zDd--vGh8QJCHg/med.jpg?1416264694"},
{name: "Geo_B_0022", edge: false, corner: false, entrance: false, connections: 4, side: 21, sample: "6394896/BFNWLgl-Egh9RDtWfNU2jg/med.jpg?1416264712"},
{name: "Geo_B_0023", edge: false, corner: false, entrance: false, connections: 4, side: 22, sample: "6394897/9dKWHFu7X_ExDgyOQ88Mww/med.jpg?1416264722"},
{name: "Geo_B_0024", edge: false, corner: false, entrance: false, connections: 4, side: 23, sample: "6394900/t-gZCaWE-Mabli-Y98tRZA/med.jpg?1416264731"},
{name: "Geo_B_0025", edge: false, corner: false, entrance: false, connections: 8, side: 24, sample: "6394903/AWOsTeNLvOx3mI26lpUscQ/med.jpg?1416264740"},
{name: "Geo_B_0026", edge: false, corner: false, entrance: false, connections: 6, side: 25, sample: "6394905/hiyvT-Ag0E2-D27vm33qNA/med.jpg?1416264749"},
{name: "Geo_B_0027", edge: false, corner: false, entrance: false, connections: 6, side: 26, sample: "6395354/1Lrv7SWYwBKzt_CGPiETnQ/med.jpg?1416267549"},
{name: "Geo_B_0028", edge: false, corner: false, entrance: false, connections: 1, side: 27, sample: "6395363/0TIvZ4P-WmJWt6gHvA8sxA/med.jpg?1416267566"},
{name: "Geo_B_0029", edge: false, corner: false, entrance: false, connections: 2, side: 28, sample: "6395371/-HsX1fXEHVfQ2w6nlLh80A/med.jpg?1416267577"},
{name: "Geo_B_0030", edge: false, corner: false, entrance: false, connections: 2, side: 29, sample: "6395382/nJuEVapNim-G5uadhvY8mw/med.jpg?1416267592"},
{name: "Geo_B_0031", edge: false, corner: false, entrance: false, connections: 2, side: 30, sample: "6395397/TmSgDujfUdWDGuM5DocjKw/med.jpg?1416267608"},
{name: "Geo_B_0032", edge: false, corner: false, entrance: false, connections: 2, side: 31, sample: "6395407/Lptre6CJTfHaANQfMCZrMA/med.jpg?1416267621"},
{name: "Geo_B_0033", edge: false, corner: false, entrance: false, connections: 2, side: 32, sample: "6395415/8JrsM0bSBJ7OkWYDdLDdDQ/med.jpg?1416267631"},
{name: "Geo_B_0034", edge: false, corner: false, entrance: false, connections: 2, side: 33, sample: "6395417/gYw6w6PWZ0o6fVZPtFWpyg/med.jpg?1416267643"},
{name: "Geo_B_0035", edge: false, corner: false, entrance: false, connections: 2, side: 34, sample: "6395419/lwbV8z_iBQfxAuo3ejUH0Q/med.jpg?1416267656"},
{name: "Geo_B_0036", edge: false, corner: false, entrance: false, connections: 8, side: 35, sample: "6395423/robcI_RyGO37yDUSrZBQ_g/med.jpg?1416267667"},
{name: "Geo_B_0037", edge: false, corner: false, entrance: false, connections: 3, side: 36, sample: "6395427/vYgucAdusuCc8d3eTvlLZg/med.jpg?1416267679"},
{name: "Geo_B_0038", edge: false, corner: false, entrance: false, connections: 3, side: 37, sample: "6395429/6hdfKzfZMms7u5Th9Aw8Qg/med.jpg?1416267690"},
{name: "Geo_B_0039", edge: false, corner: false, entrance: false, connections: 3, side: 38, sample: "6395432/N33Vlox7wWf13uJSC0v1Hw/med.jpg?1416267703"},
{name: "Geo_B_0040", edge: false, corner: false, entrance: false, connections: 3, side: 39, sample: "6395434/jWMHpnw_q81hEc_TChMQug/med.jpg?1416267715"},
{name: "Geo_B_0041", edge: false, corner: false, entrance: false, connections: 3, side: 40, sample: "6395435/1Qzj6ddXSDmIuW-_FOESTA/med.jpg?1416267725"},
{name: "Geo_B_0042", edge: false, corner: false, entrance: false, connections: 3, side: 41, sample: "6395437/fHt9HQ3io7kg7mhEodAQSA/med.jpg?1416267735"},
{name: "Geo_B_0043", edge: false, corner: false, entrance: false, connections: 4, side: 42, sample: "6395440/FJFT0CJgragGbhbEdLTpPw/med.jpg?1416267748"},
{name: "Geo_B_0044", edge: false, corner: false, entrance: false, connections: 4, side: 43, sample: "6397340/SPVlHZ09U1dlZLkVXdPY_g/med.jpg?1416276733"},
{name: "Geo_B_0045", edge: false, corner: false, entrance: false, connections: 4, side: 44, sample: "6395450/rYmOChNZx4Wvlk0ihMjeTg/med.jpg?1416267796"},
{name: "Geo_B_0046", edge: false, corner: false, entrance: false, connections: 4, side: 45, sample: "6394954/gmnQMKEewRdSCvGNzu_4vw/med.jpg?1416264957"},
{name: "Geo_B_0047", edge: false, corner: false, entrance: false, connections: 4, side: 46, sample: "6394957/HO0_PxOKyMq-YsrbOwEZRg/med.jpg?1416264968"},
{name: "Geo_B_0048", edge: false, corner: false, entrance: false, connections: 5, side: 47, sample: "6394959/EP1DvLpsq9DWNjbR81VV_g/med.jpg?1416264981"},
{name: "Geo_B_0049", edge: false, corner: false, entrance: false, connections: 6, side: 48, sample: "6394962/CGdvJ6iCk35oTeygPb9_8w/med.jpg?1416264997"},
{name: "Geo_B_0050", edge: false, corner: false, entrance: false, connections: 6, side: 49, sample: "6394963/gOKi1R6HFftj5s0IUJLVoA/med.jpg?1416265010"},
{name: "Geo_B_0051", edge: false, corner: false, entrance: false, connections: 7, side: 50, sample: "6394965/PpkJiQAK3tNke4nr9M4gOg/med.jpg?1416265022"},
{name: "Geo_B_0052", edge: false, corner: false, entrance: false, connections: 4, side: 51, sample: "6413066/PDQ6wdClOOAT0kYlBoi9dA/med.jpg?1416409069"},
{name: "Geo_B_0053", edge: false, corner: false, entrance: false, connections: 5, side: 52, sample: "6413004/aqNa4vRUXr7mHdQuHbB_CA/med.jpg?1416407982"},
{name: "Geo_B_0054", edge: false, corner: false, entrance: false, connections: 5, side: 53, sample: "6413003/gAROTSezj3Pk-8Um0Bimkg/med.jpg?1416407981"},
{name: "Geo_B_0055", edge: false, corner: false, entrance: false, connections: 5, side: 54, sample: "6413005/BUJvD12mIukXgPHbOGWtBw/med.jpg?1416407987"},
{name: "Geo_B_0056", edge: false, corner: false, entrance: false, connections: 5, side: 55, sample: "6412997/pI35NfMMdHTHmFJp8gQbVw/med.jpg?1416407974"},
{name: "Geo_B_0057", edge: false, corner: false, entrance: false, connections: 6, side: 56, sample: "6413001/9OoOtLlLpiIUr5mqjJZJnw/med.jpg?1416407977"},
{name: "Geo_B_0058", edge: false, corner: false, entrance: false, connections: 7, side: 57, sample: "6412998/NT7_JACUKuUDTNyWiZ37kA/med.jpg?1416407974"},
{name: "Geo_B_0059", edge: false, corner: false, entrance: false, connections: 6, side: 58, sample: "6412999/IAJVvz1XnPWaGlIU3nzJ8g/med.jpg?1416407975"},
{name: "Geo_B_0060", edge: false, corner: false, entrance: false, connections: 8, side: 59, sample: "6413000/UgUt9PekpJ7-PyvB4hQqVQ/med.jpg?1416407975"},
{name: "Geo_B_0061", edge: false, corner: false, entrance: false, connections: 8, side: 60, sample: "6417192/L0uhoo7qLfnXS9RG8aHtDw/med.jpg?1416441647"},
{name: "Geo_B_1001", edge: true, corner: false, entrance: false, connections: 0, side: 61, sample: "6394967/wE0ctwz2ZFD8zB46q34RFw/med.jpg?1416265036"},
{name: "Geo_B_1002", edge: true, corner: false, entrance: false, connections: 2, side: 62, sample: "6394968/hVf4k5rPO62ukQAF3_b_xw/med.jpg?1416265046"},
{name: "Geo_B_1003", edge: true, corner: false, entrance: false, connections: 2, side: 63, sample: "6394973/X_hpf6MKgkKcC9gw-12oFA/med.jpg?1416265056"},
{name: "Geo_B_1004", edge: true, corner: false, entrance: false, connections: 3, side: 64, sample: "6394976/QRctGIqrhtpUR6xz6mNrSA/med.jpg?1416265064"},
{name: "Geo_B_1005", edge: true, corner: false, entrance: false, connections: 3, side: 65, sample: "6394977/T7s63Pk-S3e_cEWOuTToIA/med.jpg?1416265073"},
{name: "Geo_B_1006", edge: true, corner: false, entrance: false, connections: 4, side: 66, sample: "6394978/fzuO_kwqugs81EYySj3W9g/med.jpg?1416265082"},
{name: "Geo_B_1007", edge: true, corner: false, entrance: false, connections: 4, side: 67, sample: "6394979/5M49W9dkrL_tMmlbf7fe7g/med.jpg?1416265089"},
{name: "Geo_B_2001", edge: false, corner: true, entrance: false, connections: 2, side: 68, sample: "6394987/xgkrro5BLNyIOZkeCT5n9Q/med.jpg?1416265123"},
{name: "Geo_B_2002", edge: false, corner: true, entrance: false, connections: 0, side: 69, sample: "6394990/Aq_mxgwERQILy2x3TBYL5Q/med.jpg?1416265133"}
],
dynamicLightingArray = [
{tileName: "0001,0003,0004,0005,0006,0007,1001,2002,0012,0013,0014,0016,0022,0023,0024,0026,0027", path: [[90,0],[90,50],[330,50],[330,0]]},
{tileName: "0001,0002,0004,0005,0006,0007,0009,0010,0011,0013,0014,0016,0019,0020,0022,0024", path: [[510,0],[510,50],[750,50],[750,0]]},
{tileName: "0001,1001,1003,2002", path: [[0,90],[50,90],[50,330],[0,330]]},
{tileName: "0001,0002,0003,0004,0005,0006,1001,1002,1003,1005,0008,0009,0010,0011,0012,0013,0020,0052,0054,0055,0056", path: [[0,510],[50,510],[50,750],[0,750]]},
{tileName: "0001,0002,0003,0005,0006,0007,0008,0010,0011,0012,0013,0014,0016,0019,0020,0023", path: [[840,90],[790,90],[790,330],[840,330]]},
{tileName: "0001,0002,0003,0004,0006,0007,0008,0009,0011,0012,0013,0014,0016,0019,0020,0022,0023,0026,0052,0053,0054,0055", path: [[840,510],[790,510],[790,750],[840,750]]},
{tileName: "0001,0002,0003,0004,0005,0006,0007,1001,1002,1004,0008,0009,0010,0011,0012,0014,0019,0022,0023,0024,0052,0053,0055,0056,0057,0059", path: [[90,840],[90,790],[330,790],[330,840]]},
{tileName: "0001,0002,0003,0004,0005,0007,0008,0009,0010,0024,0027,0052,0053,0054,0056,0057,0058,0059", path: [[510,840],[510,790],[750,790],[750,840]]},
{tileName: "0002,1002,1004,1005,1006,1007,2001,0008,0009,0010,0011,0015,0017,0018,0019,0020,0021,0025", path: [[0,90],[90,90],[90,0]]},
{tileName: "0002,1002,1007,2001,0017", path: [[0,330],[330,330],[330,0]]},
{tileName: "0003,0012", path: [[0,90],[510,90],[510,0]]},
{tileName: "0003,0008", path: [[0,330],[750,330],[750,0]]},
{tileName: "0004", path: [[0,90],[840,90]]},
{tileName: "0004,0009", path: [[0,330],[840,330]]},
{tileName: "0005", path: [[0,90],[540,90],[540,510],[840,510]]},
{tileName: "0005", path: [[0,330],[300,330],[300,750],[840,750]]},
{tileName: "0006,0013,0014,0016", path: [[0,90],[750,90],[750,840]]},
{tileName: "0006,0012,0016", path: [[0,330],[510,330],[510,840]]},
{tileName: "0007", path: [[0,90],[330,90],[330,750],[0,750]]},
{tileName: "0007,1004,1006,0014,0015,0018,0019", path: [[0,330],[90,330],[90,510],[0,510]]},
{tileName: "1003", path: [[90,0],[90,840]]},
{tileName: "1003,1005,1006", path: [[330,0],[330,840]]},
{tileName: "1004", path: [[330,0],[330,750],[0,750]]},
{tileName: "1005,0013,0020", path: [[0,330],[90,330],[90,840]]},
{tileName: "1006,1007,0015,0016,0017,0018,0021,0025,0026,0027", path: [[0,750],[90,750],[90,840]]},
{tileName: "1007,0016,0017,0026,0027", path: [[0,510],[330,510],[330,840]]},
{tileName: "0008,0015,0018", path: [[330,0],[330,90],[510,90],[510,0]]},
{tileName: "0009", path: [[330,0],[330,90],[840,90]]},
{tileName: "0010", path: [[0,330],[510,330],[510,750],[840,750]]},
{tileName: "0010", path: [[330,0],[330,90],[750,90],[750,510],[840,510]]},
{tileName: "0011", path: [[0,330],[510,330],[510,840]]},
{tileName: "0011,0019,0020", path: [[330,0],[330,90],[750,90],[750,840]]},
{tileName: "0012", path: [[750,0],[750,840]]},
{tileName: "0013,0020", path: [[330,840],[330,330],[510,330],[510,840]]},
{tileName: "0014,0019", path: [[0,750],[330,750],[330,330],[510,330],[510,840]]},
{tileName: "0015,0017,0018,0021,0025,0026,0027", path: [[750,0],[750,90],[840,90]]},
{tileName: "0015,0018", path: [[840,330],[750,330],[750,510],[840,510]]},
{tileName: "0015,0017,0018,0021,0025", path: [[840,750],[750,750],[750,840]]},
{tileName: "0015,0018,0060", path: [[330,840],[330,750],[510,750],[510,840]]},
{tileName: "0015,0018", path: [[330,330],[510,330],[510,510],[330,510],[330,330]]},
{tileName: "0017,0026,0027", path: [[510,0],[510,330],[840,330]]},
{tileName: "0017", path: [[510,840],[510,510],[840,510]]},
{tileName: "0018,0019,0020", path: [[90,90],[90,330]]},
{tileName: "0018,0019,0020", path: [[330,90],[330,330]]},
{tileName: "0018", path: [[510,90],[750,90]]},
{tileName: "0018", path: [[510,330],[750,330]]},
{tileName: "0018", path: [[510,330],[750,330]]},
{tileName: "0018", path: [[510,510],[510,750]]},
{tileName: "0018", path: [[750,510],[750,750]]},
{tileName: "0018", path: [[90,510],[330,510]]},
{tileName: "0018", path: [[90,750],[330,750]]},
{tileName: "0021", path: [[330,0],[330,157],[683,510],[840,510]]},
{tileName: "0021,0022,0023,0026", path: [[0,330],[157,330],[510,683],[510,840]]},
{tileName: "0021,0023,0025", path: [[510,0],[510,157],[420,245]]},
{tileName: "0021,0022,0024,0025", path: [[840,330],[683,330],[595,420]]},
{tileName: "0021,0025", path: [[330,840],[330,683],[420,595]]},
{tileName: "0021,0022,0023,0024,0025", path: [[0,510],[157,510],[245,420]]},
{tileName: "0022,0023,0026", path: [[0,90],[262,90],[750,578],[750,840]]},
{tileName: "0022,0024", path: [[840,90],[578,90],[420,245]]},
{tileName: "0022,0023,0024", path: [[0,750],[262,750],[420,595]]},
{tileName: "0023", path: [[750,0],[750,262],[595,420]]},
{tileName: "0024,0027", path: [[0,90],[262,90],[683,510],[840,510]]},
{tileName: "0024,0027", path: [[0,330],[157,330],[578,750],[840,750]]},
{tileName: "0025", path: [[330,0],[330,157],[422,247]]},
{tileName: "0025", path: [[840,510],[683,510],[592,419]]},
{tileName: "0025", path: [[510,840],[510,683],[419,592]]},
{tileName: "0025", path: [[0,330],[157,330],[247,421]]},
{tileName: "0028,0029,0030,0031,0032,0033,0034,0035,0036,0037,0038,0039,0040,0041,0042,0043,0044,0045,0046,0047,0048,0049,0050,0051,0052,0053,0054,0055,0056,0057,0058,0059,0060,0061", path: [[0,90],[35,90],[35,35],[90,35],[90,0]]},
{tileName: "0028,0029,0030,0031,0032,0033,0034,0035,0036,0037,0038,0039,0040,0041,0042,0043,0044,0045,0046,0047,0048,0049,0050,0051,0052,0053,0054,0055,0056,0057,0058,0059,0060,0061", path: [[330,0],[330,35],[510,35],[510,0]]},
{tileName: "0028,0029,0030,0031,0032,0033,0034,0035,0036,0037,0038,0039,0040,0041,0042,0043,0044,0045,0046,0047,0048,0049,0050,0051,0052,0053,0054,0055,0056,0057,0058,0059,0060,0061", path: [[750,0],[750,35],[805,35],[805,90],[840,90]]},
{tileName: "0028,0029,0030,0031,0032,0033,0034,0035,0036,0037,0038,0039,0040,0041,0042,0043,0044,0045,0046,0047,0048,0049,0050,0051,0061", path: [[840,330],[805,330],[805,510],[840,510]]},
{tileName: "0028,0029,0030,0031,0032,0033,0034,0035,0036,0037,0038,0039,0040,0041,0042,0043,0044,0045,0046,0047,0048,0049,0050,0051,0061", path: [[840,750],[805,750],[805,805],[750,805],[750,840]]},
{tileName: "0028,0029,0030,0031,0032,0033,0034,0035,0036,0037,0038,0039,0040,0041,0042,0043,0044,0045,0046,0047,0048,0049,0050,0051,0061", path: [[330,840],[330,805],[510,805],[510,840]]},
{tileName: "0028,0029,0030,0031,0032,0033,0034,0035,0036,0037,0038,0039,0040,0041,0042,0043,0044,0045,0046,0047,0048,0049,0050,0051,0061", path: [[90,840],[90,805],[35,805],[35,750],[0,750]]},
{tileName: "0028,0029,0030,0031,0032,0033,0034,0035,0036,0037,0038,0039,0040,0041,0042,0043,0044,0045,0046,0047,0048,0049,0050,0051,0061", path: [[0,330],[35,330],[35,510],[0,510]]},
{tileName: "0028,0030,0031,0032,0033,0034,0035,0040,0041,0042,0048,0050", path: [[510,35],[750,35]]},
{tileName: "0028,0029,0031,0032,0033,0034,0035,0038,0039,0041,0042,0044,0045", path: [[805,90],[805,330]]},
{tileName: "0028,0029,0030,0032,0033,0034,0035,0037,0039,0040,0041,0046,0047", path: [[805,510],[805,750]]},
{tileName: "0028,0029,0030,0031,0033,0034,0035,0037,0038,0040,0041,0042,0043,0045,0046,0047", path: [[510,805],[750,805]]},
{tileName: "0028,0029,0030,0031,0032,0034,0035,0037,0038,0039,0042,0043,0044,0045,0046,0047,0048", path: [[90,805],[330,805]]},
{tileName: "0028,0029,0030,0031,0032,0033,0035,0037,0038,0039,0040,0041,0042,0043,0044,0046", path: [[35,510],[35,750]]},
{tileName: "0028,0029,0030,0031,0032,0033,0034,0037,0038,0039,0040,0043,0044,0045,0047,0048,0049,0050,0051", path: [[35,90],[35,330]]},
{tileName: "0052,0057", path: [[0,330],[35,330],[35,455],[805,455],[805,330],[840,330]]},
{tileName: "0053", path: [[0,330],[35,330],[35,455],[90,455],[90,510],[0,510]]},
{tileName: "0053", path: [[0,750],[330,750],[330,455],[805,455],[805,330],[840,330]]},
{tileName: "0054", path: [[0,330],[35,330],[35,455],[90,455],[90,840]]},
{tileName: "0054", path: [[330,840],[330,455],[805,455],[805,330],[840,330]]},
{tileName: "0055", path: [[0,330],[35,330],[35,455],[90,455],[90,750],[510,750],[510,840]]},
{tileName: "0055", path: [[750,840],[750,510],[330,510],[330,455],[805,455],[805,330],[840,330]]},
{tileName: "0056", path: [[0,330],[35,330],[35,455],[90,455],[90,750],[840,750]]},
{tileName: "0056", path: [[840,510],[330,510],[330,455],[805,455],[805,330],[840,330]]},
{tileName: "0057", path: [[0,510],[840,510]]},
{tileName: "0057,0059", path: [[0,750],[840,750]]},
{tileName: "0058,0059,0060", path: [[0,330],[35,330],[35,455],[300,455],[300,510],[0,510]]},
{tileName: "0058,0059,0060", path: [[840,510],[540,510],[540,455],[805,455],[805,330],[840,330]]},
{tileName: "0058,0060", path: [[0,750],[90,750],[90,840]]},
{tileName: "0058", path: [[330,840],[330,750],[840,750]]},
{tileName: "0060", path: [[750,840],[750,750],[840,750]]},
{tileName: "0061", path: [[150,150],[200,150],[200,200],[150,200],[150,150]]},
{tileName: "0061", path: [[395,150],[445,150],[445,200],[395,200],[395,150]]},
{tileName: "0061", path: [[640,150],[690,150],[690,200],[640,200],[640,150]]},
{tileName: "0061", path: [[150,395],[200,395],[200,445],[150,445],[150,395]]},
{tileName: "0061", path: [[395,395],[445,395],[445,445],[395,445],[395,395]]},
{tileName: "0061", path: [[640,395],[690,395],[690,445],[640,445],[640,395]]},
{tileName: "0061", path: [[150,640],[200,640],[200,690],[150,690],[150,640]]},
{tileName: "0061", path: [[395,640],[445,640],[445,690],[395,690],[395,640]]},
{tileName: "0061", path: [[640,640],[690,640],[690,690],[640,690],[640,640]]},
{tileName: "0061", path: [[640,640],[690,640],[690,690],[640,690],[640,640]]}
],
dungeonReadyElements = [
{width: 70, height: 280, sample: "6438063/X10nUgJNuThdJ6GdhUAi0A/med.png?1416620236", name: "Door"},
{width: 70, height: 280, sample: "6438067/oyzvQp98uq_2MPCYNZO9PQ/med.png?1416620239", name: "Door_Barred"},
{width: 70, height: 280, sample: "6438070/2benB2IAVCnmxWw3nzTxog/med.png?1416620240", name: "Portcullis"},
{width: 140, height: 140, sample: "6438069/MYxJaztct9kwcwFKk0wlig/med.jpg?1416620239", name: "Trap_Door"},
{width: 140, height: 140, sample: "6438068/yXZzxkBIsN6Ld6xocRhusg/med.jpg?1416620239", name: "Trap_Door_Locked"},
{width: 70, height: 140, sample: "6438075/TbPSZ2ZA42yDNy3cduEAtA/med.png?1416620243", name: "Torch_On"},
{width: 70, height: 140, sample: "6438073/bB25Z0CTxcUhloxX3H-b9Q/med.png?1416620242", name: "Torch_Off"},
{width: 140, height: 280, sample: "6438066/fhFiHkQlKEU5pms6PnoPfg/med.png?1416620237", name: "Stairwell_Up"},
{width: 140, height: 280, sample: "6438062/WRFD9tPg08466El6RdW6eQ/med.png?1416620235", name: "Stairwell_Down"},
{width: 140, height: 280, sample: "6438064/7mysfaYCh28Q3BCUj9425A/med.png?1416620236", name: "Stairs_Up_Wall"},
{width: 140, height: 280, sample: "6438061/tfIC1VOT8W4sCQPYothkCw/med.png?1416620235", name: "Stairs_Down_Wall"},
{width: 140, height: 280, sample: "6438060/e0hVamV5AtX0_XeOWCFXNg/med.png?1416620235", name: "Stairs_Up"},
{width: 140, height: 280, sample: "6438076/fM1QHvMhaHfsaEEQ_FrZlQ/med.png?1416620243", name: "Stairs_Down"},
{width: 140, height: 140, sample: "6438071/aRpM3KJNefeDh0EgPEUf5g/med.png?1416620241", name: "Pit"}
],
dungeonReadyGMspecial = [
{width: 70, height: 70, sample: "6435690/bCQMvsS2-D5vdj52Htrveg/med.png?1416606859", name: "GM_Compass"},
{width: 70, height: 70, sample: "6435695/RS_F8sOAcHS4BQp39DFQhg/med.png?1416606881", name: "GM_Important"},
{width: 70, height: 70, sample: "6435700/JaFhadhW8S5FyFHI2_0TMQ/med.png?1416606903", name: "GM_Locked"},
{width: 70, height: 70, sample: "6435707/MPGX48yTpo5s9AhN9uDsKw/med.png?1416606933", name: "GM_Locked_Small"},
{width: 70, height: 70, sample: "6435714/N8vII4H3uD7ZRt7-8-tz0Q/med.png?1416606959", name: "GM_Locked_Barred"},
{width: 70, height: 70, sample: "6435725/EjxJjYG1p7EXPkPxS9oXCg/med.png?1416606988", name: "GM_Locked_Barred_Small"},
{width: 70, height: 70, sample: "6435742/ttKW3rifpp-67ZRdFNZgVQ/med.png?1416607038", name: "GM_Locked_Trapped"},
{width: 70, height: 70, sample: "6435744/-9PbxME-9SRv_CCaCJjVvA/med.png?1416607063", name: "GM_Locked_Trapped_Small"},
{width: 70, height: 70, sample: "6435750/7kV8FqwGCFjm6FDrL6vi6Q/med.png?1416607087", name: "GM_Pit_Trap"},
{width: 70, height: 70, sample: "6435756/Zis6hQ2m12d9F5Uu8P2A4g/med.png?1416607114", name: "GM_Secret_Door"},
{width: 70, height: 70, sample: "6435768/jz4KC21ncw1q877nPRRSuQ/med.png?1416607163", name: "GM_Secret_Door_Ceiling"},
{width: 70, height: 70, sample: "6435770/y6aLI6HUFD6VVqZ50xyUvw/med.png?1416607189", name: "GM_Secret_Door_Floor"},
{width: 70, height: 70, sample: "6435774/si9I92FZM2Sw6rOwLMbVTA/med.png?1416607216", name: "GM_Secret_Door_One_Way_Left"},
{width: 70, height: 70, sample: "6435779/NzUeRb6LUzTRofEEYBta3g/med.png?1416607233", name: "GM_Secret_Door_One_Way_Right"},
{width: 70, height: 70, sample: "6435787/79T-16o8zoNyTej11ISwnw/med.png?1416607270", name: "GM_Sense_Detect_Odor"},
{width: 70, height: 70, sample: "6556559/VIHF5zPPHeh004IRfqqdxA/med.png?1417547864", name: "GM_Sense_Detect_Sight"},
{width: 70, height: 70, sample: "6435793/cl1aASMM2ff2CZa2A6swYA/med.png?1416607289", name: "GM_Sense_Detect_Sound"},
{width: 70, height: 70, sample: "6435797/gByLL7Md4hz6e2hw1SlaIg/med.png?1416607317", name: "GM_Sense_Detect_Vibration"},
{width: 70, height: 70, sample: "6435802/OIlzC13pAvxrefGfe2MNXg/med.png?1416607345", name: "GM_Slope_Imperceptible"},
{width: 70, height: 70, sample: "6435808/Nihv22D7b0Jip-DVlU5FDg/med.png?1416607366", name: "GM_Slope_Shallow"},
{width: 70, height: 70, sample: "6435816/XkX-KTk9IRPIGV5v26WMfg/med.png?1416607383", name: "GM_Slope_Steep"},
{width: 70, height: 70, sample: "6435824/b8jJRbok-Af8TZB2nhaPzA/med.png?1416607406", name: "GM_Trap"}
],
dungeonReadyGMlabels = [
{width: 70, height: 70, sample: "6435957/wnrILG1KG5lEiEnOtSYYXQ/med.png?1416608179", name: "Label_1"},
{width: 70, height: 70, sample: "6435962/P5pvu2lYZ7V3p0bW3VOm9A/med.png?1416608206", name: "Label_2"},
{width: 70, height: 70, sample: "6435976/JabkqBh1rWdGG9m61OBnzQ/med.png?1416608229", name: "Label_3"},
{width: 70, height: 70, sample: "6435979/lqTpvxrdSXlhS4bW3Ed5Jg/med.png?1416608248", name: "Label_4"},
{width: 70, height: 70, sample: "6435986/QO-XB51WrJWmDjKAkAHkqQ/med.png?1416608270", name: "Label_5"},
{width: 70, height: 70, sample: "6435991/MK1uoRslBIR8wqJHvQQekA/med.png?1416608287", name: "Label_6"},
{width: 70, height: 70, sample: "6435996/BfOjM3dDQ_3P0kFvJS45AQ/med.png?1416608303", name: "Label_7"},
{width: 70, height: 70, sample: "6436005/koMTA4qXHc_x26zQKQIphQ/med.png?1416608330", name: "Label_8"},
{width: 70, height: 70, sample: "6436010/FRxvKgv8KTi4dwzWdlQatQ/med.png?1416608352", name: "Label_9"},
{width: 70, height: 70, sample: "6436012/V9RjIoB3HsH8tFw9NadYtg/med.png?1416608367", name: "Label_10"},
{width: 70, height: 70, sample: "6436015/X9j4-WkLN_VZ_uW1seyQQQ/med.png?1416608382", name: "Label_11"},
{width: 70, height: 70, sample: "6436022/eQoYQmc1ljfmZwnEPOFBuA/med.png?1416608407", name: "Label_12"},
{width: 70, height: 70, sample: "6436028/lZbs5QRXryjZ-JTh2QGWcg/med.png?1416608422", name: "Label_13"},
{width: 70, height: 70, sample: "6436034/OAGWdtP0eZ5bjzMLRkvfCw/med.png?1416608435", name: "Label_14"},
{width: 70, height: 70, sample: "6436038/uYqWNIYCeUk3sVEwibTk4A/med.png?1416608450", name: "Label_15"},
{width: 70, height: 70, sample: "6436041/zZMmi8xsVtsUGoBt9UqYig/med.png?1416608465", name: "Label_16"},
{width: 70, height: 70, sample: "6436046/qBnOsYE8qKme4QLixMNuxQ/med.png?1416608482", name: "Label_17"},
{width: 70, height: 70, sample: "6436051/wEQi2v1kTUJWbKGWwtYMbQ/med.png?1416608506", name: "Label_18"},
{width: 70, height: 70, sample: "6436054/c07m5StmNqCBwZUtE8Vbcg/med.png?1416608518", name: "Label_19"},
{width: 70, height: 70, sample: "6436055/Tza9JX5XNDUW1Yp47ukpPA/med.png?1416608535", name: "Label_20"},
{width: 70, height: 70, sample: "6436059/s2pphkUSW7_pG0xwNMMYYw/med.png?1416608547", name: "Label_21"},
{width: 70, height: 70, sample: "6436063/Yd7bEko7l5wOZsZ0Te4Aiw/med.png?1416608566", name: "Label_22"},
{width: 70, height: 70, sample: "6436065/37ivKhVMW4YX2Kk1OJws5w/med.png?1416608581", name: "Label_23"},
{width: 70, height: 70, sample: "6436068/8nikh6b9qs6lsiemYvdMyA/med.png?1416608596", name: "Label_24"},
{width: 70, height: 70, sample: "6436071/ote4cZGH86Vo97XOAdf43A/med.png?1416608609", name: "Label_25"},
{width: 70, height: 70, sample: "6436076/083ZosMdceKEpbUTphAN0Q/med.png?1416608627", name: "Label_26"},
{width: 70, height: 70, sample: "6436084/BivTKmGo2XNbp3HgldAkAA/med.png?1416608668", name: "Label_27"},
{width: 70, height: 70, sample: "6436089/hdn1q9rFSXr7k943wLitpA/med.png?1416608683", name: "Label_28"},
{width: 70, height: 70, sample: "6436145/pBRcNQofGrLcgdUd8XYfYg/med.png?1416608913", name: "Label_29"},
{width: 70, height: 70, sample: "6436148/a0SE-25JhoYM31pu6N5sEg/med.png?1416608935", name: "Label_30"},
{width: 70, height: 70, sample: "6436154/EUtioMiHUyR3i6HU4Sl_hA/med.png?1416608955", name: "Label_a"},
{width: 70, height: 70, sample: "6436156/cbj-25xN7Z9s_h5ZWFjIlw/med.png?1416608971", name: "Label_b"},
{width: 70, height: 70, sample: "6436164/uSbzjPsFLCMeKrDBQKuSPg/med.png?1416609001", name: "Label_c"},
{width: 70, height: 70, sample: "6436105/TNQPbbDeLeYZJFSh1HH2yQ/med.png?1416608763", name: "Label_d"},
{width: 70, height: 70, sample: "6436109/9y4qcOaf_9xHJJdoPi7nSw/med.png?1416608777", name: "Label_e"},
{width: 70, height: 70, sample: "6436116/W4_7JLCk5KSRYLc7lYvGNg/med.png?1416608790", name: "Label_f"},
{width: 70, height: 70, sample: "6436122/pyDCozCF7zMKqCC4mLRb0Q/med.png?1416608828", name: "Label_g"},
{width: 70, height: 70, sample: "6436127/wgb3x1LQxgTs5fmtZlz5dg/med.png?1416608842", name: "Label_h"},
{width: 70, height: 70, sample: "6436131/WJrprsQ3Z_HJ3mhTQMNP_A/med.png?1416608857", name: "Label_i"},
{width: 70, height: 70, sample: "6436137/Xz9H7yIKgaNR1bnTL5jukQ/med.png?1416608875", name: "Label_j"},
{width: 140, height: 70, sample: "6436171/imVjTG899A9KbZPsCIgUNw/med.png?1416609032", name: "Label_Level_1"},
{width: 140, height: 70, sample: "6436173/W4NyCv2MNC_jjxkKJaJDIQ/med.png?1416609043", name: "Label_Level_2"},
{width: 140, height: 70, sample: "6436176/eXHpneW7gSNDXw7QYAkNYw/med.png?1416609056", name: "Label_Level_3"},
{width: 140, height: 70, sample: "6436179/U0OW8P54xv0QzDoafsH3Gw/med.png?1416609069", name: "Label_Level_4"},
{width: 140, height: 70, sample: "6436182/JonVRaowWY7c8bcF-ZJ04w/med.png?1416609081", name: "Label_Level_5"},
{width: 140, height: 70, sample: "6436186/IcnRk1FjwjcPw7zibAuY5A/med.png?1416609092", name: "Label_Level_6"},
{width: 140, height: 70, sample: "6436189/1OsVBkj5WSUNvBGUkEICzg/med.png?1416609108", name: "Label_Level_7"},
{width: 140, height: 70, sample: "6436191/O_pLsdeUsIzrCPHZFHkX_A/med.png?1416609121", name: "Label_Level_8"},
{width: 140, height: 70, sample: "6436193/q-3BEEN-5bXQjdbUuaLmdw/med.png?1416609136", name: "Label_Level_9"},
{width: 140, height: 70, sample: "6436198/6GDNaMugSbFDa7vofRTQpA/med.png?1416609166", name: "Label_Level_10"}
],
handleInput = function(msg) {
var args, obj, playerid, dungeonReadyPage, dungeonReadyID, objCheck
msg = _.clone(msg);
if ( "api" !== msg.type ) {return; }
args = msg.content.split(/\s+/);
obj = _.first(msg.selected);
playerid = msg.playerid
switch(args[0]) {
case "!dungeonready": setupDungeonGenerator(true,playerid); return;
case "!mapdun": mapdungeon(playerid); return;
}
errorArray = new Array();
dungeonReadyPage = findObjs({ name: mapName, _type: "page"});
if (dungeonReadyPage.length == 0) {
errorArray.push({typeError: "Critical", textError: "Page named '" + mapName + "' is missing."});
messageErrors();
return;
}
if (dungeonReadyPage.length > 1) {
errorArray.push({typeError: "Critical", textError: "More than one " + mapName + "."});
messageErrors();
return;
}
dungeonReadyID = dungeonReadyPage[0].get("_id");
switch(args[0]) {
case "!lightW": setPaths(playerid,dungeonReadyPage,dungeonReadyID); return;
case "!tofrom": tofromGM(dungeonReadyID); return;
case "!addfea":
objCheck = checkSelect(obj,"graphic","add");
if ( objCheck == false) {return; }
addfeature(playerid,obj,"add",dungeonReadyID);
return;
case "!double":
objCheck = checkSelect(obj,"graphic","add");
if ( objCheck == false) { return; }
addfeature(playerid,obj,"pst",dungeonReadyID);
return;
case "!lightf": lightFeatures(dungeonReadyID); return;
case "!addGMf": addGMfeature(dungeonReadyPage,dungeonReadyID); return;
case "!addGMl": addGMlabel(msg,dungeonReadyPage,dungeonReadyID); return;
case "!dltpth": deletePaths(msg,dungeonReadyPage,dungeonReadyID); return;
}
switch(args[0]) {
case "!rght90":
if ( pathCheck(dungeonReadyID) != 0 ) {return; }
rotateTile(msg, 90);
return;
case "!left90":
if ( pathCheck(dungeonReadyID) != 0 ) {return; }
rotateTile(msg, -90);
return;
case "!trn180":
if ( pathCheck(dungeonReadyID) != 0 ) {return; }
rotateTile(msg, 180);
return;
case "!v_flip":
if ( pathCheck(dungeonReadyID) != 0 ) {return; }
flipTile(msg, "V");
return;
case "!h_flip":
if ( pathCheck(dungeonReadyID) != 0 ) {return; }
flipTile(msg, "H");
return;
case "!left_1":
if ( pathCheck(dungeonReadyID) != 0 ) {return; }
chooseTile(msg, "L", 1);
return;
case "!left_5":
if ( pathCheck(dungeonReadyID) != 0 ) {return; }
chooseTile(msg, "L", 5);
return;
case "!rght_1":
if ( pathCheck(dungeonReadyID) != 0 ) {return; }
chooseTile(msg, "R", 1);
return;
case "!rght_5":
if ( pathCheck(dungeonReadyID) != 0 ) {return; }
chooseTile(msg, "R", 5);
return;
}
},
lightFeatures = function(dungeonReadyID) {
var featureGraphics, featurePathArray, foundFeature;
errorArray = new Array();
checkOrGetTableData("Dungeon-Ready-Elements",dungeonReadyElements);
featureGraphics = findObjs({_pageid: dungeonReadyID, _type: "graphic", name: "Feature", layer: "map", });
if (featureGraphics.length === 0) {
errorArray.push({
typeError: "Warning",
textError: "No <B>FEATURES</B> foundon the <b>Map Layer.</b>"
});
messageErrors();
return;
}
featurePathArray = new Array();
_.each(featureGraphics, function(featureGraphicsEach) {
foundFeature = _.where(dungeonReadyTilesArray, {tileURL: featureGraphicsEach.get("imgsrc").replace("med.","thumb.")});
switch (foundFeature[0].tileName) {
case "Torch_On":
featureGraphicsEach.set({"light_radius": 60, "light_dimradius": 20, "light_otherplayers": true, "layer": "objects", "name": "dungeonreadytorch", "bar1_value": "1"});
break;
case "Torch_Off":
featureGraphicsEach.set({"layer": "objects", "name": "dungeonreadytorch", "bar1_value": "0"});
break;
case "Door":
featureGraphicsEach.set({ "layer": "objects", "name": "dungeonreadydoor", "bar1_value": "1"});
case "Door_Barred":
featureGraphicsEach.set({ "layer": "objects", "name": "dungeonreadydoor"});
featurePathArray.push({
width: featureGraphicsEach.get("width"),
height: featureGraphicsEach.get("height"),
top: featureGraphicsEach.get("top"),
left: featureGraphicsEach.get("left"),
rotation: featureGraphicsEach.get("rotation"),
fliph: featureGraphicsEach.get("fliph"),
flipv: featureGraphicsEach.get("flipv"),
path: [[34,18],[34,262]],
stroke: "#00ff00",
strokewidth: 1
});
break;
case "Stairwell_Up":
case "Stairwell_Down":
featurePathArray.push({
width: featureGraphicsEach.get("width"),
height: featureGraphicsEach.get("height"),
top: featureGraphicsEach.get("top"),
left: featureGraphicsEach.get("left"),
rotation: featureGraphicsEach.get("rotation"),
fliph: featureGraphicsEach.get("fliph"),
flipv: featureGraphicsEach.get("flipv"),
path: [[20,35],[105,35],[105,245],[20,245]],
stroke: "#00ffff",
strokewidth: 5
});
break;
case "Stairs_Down_Wall":
case "Stairs_Up_Wall":
featurePathArray.push({
width: featureGraphicsEach.get("width"),
height: featureGraphicsEach.get("height"),
top: featureGraphicsEach.get("top"),
left: featureGraphicsEach.get("left"),
rotation: featureGraphicsEach.get("rotation"),
fliph: featureGraphicsEach.get("fliph"),
flipv: featureGraphicsEach.get("flipv"),
path: [[104,21],[104,258]],
stroke: "#00ffff",
strokewidth: 5
});
break;
}
});
placeRotatedFlipPaths(featurePathArray);
},
placeRotatedFlipPaths = function(givenPathData) {
var temp, i, newX, newY, inputPath, angle, Xoffset, Yoffset, PathArray, maxX, minX, maxY, minY, objectWidth, objectHeight,
objectTop, objectLeft, pathString
_.each(givenPathData, function(given) {
temp = [];
for(i = 0; i < given.path.length; i++) {
newX = given.path[i][0];
newY = given.path[i][1];
if(given.fliph){newX = given.width - given.path[i][0]; }
if(given.flipv){newY = given.height - given.path[i][1]; }
temp.push([newX, newY]);
}
given.path = temp;
inputPath = given.path;
angle = given.rotation;
Xoffset = given.left - (given.width/2);
Yoffset = given.top - (given.height/2);
PathArray = [];
if(!angle) angle = 0;
if(!Xoffset) Xoffset = 0;
if(!Yoffset) Yoffset = 0;
maxX = 0;
minX = false;
maxY = 0;
minY = false;
for(i = 0; i < inputPath.length; i++) {
PathArray.push([inputPath[i][0], inputPath[i][1]]);
PathArray[i] = pathingRotation(angle, PathArray[i],given.width,given.height);
if(PathArray[i][0] > maxX) maxX = PathArray[i][0];
if(minX === false || Number(PathArray[i][0]) < Number(minX)) minX = PathArray[i][0];
if(PathArray[i][1] > maxY) maxY = PathArray[i][1];
if(minY === false || PathArray[i][1] < minY) minY = PathArray[i][1];
}
objectWidth = maxX - minX;
objectHeight = maxY - minY;
objectTop = minY + (objectHeight/2);
objectLeft = minX + (objectWidth/2);
for(i = 0; i < PathArray.length; i++) {
PathArray[i][0] = PathArray[i][0] - minX;
PathArray[i][1] = PathArray[i][1] - minY;
}
pathString = "";
for(i = 0; i < PathArray.length; i++) {
if(i != 0) {
pathString += ",[\"L\"," + PathArray[i][0] + "," + PathArray[i][1] + "]";
} else {
pathString = "[\[\"M\"," + PathArray[i][0] + "," + PathArray[i][1] + "]";
}
}
pathString += "\]";
objectTop = objectTop + Yoffset;
objectLeft = objectLeft + Xoffset;
given.path = pathString;
given.left = objectLeft;
given.top = objectTop;
createObj("path",{
pageid: Campaign().get("playerpageid"),
layer: "walls",
path: given.path,
left: given.left,
top: given.top,
width: objectWidth,
height: objectHeight,
rotation: 0,
fliph: false,
flipv: false,
stroke: given.stroke,
stroke_width: given.strokewidth,
});
});
},
pathingRotation = function(angle, point,width,height) {
var pointX = point[0], pointY = point[1], originX = (width/2), originY = (height/2);
angle = angle * Math.PI / 180.0;
return [
Math.cos(angle) * (pointX-originX) - Math.sin(angle) * (pointY-originY) + originX,
Math.sin(angle) * (pointX-originX) + Math.cos(angle) * (pointY-originY) + originY
];
},
chooseTile = function(msg, direction, step) {
var selectedObjs = msg.selected, obj = _.first(selectedObjs), token, sideArray, currentSide, newURL, findFeature;
if (obj._type == "graphic") {
token = getObj("graphic", obj._id);
sideArray = token.get("sides").split("|");
currentSide = token.get("currentSide");
if (direction == "L") {
currentSide = currentSide - step;
if (currentSide < 0 ) { currentSide = sideArray.length + currentSide; }
}
if (direction == "R") {
currentSide = currentSide + step;
if (currentSide > (sideArray.length - 1) ) { currentSide = currentSide - sideArray.length; }
}
newURL = sideArray[currentSide];
token.set({"imgsrc": newURL, "currentSide": currentSide});
}
if (token.get("name") == "Feature") {
checkOrGetTableData("Dungeon-Ready-Elements",dungeonReadyElements);
findFeature = _.where(dungeonReadyTilesArray, {tileURL: newURL});
token.set({"height": findFeature[0].tileHeight, "width": findFeature[0].tileWidth});
}
if (token.get("name") == "GMlabel") {
checkOrGetTableData("GM_Labels",dungeonReadyGMlabels);
findFeature = _.where(dungeonReadyTilesArray, {tileURL: newURL});
token.set({"height": findFeature[0].tileHeight, "width": findFeature[0].tileWidth});
}
},
deletePaths = function(msg,dungeonReadyPage,dungeonReadyID) {
var message = msg.content.split(" "), value = message[1].toLowerCase(), firstLetter = value.charAt(0), tossedPaths,
trashbin, pathsDL;
if (firstLetter != "y") {return; }
tossedPaths = findObjs({
_pageid: dungeonReadyID,
_type: "path",
layer: "objects",
stroke: "#ffffff",
});
if (tossedPaths.length >= 400) {
errorArray.push({
typeError: "Critical",
textError: "Trash Bin is full, please <b>DELETE the Trash Bin and all Paths beneath it.</b>"
});
trashbin = findObjs({
_pageid: dungeonReadyID,
_type: "graphic", name: "TrashBin"
});
if (trashbin.length == 0) {
marker = createObj("graphic", {
name: "TrashBin",
_type: "graphic",
_subtype: "token",
_pageid: dungeonReadyID,
layer: "objects",
width: 70,
height: 70,
left: Math.round(dungeonReadyPage[0].get("width")*70) - 105,
top: 105,
imgsrc: "https://s3.amazonaws.com/files.d20.io/images/6480696/rWlOt_7lJvZLSHKwAEnK4g/thumb.png?1416921531",
rotation: 0,
light_radius: -1,
light_otherplayers: true
});
marker = fixNewObject(marker);
}
messageErrors();
return;
}
pathsDL = findObjs({_pageid: dungeonReadyID, _type: "path", stroke: "#00ffff", layer: "walls"});
if (pathsDL.length != 0) {
_.each(pathsDL, function(obj) {
obj.set({
layer: "objects",
width: 70,
height: 70,
stroke: "#ffffff",
scaleX: .01,
scaleY: .01,
top: 105,
left: Math.round(dungeonReadyPage[0].get("width")*70) - 105
});
});
trashbin = findObjs({
_pageid: dungeonReadyID,
_type: "graphic", name: "TrashBin"
});
if (trashbin.length == 0) {
fixNewObject(createObj("graphic", {
name: "TrashBin",
_type: "graphic",
_subtype: "token",
_pageid: dungeonReadyID,
layer: "objects",
width: 70,
height: 70,
left: Math.round(dungeonReadyPage[0].get("width")*70) - 105,
top: 105,
imgsrc: "https://s3.amazonaws.com/files.d20.io/images/6480696/rWlOt_7lJvZLSHKwAEnK4g/thumb.png?1416921531",
rotation: 0,
light_radius: -1,
light_otherplayers: true
}));
}
sendChat('','/direct '
+'<div style="padding:1px 3px;border: 1px solid #00529B; background: #BDE5F8; color: #00529B; font-size: 80%;">'
+'<img src="https://s3.amazonaws.com/files.d20.io/images/6422881/TSnHqUi-Y3TjRjqM1P_GsQ/thumb.png?1416499690" style="vertical-align: text-bottom; width:20px; height:20px; padding: 0px 5px;" />'
+'Paths sent to <b>Object Layer Trash-Bin.</b>'
);
return;
}
sendChat('','/direct '
+'<div style="padding:1px 3px;border: 1px solid #9F6000; background: #FEEFB3; color: #9F6000; font-size: 80%;">'
+'<img src="https://s3.amazonaws.com/files.d20.io/images/6422879/M-oWEvMt1bhC2M-bdi28tA/thumb.png?1416499678" style="vertical-align: text-bottom; width:20px; height:20px; padding: 0px 5px;" />'
+'No Dynamic Lighting paths found to move.'
);
},
addGMlabel = function(msg,dungeonReadyPage,dungeonReadyID) {
var message = msg.content.split(" "), value = message[1].toLowerCase(), firstLetter = value.charAt(0),
rightLetters = value.substring(1), number = parseInt(value), label = "Label_1", checkDungeonReadyElements,
featuresString, foundlabel, labelURL, labelW, labelH, featuresStringArray, inArrayAt;
switch (firstLetter) {
case "a":
case "b":
case "c":
case "d":
case "e":
case "f":
case "g":
case "h":
case "i":
case "j":
label = "Label_" + firstLetter
break;
case "l":
label = "Label_Level_" + rightLetters
break;
default:
label = "Label_" + number
}
checkDungeonReadyElements = checkOrGetTableData("GM_Labels",dungeonReadyGMlabels);
foundlabel = _.where(dungeonReadyTilesArray, {tileName: label});
labelURL = foundlabel[0].tileURL;
labelW = foundlabel[0].tileWidth;
labelH = foundlabel[0].tileHeight;
featuresString = checkDungeonReadyElements.sideString;
featuresStringArray = featuresString.split("|");
inArrayAt = featuresStringArray.indexOf(labelURL);
fixNewObject(createObj("graphic", {
name: "GMlabel",
_type: "graphic",
_subtype: "token",
_pageid: dungeonReadyID,
layer: "gmlayer",
width: labelW,
height: labelH,
left: Math.round(dungeonReadyPage[0].get("width")*35),
top: Math.round(dungeonReadyPage[0].get("height")*35),
imgsrc: labelURL,
rotation: 0,
sides: featuresString,
currentSide: inArrayAt
}));
sendChat('','/direct '
+'<div style="padding:1px 3px;border: 1px solid #4F8A10; background: #DFF2BF; color: #4F8A10; font-size: 80%;">'
+'<img src="https://s3.amazonaws.com/files.d20.io/images/6422883/Mvzm968Oeumx6UfTlkOMfQ/thumb.png?1416499707" style="vertical-align: text-bottom; width:20px; height:20px; padding: 0px 5px;" />'
+'GM Label added. Located in the center of the map on the GM Layer!'
);
},
addGMfeature = function(dungeonReadyPage,dungeonReadyID) {
var checkDungeonReadyElements = checkOrGetTableData("GM_Special",dungeonReadyGMspecial),
featuresString = checkDungeonReadyElements.sideString,
featuresStringArray = featuresString.split("|"),
firstURL = featuresStringArray[0];
fixNewObject(createObj("graphic", {
name: "GMFeature",
_type: "graphic",
_subtype: "token",
_pageid: dungeonReadyID,
layer: "gmlayer",
width: checkDungeonReadyElements.firstWidth,
height: checkDungeonReadyElements.firstHeight,
left: Math.round(dungeonReadyPage[0].get("width")*35),
top: Math.round(dungeonReadyPage[0].get("height")*35),
imgsrc: firstURL,
rotation: 0,
sides: featuresString,
currentSide: 0
}));
sendChat('','/direct '
+'<div style="padding:1px 3px;border: 1px solid #4F8A10; background: #DFF2BF; color: #4F8A10; font-size: 80%;">'
+'<img src="https://s3.amazonaws.com/files.d20.io/images/6422883/Mvzm968Oeumx6UfTlkOMfQ/thumb.png?1416499707" style="vertical-align: text-bottom; width:20px; height:20px; padding: 0px 5px;" />'
+'GM Feature added. Located in the center of the map on the GM Layer!'
);
},
checkSelect = function(obj,type,command) {
var token;
errorArray = new Array();
if (obj == undefined || obj.length < 1) {
errorArray.push({
typeError: "Warning",
textError: "Please <b>SELECT A TILE</b> on the map layer."
});
messageErrors();
return false;
}
if (obj._type != type) {
errorArray.push({
typeError: "Warning",
textError: "Please <b>SELECT A TILE</b> on the map layer."
});
messageErrors();
return false;
}
if (command == "add") {
token = getObj('graphic', obj._id);
if (token.get("layer") != "map") {
errorArray.push({
typeError: "Warning",
textError: "Please <b>SELECT A TILE</b> on the map layer."
});
messageErrors();
return false;
}
}
return true;
},
addfeature = function(playerid,obj,command,dungeonReadyID) {
var checkDungeonReadyElements = checkOrGetTableData("Dungeon-Ready-Elements",dungeonReadyElements),
featuresString = checkDungeonReadyElements.sideString, token = getObj('graphic', obj._id),
featuresStringArray, firstURL, marker;
if (command == "add") {
featuresStringArray = featuresString.split("|");
firstURL = featuresStringArray[0];
marker = createObj("graphic", {
name: "Feature",
_type: "graphic",
_subtype: "token",
_pageid: dungeonReadyID,
layer: "map",
width: checkDungeonReadyElements.firstWidth,
height: checkDungeonReadyElements.firstHeight,
left: Math.round(token.get("left")),
top: Math.round(token.get("top")),
imgsrc: firstURL,
rotation: 0,
sides: featuresString,
currentSide: 0
});
marker = fixNewObject(marker);
toFront(marker);
}
if (command == "pst") {
marker = createObj("graphic", {
name: "Feature",
_type: "graphic",
_subtype: "token",
_pageid: dungeonReadyID,
layer: token.get("layer"),
width: token.get("width"),
height: token.get("height"),
left: Math.round(token.get("left") + 35),
top: Math.round(token.get("top") + 35),
imgsrc: token.get("imgsrc"),
rotation: token.get("rotation"),
sides: token.get("sides"),
currentSide: token.get("currentSide"),
light_radius: token.get("light_radius"),
light_dimradius: token.get("light_dimradius"),
light_otherplayers: token.get("light_otherplayers")
});
marker = fixNewObject(marker);
toFront(marker);
}
sendChat('','/direct '
+'<div style="padding:1px 3px;border: 1px solid #00529B; background: #BDE5F8; color: #00529B; font-size: 80%;">'
+'<img src="https://s3.amazonaws.com/files.d20.io/images/6422881/TSnHqUi-Y3TjRjqM1P_GsQ/thumb.png?1416499690" style="vertical-align: text-bottom; width:20px; height:20px; padding: 0px 5px;" />'
+'Element added! <b>SELECT</b> the new element to edit or move it.</b>'
);
},
tofromGM = function(dungeonReadyID) {
var pathsDL = findObjs({_pageid: dungeonReadyID, _type: "path", stroke: "#00ffff", layer: "walls"});
if (pathsDL.length != 0) {
_.each(pathsDL, function(obj) {obj.set("layer", "gmlayer"); });
sendChat('','/direct '
+'<div style="padding:1px 3px;border: 1px solid #00529B; background: #BDE5F8; color: #00529B; font-size: 80%;">'
+'<img src="https://s3.amazonaws.com/files.d20.io/images/6422881/TSnHqUi-Y3TjRjqM1P_GsQ/thumb.png?1416499690" style="vertical-align: text-bottom; width:20px; height:20px; padding: 0px 5px;" />'
+'Paths sent to <b>GM Information Layer.</b>'
);
return;
}
pathsDL = findObjs({_pageid: dungeonReadyID, _type: "path", stroke: "#00ffff", layer: "gmlayer"});
if (pathsDL.length != 0) {
_.each(pathsDL, function(obj) {obj.set("layer", "walls"); });
sendChat('','/direct '
+'<div style="padding:1px 3px;border: 1px solid #00529B; background: #BDE5F8; color: #00529B; font-size: 80%;">'
+'<img src="https://s3.amazonaws.com/files.d20.io/images/6422881/TSnHqUi-Y3TjRjqM1P_GsQ/thumb.png?1416499690" style="vertical-align: text-bottom; width:20px; height:20px; padding: 0px 5px;" />'
+'Paths sent to <b>Dynamic Lighting Layer.</b>'
);
return;
}
sendChat('','/direct '
+'<div style="padding:1px 3px;border: 1px solid #9F6000; background: #FEEFB3; color: #9F6000; font-size: 80%;">'
+'<img src="https://s3.amazonaws.com/files.d20.io/images/6422879/M-oWEvMt1bhC2M-bdi28tA/thumb.png?1416499678" style="vertical-align: text-bottom; width:20px; height:20px; padding: 0px 5px;" />'
+'No auto created Dynamic Lighting paths found to move.'
);
},
setPaths = function(playerid,dungeonReadyPage,dungeonReadyID) {
var mapcheck, pageID, pageWidth, pageHeight, checkDungeonReadyTiles, currentPageGraphics, lightArray = new Array(),
tileData, pathArray = new Array(), pathString, tileString, n, givenVflip, givenHflip, unflippedPath, PathArray,
i, newX, newY, inputPath, angle, Xoffset, Yoffset;
mapcheck = checkMapGraphicsPaths();
pageID = mapcheck.dungeonReadyPageID;
pageWidth = mapcheck.dungeonReadyMapWidth;
pageHeight = mapcheck.dungeonReadyMapHeight;
checkDungeonReadyTiles = checkOrGetTableData("Dungeon-Ready-Tiles",dungeonReadyTiles);
currentPageGraphics = findObjs({_pageid: pageID, layer: "map", width: 840, height: 840});
lightArray = new Array();
_.each(currentPageGraphics, function(obj) {
tileData = _.where(dungeonReadyTilesArray, {tileURL: obj.get("imgsrc").replace("med.","thumb.")});
if (tileData.length != 0) {
lightArray.push({
tileName: tileData[0].tileName.slice(-4),
left: obj.get("left"),
top: obj.get("top"),
rotation: obj.get("rotation"),
flipv: obj.get("flipv"),
fliph: obj.get("fliph")
});
}
})
pathArray = new Array();
_.each(lightArray, function(lightArrayEach) {
_.each(dynamicLightingArray, function(dynamicLightingArrayEach) {
pathString = dynamicLightingArrayEach.tileName;
tileString = lightArrayEach.tileName
n = pathString.indexOf(tileString)
if(n != -1){
pathArray.push({
left: lightArrayEach.left,
top: lightArrayEach.top,
rotation: lightArrayEach.rotation,
path: dynamicLightingArrayEach.path,
flipv: lightArrayEach.flipv,
fliph: lightArrayEach.fliph
});
};
});
});
_.each(pathArray, function(pathArrayEach) {
givenVflip = pathArrayEach.flipv;
givenHflip = pathArrayEach.fliph;
unflippedPath = pathArrayEach.path;
PathArray = [];
for(i = 0; i < unflippedPath.length; i++) {
newX = unflippedPath[i][0]
newY = unflippedPath[i][1]
if(givenHflip){
newX = 840 - unflippedPath[i][0]
}
if(givenVflip){
newY = 840 - unflippedPath[i][1]
}
PathArray.push([newX, newY]);
};
inputPath = PathArray;
angle = pathArrayEach.rotation;
Xoffset = pathArrayEach.left - 420;
Yoffset = pathArrayEach.top - 420;
createPath(inputPath, angle, Xoffset, Yoffset, pageID);
});
sendChat('','/direct '
+'<div style="padding:1px 3px;border: 1px solid #4F8A10; background: #DFF2BF; color: #4F8A10; font-size: 80%;">'
+'<img src="https://s3.amazonaws.com/files.d20.io/images/6422883/Mvzm968Oeumx6UfTlkOMfQ/thumb.png?1416499707" style="vertical-align: text-bottom; width:20px; height:20px; padding: 0px 5px;" />'
+'Dynamic Lighting add based on the map tiles! <b>"Lighting-To-From-GM-Layer"</b> can be used to move auto created Dynamic Lighting paths to and from the GM Layer to make it easy to add custom or addtional pathing lines.'
);
},
createPath = function(inputPath, angle, Xoffset, Yoffset, pageID) {
var PathArray = [], maxX = 0, minX = false, maxY = 0, minY = false, i, objectWidth, objectHeight, objectTop,
objectLeft, pathString = "";
if(!angle) angle = 0;
if(!Xoffset) Xoffset = 0;
if(!Yoffset) Yoffset = 0;
for(i = 0; i < inputPath.length; i++) {
PathArray.push([inputPath[i][0], inputPath[i][1]]);
PathArray[i] = pathingRotation(angle, PathArray[i], 840, 840);
if(PathArray[i][0] > maxX) maxX = PathArray[i][0];
if(minX === false || Number(PathArray[i][0]) < Number(minX)) minX = PathArray[i][0];
if(PathArray[i][1] > maxY) maxY = PathArray[i][1];
if(minY === false || PathArray[i][1] < minY) minY = PathArray[i][1];
}
objectWidth = maxX - minX;
objectHeight = maxY - minY;
objectTop = minY + (objectHeight/2);
objectLeft = minX + (objectWidth/2);
for(i = 0; i < PathArray.length; i++) {
PathArray[i][0] = PathArray[i][0] - objectLeft + (objectWidth/2);
PathArray[i][1] = PathArray[i][1] - objectTop + (objectHeight/2);
}
pathString = "";
for(i = 0; i < PathArray.length; i++) {
if(i != 0) {
pathString += ",[\"L\"," + PathArray[i][0] + "," + PathArray[i][1] + "]";
} else {
pathString = "[\[\"M\"," + PathArray[i][0] + "," + PathArray[i][1] + "]";
}
}
pathString += "\]";
objectTop = objectTop + Yoffset;
objectLeft = objectLeft + Xoffset;
fixNewObject(createObj("path",{
layer: "walls",
_path: pathString,
width: objectWidth,
height: objectHeight,
top: objectTop,
left: objectLeft,
rotation: 0,
stroke: lineColor,
pageid: pageID,
stroke_width: lineSize
}));
},
mapdungeon = function(playerid) {
var errorDetails = setupDungeonGenerator(false,playerid), checkDungeonReadyTiles, checkDungeonReadyMapGraphicsPaths,
numberTileRows, numberTileCols, mapID, possibleTiles, randomTile, i, j, stepRight, stepDown, left, top, tileToPlace;
mapTileTracker = [];
if (true == errorDetails.mapError || errorDetails.imgError || errorDetails.pthError) {
sendChat('','/direct '
+'<div style="padding:1px 3px;border: 1px solid #FF0000; background: #FFBABA; color: #D8000C; font-size: 80%;">'
+'<img src="https://s3.amazonaws.com/files.d20.io/images/6422880/SIjBHWJNC8f9a73Rg_VkOQ/thumb.png?14164996807" style="vertical-align: text-bottom; width:20px; height:20px; padding: 0px 5px;" />'
+'<b>Script Halted.</b> Please correct any critical errors and/or warnings.'
);
return;
}
checkDungeonReadyTiles = checkOrGetTableData("Dungeon-Ready-Tiles",dungeonReadyTiles);
checkDungeonReadyMapGraphicsPaths = checkMapGraphicsPaths();
numberTileRows = (checkDungeonReadyMapGraphicsPaths.dungeonReadyMapHeight / 12) - 1;
numberTileCols = (checkDungeonReadyMapGraphicsPaths.dungeonReadyMapWidth / 12) - 1;
mapID = checkDungeonReadyMapGraphicsPaths.dungeonReadyPageID;
for(i=0; i < (numberTileCols + 1); i++){mapTileTracker.push([]); mapTileTracker[i].push( new Array((numberTileRows + 1)));
for(j=0; j < (numberTileRows + 1); j++){
mapTileTracker[i][j] = {
tileName: dungeonReadyTilesArray[0].tileName,
tileURL: dungeonReadyTilesArray[0].tileURL,
tileRotation: dungeonReadyTilesArray[0].rotation,
tileVflip: dungeonReadyTilesArray[0].tileVflip,
tileHflip: dungeonReadyTilesArray[0].tileHflip,
tileWidth: 840,
tileHeight: 840,
tileSides: dungeonReadyTilesArray[0].tileSides,
tileCurrent: dungeonReadyTilesArray[0].tileCurrent,
tileWeight: dungeonReadyTilesArray[0].tileWeight
};
};
};
possibleTiles = _.where(dungeonReadyTilesArray, {corner: true});
randomTile = tileSelector(possibleTiles, "TopLeft",0,0);
possibleTiles = _.where(dungeonReadyTilesArray, {corner: true});
randomTile = tileSelector(possibleTiles, "TopRight",numberTileCols,0);
possibleTiles = _.where(dungeonReadyTilesArray, {corner: true});
randomTile = tileSelector(possibleTiles, "BottomRight",0,numberTileRows);
possibleTiles = _.where(dungeonReadyTilesArray, {corner: true});
randomTile = tileSelector(possibleTiles, "BottomLeft",numberTileCols,numberTileRows);
possibleTiles = _.where(dungeonReadyTilesArray, {edge: true});
for (stepRight=1;stepRight<numberTileCols;stepRight++){
randomTile = tileSelector(possibleTiles, "edgeTop",stepRight,0);
};
possibleTiles = _.where(dungeonReadyTilesArray, {edge: true});
for (stepRight=1;stepRight<numberTileCols;stepRight++){
randomTile = tileSelector(possibleTiles, "edgeBottom",stepRight,numberTileRows);
};
possibleTiles = _.where(dungeonReadyTilesArray, {edge: true});
for (stepDown=1;stepDown<numberTileRows;stepDown++){
randomTile = tileSelector(possibleTiles, "edgeLeft",0,stepDown);
};
possibleTiles = _.where(dungeonReadyTilesArray, {edge: true});
for (stepDown=1;stepDown<numberTileRows;stepDown++){
randomTile = tileSelector(possibleTiles, "edgeRight",numberTileCols,stepDown);
};
possibleTiles = _.where(dungeonReadyTilesArray, {edge: false, corner: false});
for (i=1;i<numberTileCols;i++){
for (j=1;j<numberTileRows;j++){
randomTile = tileSelector(possibleTiles, "edgeRight",i,j)
};
};
for (i=0;i<numberTileCols + 1;i++){
for (j=0;j<numberTileRows + 1;j++){
left = (i * 840) + 420;
top = (j * 840) + 420;
tileToPlace = {
name: mapTileTracker[i][j].tileName,
pageid: mapID,
layer: "map",
width: mapTileTracker[i][j].tileWidth,
height: mapTileTracker[i][j].tileHeight,
left: left,
top: top,
imgsrc: mapTileTracker[i][j].tileURL,
rotation :mapTileTracker[i][j].tileRotation,
flipv: mapTileTracker[i][j].tileVflip,
fliph: mapTileTracker[i][j].tileHflip,
sides: mapTileTracker[i][j].tileSides,
currentSide: mapTileTracker[i][j].tileCurrent,
tileWeight: mapTileTracker[i][j].tileWeight
};
placeObject(tileToPlace)
};
};
sendChat('','/direct '
+'<div style="padding:1px 3px;border: 1px solid #4F8A10; background: #DFF2BF; color: #4F8A10; font-size: 80%;">'
+'<img src="https://s3.amazonaws.com/files.d20.io/images/6422883/Mvzm968Oeumx6UfTlkOMfQ/thumb.png?1416499707" style="vertical-align: text-bottom; width:20px; height:20px; padding: 0px 5px;" />'
+'Map complete! Please edit the map or add addtional elements. <b>SELECT A MAP TILE</b> to add elements or edit the map tile.'
);
},
tileSelector = function(tiles, whereAt,i,j) {
var tilePickedRotation = 0, tilePickedVflip, tilePickedHflip, randomPick, rarityValue, rartityChance,
tilePickedRotation = Math.floor(Math.random() * 4) * 90, tries = 0, tilePicked = -1;
if (Math.random() > 0.5) {tilePickedVflip = false; } else {tilePickedVflip = true; }
if (Math.random() > 0.5) {tilePickedHflip = false; } else { tilePickedHflip = true; }
switch(whereAt) {
case "TopLeft":
tilePickedRotation = 0;
tilePickedVflip = true;
tilePickedHflip = true;
break;
case "TopRight":
tilePickedRotation = 0;
tilePickedVflip = true;
tilePickedHflip = false;
break;
case "BottomLeft":
tilePickedRotation = 0;
tilePickedVflip = false;
tilePickedHflip = false;
break;
case "BottomRight":
tilePickedRotation = 0;
tilePickedVflip = false;
tilePickedHflip = true;
break;
case "edgeTop":
tilePickedRotation = 270;
tilePickedHflip = false;
break;
case "edgeBottom":
tilePickedRotation = 90;
tilePickedHflip = false;
break;
case "edgeLeft":
tilePickedRotation = 0;
tilePickedHflip = true;
break;
case "edgeRight":
tilePickedRotation = 0;
tilePickedHflip = false;
break;
}
while ((tilePicked == -1) && (tries < 20)){
tries++
randomPick = Math.floor(Math.random() * tiles.length);
rarityValue = tiles[randomPick].tileWeight;
rartityChance = Math.floor(Math.random() * 100) + 1;
if(rartityChance <= rarityValue){
tilePicked = randomPick;
}
};
if (tilePicked == -1) {
randomPick = Math.floor(Math.random() * tiles.length);
}
mapTileTracker[i][j] = {
tileName: tiles[randomPick].tileName,
tileURL: tiles[randomPick].tileURL,
tileRotation: tilePickedRotation,
tileVflip: tilePickedVflip,
tileHflip: tilePickedHflip,
tileWidth: 840,
tileHeight: 840,
tileSides: tiles[randomPick].tileSides,
tileCurrent: tiles[randomPick].tileCurrent,
tileWeight: tiles[randomPick].tileWeight
};
},
setupDungeonGenerator = function(fullSetup,playerid) {
var errorDetails;
errorArray = new Array();
checkOrGetTableData("Dungeon-Ready-Tiles",dungeonReadyTiles);
checkOrGetTableData("Dungeon-Ready-Elements",dungeonReadyElements);
checkOrGetTableData("GM_Special",dungeonReadyGMspecial);
checkOrGetTableData("GM_Labels",dungeonReadyGMlabels);
checkMapGraphicsPaths();
if (true == fullSetup) {
createHandOuts(playerid);
createMacros(playerid);
}
errorDetails = messageErrors();
if (true == fullSetup) {
if (true == errorDetails.mapError || errorDetails.imgError || errorDetails.pthError) {
sendChat('','/direct '
+'<div style="padding:1px 3px;border: 1px solid #FF0000; background: #FFBABA; color: #D8000C; font-size: 80%;">'
+'<img src="https://s3.amazonaws.com/files.d20.io/images/6422880/SIjBHWJNC8f9a73Rg_VkOQ/thumb.png?14164996807" style="vertical-align: text-bottom; width:20px; height:20px; padding: 0px 5px;" />'
+'<b>Script Halted.</b> Please correct any critical errors and/or warnings.'
);
} else {
sendChat('','/direct '
+'<div style="padding:1px 3px;border: 1px solid #4F8A10; background: #DFF2BF; color: #4F8A10; font-size: 80%;">'
+'<img src="https://s3.amazonaws.com/files.d20.io/images/6422883/Mvzm968Oeumx6UfTlkOMfQ/thumb.png?1416499707" style="vertical-align: text-bottom; width:20px; height:20px; padding: 0px 5px;" />'
+'Setup complete!'
);
}
}
return {
mapError: errorDetails.mapError,
imgError: errorDetails.imgError,
pthError: errorDetails.pthError,
infError: errorDetails.infError
};
},
messageErrors = function(){
var mapError = false, imgError = false, pthError = false, infError = false;
_.each(errorArray, function(errorArrayEach) {
switch (errorArrayEach.detailError) {
case "Map": mapError = true; break;
case "Image": imgError = true; break;
case "Paths": pthError = true; break;
case "Information": infError = true; break;
}
switch (errorArrayEach.typeError) {
case "Critical":
sendChat('','/direct '
+'<div style="padding:1px 3px;border: 1px solid #FF0000; background: #FFBABA; color: #D8000C; font-size: 80%;">'
+'<img src="https://s3.amazonaws.com/files.d20.io/images/6422880/SIjBHWJNC8f9a73Rg_VkOQ/thumb.png?14164996807" style="vertical-align: text-bottom; width:20px; height:20px; padding: 0px 5px;" />'
+errorArrayEach.textError
);
break;
case "Warning":
sendChat('','/direct '
+'<div style="padding:1px 3px;border: 1px solid #9F6000; background: #FEEFB3; color: #9F6000; font-size: 80%;">'
+'<img src="https://s3.amazonaws.com/files.d20.io/images/6422879/M-oWEvMt1bhC2M-bdi28tA/thumb.png?1416499678" style="vertical-align: text-bottom; width:20px; height:20px; padding: 0px 5px;" />'
+errorArrayEach.textError
);
break;
case "Information":
sendChat('','/direct '
+'<div style="padding:1px 3px;border: 1px solid #00529B; background: #BDE5F8; color: #00529B; font-size: 80%;">'
+'<img src="https://s3.amazonaws.com/files.d20.io/images/6422881/TSnHqUi-Y3TjRjqM1P_GsQ/thumb.png?1416499690" style="vertical-align: text-bottom; width:20px; height:20px; padding: 0px 5px;" />'
+errorArrayEach.textError
);
break;
}
});
return {
mapError: mapError,
imgError: imgError,
pthError: pthError,
infError: infError
};
},
checkMapGraphicsPaths = function(){
var dungeonReadyPage = findObjs({ name: mapName, _type: "page"}), dungeonReadyPageID, dungeonReadyPageGraphics,
dungeonReadyMapWidth, dungeonReadyMapHeight;
if (dungeonReadyPage.length != 1) {
if (dungeonReadyPage.length > 1) {
errorArray.push({
typeError: "Critical",
textError: "More than one page named <b>'" + mapName + "'</b>. Please ensure there is only one page named " + mapName + ".",
detailError: "Map"
});
} else {
errorArray.push({
typeError: "Critical",
textError: "Campaign Page named <b>'" + mapName + "'</b> not found. Please add the <b>'" + mapName + "'</b> page to the campaign.",
detailError: "Map"
});
}
} else {
dungeonReadyPageID = dungeonReadyPage[0].get("_id");
dungeonReadyPageGraphics = findObjs({_pageid: dungeonReadyPageID, _type: "graphic"});
if (dungeonReadyPageGraphics.length !== 0) {
errorArray.push({
typeError: "Warning",
textError: mapName + " has images on it. Please remove the images.",
detailError: "Image"
});
}
dungeonReadyPageGraphics = findObjs({_pageid: dungeonReadyPageID, _type: "path"});
if (dungeonReadyPageGraphics.length !== 0) {
errorArray.push({
typeError: "Warning",
textError: mapName + " has paths on it. Please remove the paths.",
detailError: "Paths"
});
}
dungeonReadyMapWidth = dungeonReadyPage[0].get("width");
dungeonReadyMapHeight = dungeonReadyPage[0].get("height");
if (dungeonReadyMapWidth % 12 !== 0) {
errorArray.push({
typeError: "Warning",
textError: "Map <b>'WIDTH'</b> must be divisible by 12. Please change map <b>width.</b>",
detailError: "Map"
});
}
if (dungeonReadyMapHeight % 12 !== 0) {
errorArray.push({
typeError: "Warning",
textError: "Map <b>'HEIGHT'</b> must be divisible by 12. Please change map <b>height.</b>",
detailError: "Map"
});
}
if (dungeonReadyMapWidth < 36 || dungeonReadyMapHeight < 36) {
errorArray.push({
typeError: "Warning",
textError: "Map <b>'WIDTH'</b> and <b>'HEIGHT'</b> must be <b>'36'<b> or <b>larger</b>.",
detailError: "Map"
});
}
}
return {
dungeonReadyPageID: dungeonReadyPageID,
dungeonReadyMapWidth: dungeonReadyMapWidth,
dungeonReadyMapHeight: dungeonReadyMapHeight
};
},
checkOrGetTableData = function(tableName,arrayData){
var urlsExits = true, rollabletableItems, sideString = "", rollabletableID, chanceSelect, current = 0, edge = false,
corner = false, entrance = false, rollabletable = findObjs({ _type: "rollabletable", name: tableName});
dungeonReadyTilesArray = new Array();
if (rollabletable.length == 0) {
createObj("rollabletable", {name: tableName});
}
rollabletable = findObjs({ _type: "rollabletable", name: tableName});
rollabletableID = rollabletable[0].get("_id");
_.each(arrayData, function(obj) {
rollabletableItems = findObjs({_type: "tableitem", name: obj.name, _rollabletableid: rollabletableID});
if (rollabletableItems.length == 0) {
if (obj.connections != undefined) {
chanceSelect = (obj.connections + 1) * 10;
} else {
chanceSelect = 1;
}
createObj("tableitem", {name: obj.name, _rollabletableid: rollabletableID, weight: chanceSelect, avatar: leadingURL + obj.sample});
rollabletableItems = findObjs({_type: "tableitem", name: obj.name, _rollabletableid: rollabletableID});
urlsExits = false;
}
if (rollabletableItems[0].get("avatar").length == 0) {
rollabletableItems[0].set("avatar", leadingURL + obj.sample);
urlsExits = false;
}
sideString += rollabletableItems[0].get("avatar").replace("med.","thumb.")+"|"
});
sideString = sideString.slice(0,-1);
_.each(arrayData, function(obj) {
rollabletableItems = findObjs({_type: "tableitem", name: obj.name, _rollabletableid: rollabletableID});
if (obj.side == undefined ) {
current = 0;
edge = false;
corner = false;
entrance = false;
} else {
current = obj.side;
edge = obj.edge;
corner = obj.corner;
entrance = obj.entrance;
}
if (rollabletableItems[0].get("weight") != -1) {
dungeonReadyTilesArray.push({
tileName: obj.name,
tileURL: rollabletableItems[0].get("avatar").replace("med.","thumb."),
edge: edge,
corner: corner,
entrance: obj.entrance,
rotation: 0,
tileVflip: false,
tileHflip: false,
tileWidth: obj.width,
tileHeight: obj.height,
tileWeight: rollabletableItems[0].get("weight"),
tileSides: sideString,
tileCurrent: current
});
}
});
if (urlsExits === false) {
errorArray.push({
typeError: "Information",
textError: "One or more avatars are missing from the <b>'" + tableName + "'</b> rollable table (sample avatars provided as a substitute.)",
detailError: "Info"
});
}
return {
sideString: sideString,
firstURL: leadingURL + arrayData[0].sample.replace("med.","thumb."),
firstWidth: arrayData[0].width,
firstHeight: arrayData[0].height
};
},
createMacros = function(playerid) {
var macroString = "", dungeonReadyMacrosFound;
_.each(dungeonReadyMacros, function(obj) {
dungeonReadyMacrosFound = findObjs({ _type: "macro", name: obj.name});
if (dungeonReadyMacrosFound.length === 0) {
if (! obj.istokenaction) {
macroString += "<li>"+obj.name+"</li>";
}
createObj("macro", {
name: obj.name,
_playerid: playerid,
visibleto: playerid,
action: obj.action,
istokenaction: obj.istokenaction
});
}
});
if (macroString != "") {
errorArray.push({
typeError: "Information",
textError: "Please ensure the following Macros are in your Macro bar:<ul>"+macroString+"</ul>",
detailError: "Info"
});
}
},
pathCheck = function(dungeonReadyID) {
var pathsDL = findObjs({pageid: dungeonReadyID, type: "path", layer: "walls"});
if (pathsDL.length > 0) {
sendChat('','/direct '
+'<div style="padding:1px 3px;border: 1px solid #9F6000; background: #FEEFB3; color: #9F6000; font-size: 80%;">'
+'<img src="https://s3.amazonaws.com/files.d20.io/images/6422879/M-oWEvMt1bhC2M-bdi28tA/thumb.png?1416499678" style="vertical-align: text-bottom; width:20px; height:20px; padding: 0px 5px;" />'
+'Dynamic Lighting Layer must be free of paths.'
);
}
return pathsDL.length;
},
flipTile = function(msg, direction) {
var selectedObjs = msg.selected, obj = _.first(selectedObjs), token;
if ("graphic" === obj._type) {
token = getObj("graphic", obj._id);
token.set({
fliph: 'H' === direction ? !token.get('fliph') : token.get('fliph'),
flipv: 'H' !== direction ? !token.get('flipv') : token.get('flipv')
});
}
},
rotateTile = function(msg, degree) {
var selectedObjs = msg.selected, obj = _.first(selectedObjs), token;
if (obj._type == "graphic") {
token = getObj("graphic", obj._id);
token.set({rotation: token.get("rotation") + degree});
}
},
createHandOuts = function(playerid) {
var DungeonReadyAvatar = "6465213/59XklDtcSlkJO0PFyXOmlw/med.png?1416787536",
GMLegendAvatar = "6465227/hyBNAUkVJ1QAKL3qyQZV1w/med.png?1416787569";
if (findObjs({ type: "handout", name: "GM-Legend" }).length) {
return;
}
if (! findObjs({ type: "handout", name: "Dungeon-Ready" }).length) {
handoutMaker("Dungeon-Ready",DungeonReadyAvatar," ");
getObj("handout", findObjs({ type: "handout", name: "Dungeon-Ready" })[0].get("_id")).set(
"notes", "<a href='https://marketplace.roll20.net/browse/search/shomo/1'>Found on the Market Here.</a>"
);
}
handoutMaker("GM-Legend",GMLegendAvatar," ",playerid);
},
placeObject = function(objToPlace) {
fixNewObject(createObj("graphic", {
name: objToPlace.name,
type: "graphic",
subtype: "token",
pageid: objToPlace.pageid,
layer: objToPlace.layer,
width: objToPlace.width,
height: objToPlace.height,
left: objToPlace.left,
top: objToPlace.top,
imgsrc: objToPlace.imgsrc,
rotation: objToPlace.rotation,
flipv: objToPlace.flipv,
fliph: objToPlace.fliph,
sides: objToPlace.sides,
currentSide: objToPlace.currentSide
}));
},
handoutMaker = function(name,avatar,note,playerid) {
fixNewObject(createObj("handout", {
name: name,
avatar: "https://s3.amazonaws.com/files.d20.io/images/" + avatar,
notes: note
}));
},
fixNewObject = function(obj) {
var p = obj.changed._fbpath, new_p = p.replace(/([^\/]*\/){4}/, "/");
obj.fbpath = new_p;
return obj;
},
registerEventHandlers = function() {
on('chat:message', handleInput);
};
return {
RegisterEventHandlers: registerEventHandlers
};
}());
on("ready",function(){
'use strict';
DungeonReady.RegisterEventHandlers();
});
/* -------------------
Big thanks to:
createPath function was most helpfully provided by Alex L.
Wes for test GMing all my stuff!
"The Aaron" for enduring my endless questions and fixing my door lighting for me!!
All the API forum posters on Roll20!
Icons used error messages are from Knob Toolbar icons collection.
http://itweek.deviantart.com/art/Knob-Buttons-Toolbar-icons-73463960
Icons for trash can can be found here:
http://www.iconarchive.com/
------------------- */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment