Skip to content

Instantly share code, notes, and snippets.

@simon-wh
Created February 15, 2017 13:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simon-wh/9fecf1efc5f1fb91c16273de4cd5deb8 to your computer and use it in GitHub Desktop.
Save simon-wh/9fecf1efc5f1fb91c16273de4cd5deb8 to your computer and use it in GitHub Desktop.
PD2 Script for outputting item information for wiki
------------ Skins ------------
local file = io.open("WikiInfo/skin_data.txt", "w+")
for id, skin in pairs(tweak_data.blackmarket.weapon_skins) do
file:write(id .. ":\n")
file:write(managers.localization:text(tweak_data.weapon[skin.weapon_id].name_id) .. " | " .. managers.localization:text(skin.name_id) .. "\n")
local desc = InventoryDescription.create_description_item({
instance_id = 0,
entry = id,
category = "weapon_skins",
quality = false,
bonus = true
},
skin,
{
default = tweak_data.screen_colors.text,
mods = tweak_data.screen_colors.text
},
false)
file:write(desc)
file:write("\n\n")
end
file:close()
------------ End Skins ------------
------------ Weapons ------------
local file = io.open("WikiInfo/weapon_data.txt", "w+")
file:write("{|align=right\n|__TOC__\n|}\n")
local weapon_data = {}
for id, weap in pairs(tweak_data.weapon) do
if weap.category and not weap.custom then
local cat = tweak_data.gui.buy_weapon_category_groups[weap.category] ~= nil and tweak_data.gui.buy_weapon_category_groups[weap.category] or weap.category
weapon_data[cat] = weapon_data[cat] or {}
weapon_data[cat][id] = weap
end
end
file:write("You can find information for Guns, Throwable and Melee weapons here\n\n")
file:write("== Guns ==\n\n")
for i, cat in pairs(weapon_data) do
file:write("=== " .. managers.localization:text("menu_" .. i) .." ===\n\n")
file:write('{| class="wikitable"\n')
file:write('!Weapon\n!ID\n!Factory ID\n!Unit\n')
for id, weap in pairs(cat) do
local fac_id = managers.weapon_factory:get_factory_id_by_weapon_id(id)
if weap.name_id and fac_id and tweak_data.weapon.factory[fac_id] then
file:write("|-\n")
file:write("|" .. managers.localization:text(weap.name_id) .. "||" .. id .. "||" .. fac_id .. "||" .. tweak_data.weapon.factory[fac_id].unit .. "\n")
end
end
file:write("|}\n\n")
end
file:write("== Throwables ==\n\n")
file:write('{| class="wikitable"\n')
file:write('!Name\n!ID\n!Unit\n')
for id, weap in pairs(tweak_data.blackmarket.projectiles) do
if not weap.custom and weap.throwable then
local fac_id = managers.weapon_factory:get_factory_id_by_weapon_id(id)
file:write("|-\n")
file:write("|" .. managers.localization:text(weap.name_id) .. "||" .. id .. "||" .. weap.unit .. "\n")
end
end
file:write("|}\n\n")
file:write("== Melee ==\n\n")
local dlcs = {
{ dlc = "base"},
{ dlc = "starvr_free"},
{ dlc = "starter_kit"},
{ dlc = "pd2_clan"},
{ dlc = "pd2_clan2"},
{ dlc = "pd2_clan3"},
{ dlc = "pd2_clan4"},
{ dlc = "pd2_clan5"},
{ dlc = "pd2_clan6"},
{ dlc = "pd2_clan_crimefest_oct19"},
{ dlc = "pd2_clan_johnwick"},
{ dlc = "pd2_clan_crimefest_oct23"},
{ dlc = "pd2_clan_lgl"},
{ dlc = "pd2_clan_hoxton"},
{ dlc = "ach_bulldog_1"},
{ dlc = "freed_old_hoxton"},
{ dlc = "crimefest2_u2"},
{ dlc = "crimefest2_par"},
{ dlc = "crimefest2_rave"},
{ dlc = "crimefest2_u8"},
{ dlc = "crimefest2_u9"},
{ dlc = "pd2_clan_bonnie"},
{ dlc = "preorder"},
{ dlc = "cce"},
{ dlc = "soundtrack"},
{ dlc = "poetry_soundtrack"},
{ dlc = "armored_transport"},
{ dlc = "armored_transport_intel"},
{ dlc = "gage_pack"},
{ dlc = "gage_pack_shotgun"},
{ dlc = "gage_pack_assault"},
{ dlc = "gage_pack_lmg"},
{ dlc = "gage_pack_snp"},
{ dlc = "big_bank"},
{ dlc = "charliesierra"},
{ dlc = "xmas_soundtrack"},
{ dlc = "gage_pack_jobs"},
{ dlc = "twitch_pack"},
{ dlc = "twitch_pack2"},
{ dlc = "humble_pack2"},
{ dlc = "humble_pack3"},
{ dlc = "humble_pack4"},
{ dlc = "e3_s15a"},
{ dlc = "e3_s15b"},
{ dlc = "e3_s15c"},
{ dlc = "e3_s15d"},
{ dlc = "sweettooth"},
{ dlc = "hl_miami"},
{ dlc = "hlm_game"},
{ dlc = "gage_pack_historical"},
{ dlc = "goty_weapon_bundle_2014"},
{ dlc = "goty_heist_bundle_2014"},
{ dlc = "goty_dlc_bundle_2014"},
{ dlc = "character_pack_clover"},
{ dlc = "hope_diamond"},
{ dlc = "butch_pack_free"},
{ dlc = "character_pack_dragan"},
{ dlc = "overkill_pack"},
{ dlc = "complete_overkill_pack"},
{ dlc = "hlm2"},
{ dlc = "hlm2_deluxe"},
{ dlc = "speedrunners"},
{ dlc = "bbq"},
{ dlc = "west"},
{ dlc = "arena"},
{ dlc = "character_pack_sokol"},
{ dlc = "kenaz"},
{ dlc = "turtles"},
{ dlc = "turtles_mods_fix"},
{ dlc = "turtles_free"},
{ dlc = "dragon"},
{ dlc = "dragon_maskfix"},
{ dlc = "steel"},
{ dlc = "rip_free"},
{ dlc = "berry"},
{ dlc = "tormentor_mask"},
{ dlc = "pdcon_2015"},
{ dlc = "bobblehead"}
}
LocalizationManager:add_localized_strings({
["bm_global_value_bobblehead"] = "Bobblehead",
["bm_global_value_big_bank"] = "Big Bank",
["bm_global_value_base"] = "Game Base"
})
local _dlcs = {}
for i, dlc in pairs(dlcs) do
_dlcs[dlc.dlc] = i
end
for id, dlc in pairs(tweak_data.dlc) do
if not _dlcs[id] then
table.insert(dlcs, {dlc=id})
_dlcs[id] = #dlcs
end
end
for id, dlc in pairs(tweak_data.lootdrop.global_values) do
if not _dlcs[id] then
table.insert(dlcs, {dlc=id})
_dlcs[id] = #dlcs
end
end
for id, weap in pairs(tweak_data.blackmarket.melee_weapons) do
local dlc = weap.dlc or "base"
if not weap.custom then
dlcs[_dlcs[dlc]].melee = dlcs[_dlcs[dlc]].melee or {}
dlcs[_dlcs[dlc]].melee[id] = weap
end
end
for id, weap in pairs(tweak_data.blackmarket.masks) do
local dlc = weap.dlc or "base"
if not weap.custom then
dlcs[_dlcs[dlc]].masks = dlcs[_dlcs[dlc]].masks or {}
dlcs[_dlcs[dlc]].masks[id] = weap
end
end
for id, weap in pairs(tweak_data.blackmarket.materials) do
local dlc = weap.dlc or "base"
if not weap.custom then
dlcs[_dlcs[dlc]].materials = dlcs[_dlcs[dlc]].materials or {}
dlcs[_dlcs[dlc]].materials[id] = weap
end
end
for id, weap in pairs(tweak_data.blackmarket.textures) do
local dlc = weap.dlc or "base"
dlcs[_dlcs[dlc]].patterns = dlcs[_dlcs[dlc]].patterns or {}
dlcs[_dlcs[dlc]].patterns[id] = weap
end
for id, weap in pairs(tweak_data.weapon.factory.parts) do
local dlc = weap.dlc or "base"
if not weap.custom then
dlcs[_dlcs[dlc]].mods = dlcs[_dlcs[dlc]].mods or {}
dlcs[_dlcs[dlc]].mods[id] = weap
end
end
local file_index = {
melee = file,
}
file = io.open("WikiInfo/mask_data.txt", "w+")
file:write("{|align=right\n|__TOC__\n|}\n")
file:write("This contains data for all the current masks in the game\n\n")
file:write("Also see:\n\n[[Payday 2/Mask Material IDs]]\n\n")
file:write("[[Payday 2/Mask Pattern IDs]]\n\n")
file:write("== Masks ==\n\n")
file_index.masks = file
file = io.open("WikiInfo/mask_material_data.txt", "w+")
file:write("{|align=right\n|__TOC__\n|}\n")
file:write("This contains data for all the current mask materials in the game\n\n")
file:write("== Materials ==\n\n")
file_index.materials = file
file = io.open("WikiInfo/mask_pattern_data.txt", "w+")
file:write("{|align=right\n|__TOC__\n|}\n")
file:write("This contains data for all the current mask patterns in the game\n\n")
file:write("== Patterns ==\n\n")
file_index.patterns = file
file = io.open("WikiInfo/weapon_mod_data.txt", "w+")
file:write("{|align=right\n|__TOC__\n|}\n")
file:write("This contains data for all the current weapon mods in the game\n\n")
file:write("== Weapon Mods ==\n\n")
file_index.mods = file
for _, dlc_data in pairs(dlcs) do
for i, data in pairs(dlc_data) do
if type(data) == "table" then
file = file_index[i]
file:write("=== " .. managers.localization:text("bm_global_value_" .. dlc_data.dlc) .." ===\n\n")
file:write('{| class="wikitable"\n')
if i == "melee" then
file:write('!Weapon\n!ID\n!Unit\n')
for id, weap in pairs(data) do
if weap.name_id then
file:write("|-\n")
file:write("|" .. managers.localization:text(weap.name_id) .. "||" .. id .. "||" .. (weap.unit and weap.unit or "N/A") .. "\n")
end
end
file:write("|}\n\n")
elseif i == "masks" then
file:write('!Mask Name\n!ID\n!Unit\n')
for id, mask in pairs(data) do
if mask.name_id then
file:write("|-\n")
file:write("|" .. managers.localization:text(mask.name_id == "bm_msk_cheat_error" and "bm_msk_balaclava" or mask.name_id) .. "||" .. id .. "||" .. (mask.unit and mask.unit or "N/A") .. "\n")
end
end
file:write("|}\n\n")
elseif i == "materials" then
file:write('!Material\n!ID\n!Texture\n')
for id, mask in pairs(data) do
if mask.name_id then
file:write("|-\n")
file:write("|" .. managers.localization:text(mask.name_id) .. "||" .. id .. "||" .. (mask.texture and mask.texture or "N/A") .. "\n")
end
end
file:write("|}\n\n")
elseif i == "patterns" then
file:write('!Pattern\n!ID\n!Unit\n')
for id, mask in pairs(data) do
if mask.name_id then
file:write("|-\n")
file:write("|" .. managers.localization:text(mask.name_id) .. "||" .. id .. "||" .. (mask.texture and mask.texture or "N/A") .. "\n")
end
end
file:write("|}\n\n")
elseif i == "mods" then
file:write('!Mod\n!ID\n!Unit\n!Third Unit\n')
for id, mod in pairs(data) do
if mod.name_id then
file:write("|-\n")
file:write("|" .. managers.localization:text(mod.name_id) .. "||" .. id .. "||" .. (mod.unit and mod.unit or "N/A") .. "||" .. (mod.third_unit and mod.third_unit or "N/A") .. "\n")
end
end
file:write("|}\n\n")
end
end
end
end
for _, file in pairs(file_index) do
file:close()
end
local file = io.open("WikiInfo/weap_stats_data.txt", "w+")
for id, weap in pairs(tweak_data.weapon) do
if weap.stats then
file:write(id .. "(" .. managers.localization:text(weap.name_id) .. ")" .. ":\n")
for stat, val in pairs(WeaponDescription._get_base_stats(id)) do
file:write(stat .. ": " .. tostring(math.round(val.value)) .. "\n")
end
file:write("\n")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment