Changes

no edit summary
Line 1: Line 1:  
local p = {}
 
local p = {}
 
+
local remiLib = require("Module:RemiLib")
 
-- Module for enemy encounter tables written by
 
-- Module for enemy encounter tables written by
 
-- Remi_Scarlet
 
-- Remi_Scarlet
 
-- I fucking hate lua.
 
-- I fucking hate lua.
 +
 +
-- 10/24/15 Added colorful blue button as per Wsewo's request.
    
-- checks if data is in the array as a key
 
-- checks if data is in the array as a key
Line 76: Line 78:  
         if bool then numCols = numCols + 1 end
 
         if bool then numCols = numCols + 1 end
 
     end
 
     end
     local body = mw.html.create("table")
+
   
     body
+
    -- Will be used to uniquely identify each table with the "button" and the "table content". Normally
 +
    -- this would be done with like mw-customtoggle-1-1-enemy or whatnot, but since I can't
 +
    -- actually discern what "map" it's being used on, I'm just using a hash function on the time of
 +
    -- rendering to replace the map identifier.
 +
    local uniqueID = remiLib.timeHash()
 +
   
 +
    local classString = "mw-customtoggle-" .. tostring(uniqueID)
 +
     local idString = "mw-customcollapsible-" .. tostring(uniqueID)
 +
   
 +
    local button = mw.html.create('div')
 +
    button
 +
    :addClass(classString)
 +
    :addClass("globalbutton")
 +
    :wikitext("Show/Hide Nodes and Enemy Encounters")
 +
 
 +
    local encounterTable = mw.html.create("table")
 +
     encounterTable
 +
        :addClass("mw-collapsible")
 
         :addClass("wikitable")
 
         :addClass("wikitable")
         :addClass("mw-collapsible")
+
         :addClass("mw-collapsed")
         :addClass("globalbutton")
+
         :attr("id",idString)
     if collapsed then
+
     -- if collapsed then
        body:addClass("mw-collapsed")
+
    --    encounterTable:addClass("mw-collapsed")
     end
+
     -- end
 
     local titleRow = mw.html.create("tr")
 
     local titleRow = mw.html.create("tr")
 
     local th = mw.html.create("th")
 
     local th = mw.html.create("th")
Line 91: Line 110:  
         :css("font-weight","bold")
 
         :css("font-weight","bold")
 
     titleRow:node(th)
 
     titleRow:node(th)
     body:node(titleRow)
+
     encounterTable:node(titleRow)
 
     local headerRow = mw.html.create("tr")
 
     local headerRow = mw.html.create("tr")
 
     th = mw.html.create("th")
 
     th = mw.html.create("th")
Line 120: Line 139:  
         headerRow:node(th)
 
         headerRow:node(th)
 
     end
 
     end
     body:node(headerRow)
+
     encounterTable:node(headerRow)
 
     local letterOrder = {"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"}
 
     local letterOrder = {"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"}
 
     for _,nodeLetter in pairs(letterOrder) do
 
     for _,nodeLetter in pairs(letterOrder) do
Line 195: Line 214:  
                 end
 
                 end
 
             end
 
             end
             body:node(firstRow)
+
             encounterTable:node(firstRow)
 
             -- Keep note that values is the table of node A
 
             -- Keep note that values is the table of node A
 
             -- Eg, {["1"]={
 
             -- Eg, {["1"]={
Line 257: Line 276:  
                     end
 
                     end
   −
                     body:node(row)
+
                     encounterTable:node(row)
 
                 end
 
                 end
 
             end
 
             end
 
         end
 
         end
 
     end
 
     end
     return tostring(body)
+
     return tostring(button) .. "\n" .. tostring(encounterTable)
 
end
 
end
  
2,922

edits