Line 1: |
Line 1: |
| local p = {} | | local p = {} |
− | --local remiLib = require("Module:RemiLib")
| + | local remiLib = require("Module:RemiLib") |
| -- Module for enemy encounter tables written by | | -- Module for enemy encounter tables written by |
| -- Remi_Scarlet | | -- Remi_Scarlet |
Line 8: |
Line 8: |
| | | |
| -- checks if data is in the array as a key | | -- checks if data is in the array as a key |
− |
| |
− | function getLetterNum(x)
| |
− | local ab = mw.text.split(x, "-")
| |
− | return ab[2] and ab[1] or x:sub(1, 1), ab[2] and ab[2]:sub(1, 1) or x:sub(2, 2)
| |
− | end
| |
− |
| |
| function valid(data, array) | | function valid(data, array) |
| local valid = {} | | local valid = {} |
Line 89: |
Line 83: |
| -- actually discern what "map" it's being used on, I'm just using a hash function on the time of | | -- 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. | | -- rendering to replace the map identifier. |
− | local uniqueID = "" -- remiLib.timeHash(info) | + | local uniqueID = remiLib.timeHash(info) |
| | | |
| local classString = "mw-customtoggle-" .. tostring(uniqueID) | | local classString = "mw-customtoggle-" .. tostring(uniqueID) |
Line 351: |
Line 345: |
| for k,v in pairs(frame.args) do | | for k,v in pairs(frame.args) do |
| if string.lower(k) ~= "boss_node" and string.lower(k) ~= "final_form" and string.lower(k) ~= "post_final_form" then | | if string.lower(k) ~= "boss_node" and string.lower(k) ~= "final_form" and string.lower(k) ~= "post_final_form" then |
− | local letter, num = getLetterNum(k) | + | local letter = mw.text.split(k,"")[1] |
| + | local num = mw.text.split(k,"")[2] |
| + | if letter == 'z' then |
| + | val = string.find(k, "-") |
| + | if val ~= nil then |
| + | letter = mw.text.split(k, "-")[1] |
| + | num = mw.text.split(k, "")[val + 1] |
| + | end |
| + | end |
| if validNodeLetters[letter] and tonumber(num) ~= nil then | | if validNodeLetters[letter] and tonumber(num) ~= nil then |
| mapEncounterTable[letter] = {} | | mapEncounterTable[letter] = {} |
Line 377: |
Line 379: |
| -- nodePattern should be like A1_xp, B3_lv, C1_form or something | | -- nodePattern should be like A1_xp, B3_lv, C1_form or something |
| for nodePattern,patternInfo in pairs(frame.args) do | | for nodePattern,patternInfo in pairs(frame.args) do |
− | local letter, patternNum = getLetterNum(nodePattern) | + | local letter = mw.text.split(nodePattern,"")[1] |
| + | if letter == 'z' then |
| + | val = string.find(k, "-") |
| + | if val ~= nil then |
| + | letter = mw.text.split(k, "-")[1] |
| + | end |
| + | end |
| + | |
| if mapEncounterTable[letter] ~= nil and nodePattern ~= "final_form" and nodePattern ~= "post_final_form" then | | if mapEncounterTable[letter] ~= nil and nodePattern ~= "final_form" and nodePattern ~= "post_final_form" then |
| if mw.text.split(nodePattern,"")[2] ~= "_" then | | if mw.text.split(nodePattern,"")[2] ~= "_" then |
| + | local patternNum = mw.text.split(mw.text.split(nodePattern,"_")[1],"")[2] |
| | | |
| -- If the second char is not a number, invalid. | | -- If the second char is not a number, invalid. |
Line 686: |
Line 696: |
| return "Nil was passed instead of a string" | | return "Nil was passed instead of a string" |
| end | | end |
− | end
| |
− |
| |
− | function p.test()
| |
− | return p.encounterTemplate({
| |
− | args = {
| |
− | ["C_label"] = "C_label",
| |
− | ["C1_node_info"] = "C1_node_info",
| |
− | ["C1_form"] = "C1_form",
| |
− | ["C1_xp"] = "C1_xp",
| |
− | ["C1_enemy_air_power"] = "123",
| |
− | ["C2_node_info"] = "C2_node_info",
| |
− | ["C2_form"] = "C2_form",
| |
− | ["C2_xp"] = "C2_xp",
| |
− | ["C2_enemy_air_power"] = "123",
| |
− | ["ZZ3_label"] = "ZZ3-label",
| |
− | ["ZZ3-1_node_info"] = "ZZ3-1_node_info",
| |
− | ["ZZ3-1_form"] = "ZZ3-1_form",
| |
− | ["ZZ3-1_xp"] = "ZZ3-1_xp",
| |
− | ["ZZ3-1_enemy_air_power"] = "123",
| |
− | ["ZZ3-2_node_info"] = "ZZ3-2_node_info",
| |
− | ["ZZ3-2_form"] = "ZZ3-2_form",
| |
− | ["ZZ3-2_xp"] = "ZZ3-2_xp",
| |
− | ["ZZ3-2_enemy_air_power"] = "123",
| |
− | }
| |
− | })
| |
| end | | end |
| | | |
| return p | | return p |