Code:
-- Function to check if value is in table
function in_table( table, value )
if table ~= nil then for i,x in pairs(table) do if x == value then return true end end end
return false
end
-------------------------------------------------------------------------
--giveitems( itype, times )
--[[
Gives all items for the corresponding item type for the specified number of times. Default is 5 items per use.
Usage:
This gives you 5 of every item
giveitems("all")
You can specify the type, for example this gives you 5 of every mask
giveitems("masks")
You can also pass along a table of only certain item types you want
giveitems({"masks","textures","colors"})
--]]
function giveitems( itype, times )
local types = {"weapon_mods", "masks", "materials", "textures", "colors"}
local skip = { masks = {"character_locked"}, materials = {"plastic"}, colors = {"nothing"}, textures = {"no_color_full_material","no_color_no_material"} }
if not times then times = 5 end
if type(itype) == "table" then types = itype end
if itype == "all" or type(itype) == "table" then
for i = 1, #types do giveitems(types[i], times) end
return
elseif not in_table(types, itype) then return end
for i=1, times do
for mat_id,_ in pairs(tweak_data.blackmarket[itype]) do
if not in_table(skip[itype], mat_id) then
local global_value = "normal"
if _.global_value then
global_value = _.global_value
elseif _.infamous then
global_value = "infamous"
elseif _.dlcs or _.dlc then
local dlcs = _.dlcs or {}
if _.dlc then table.insert( dlcs, _.dlc ) end
global_value = dlcs[ math.random( #dlcs ) ]
end
if _.unlocked == false then _.unlocked = true end
managers.blackmarket:add_to_inventory(global_value, itype, mat_id, false)
end
end
end
end
-------------------------------------------------------------------------
--giveitem( item, times , global_value)
--[[
Gives you a certain item for the specified number of times. Default is 5 items per use.
By specifying global_value, you can change the item from its default global value like "normal" and "infamous"
Usage:
This gives you 5 of the slime material
giveitem("slime")
This gives you 5 of the Alien mask
giveitem("alienware")
You can also pass along a table of only certain items you want
giveitem({"slime","rainbow","alienware"})
--]]
function giveitem( item, times , global_value)
local types = {"weapon_mods", "masks", "materials", "textures", "colors"}
if not times then times = 5 end
for t = 1, #types do
local itype = types[t]
for mat_id,_ in pairs(tweak_data.blackmarket[itype]) do
if (type(item) == "table" and in_table(item, mat_id)) or (type(item) ~= "table" and mat_id == item) then
if not global_value then
local global_value = "normal"
if _.global_value then
global_value = _.global_value
elseif _.infamous then
global_value = "infamous"
elseif _.dlcs or _.dlc then
local dlcs = _.dlcs or {}
if _.dlc then table.insert( dlcs, _.dlc ) end
global_value = dlcs[ math.random( #dlcs ) ]
end
end
if _.unlocked == false then _.unlocked = true end
for i=1, times do managers.blackmarket:add_to_inventory(global_value, itype, mat_id, false) end
if type(item) ~= "table" then return end
end
end
end
end
-------------------------------------------------------------------------
--removeitems( itype, times )
--[[
Removes items from a given type, out dated, see clearitems below
--]]
function removeitems( itype, times )
local types = {"weapon_mods", "masks", "materials", "textures", "colors"}
if not times then times = 100 end
if type(itype) == "table" then types = itype end
if itype == "all" or type(itype) == "table" then
for i = 1, #types do removeitems(types[i], times) end
return
elseif not in_table(types, itype) then return end
for i=1, times do
for mat_id,_ in pairs(tweak_data.blackmarket[itype]) do
managers.blackmarket:remove_item("normal", itype, mat_id)
managers.blackmarket:remove_item("infamous", itype, mat_id)
if _.global_value then
managers.blackmarket:remove_item(_.global_value, itype, mat_id)
elseif _.dlcs or _.dlc then
local dlcs = _.dlcs or {}
if _.dlc then table.insert( dlcs, _.dlc ) end
for i = 1, #dlcs do managers.blackmarket:remove_item(dlcs[i], itype, mat_id) end
end
end
end
end
-------------------------------------------------------------------------
--removeitems( item, times )
--[[
Removes a given item, out dated, see clearitem below
--]]
function removeitem( item, times )
local types = {"weapon_mods", "masks", "materials", "textures", "colors"}
if not times then times = 100 end
for t = 1, #types do
local itype = types[t]
for mat_id,_ in pairs(tweak_data.blackmarket[itype]) do
if (type(item) == "table" and in_table(item, mat_id)) or (type(item) ~= "table" and mat_id == item) then
local global_value = { "normal" }
if _.global_value then
global_value = { _.global_value }
elseif _.infamous then
global_value = { "infamous" }
elseif _.dlcs or _.dlc then
global_value = _.dlcs or {}
if _.dlc then table.insert( global_value, _.dlc ) end
end
for g = 1, #global_value do
for i=1, times do managers.blackmarket:remove_item(global_value[g], itype, mat_id) end
end
if type(item) ~= "table" then return end
end
end
end
end
-------------------------------------------------------------------------
--clearitems( itype , globalval )
--[[
Clears the items of the specified type with the specified (optional) global value, the global value defaults to all.
Usage:
This removes every item
clearitems("all")
You can specify the type, for example this removes all the masks
clearitems("masks")
You can also pass along a table of only certain item types you want to remove
clearitems({"masks","textures","colors"})
With the optional global value, you can remove only certain items like all halloween masks
clearitems("masks", "halloween")
--]]
function clearitems( itype , globalval )
local types = {"weapon_mods", "masks", "materials", "textures", "colors"}
if not globalval then globalval = "all" end
if type(itype) == "table" then types = itype end
if itype == "all" or type(itype) == "table" then
for i = 1, #types do clearitems(types[i], globalval) end return
elseif not in_table(types, itype) then return end
for global_value, categories in pairs( Global.blackmarket_manager.inventory ) do
if (globalval == "all" or globalval == global_value) and categories[itype] then
for id,amount in pairs( categories[itype] ) do
Global.blackmarket_manager.inventory[global_value][itype][id] = 0
end
end
end
end
-------------------------------------------------------------------------
--clearitem( item , globalval )
--[[
Clears the given item with the specified (optional) global value, the global value defaults to all.
Usage:
This removes all slime materials
clearitem("slime")
This removes all the alien masks
clearitem("alienware")
You can also pass along a table of only certain items you want to remove
clearitem({"slime","rainbow","alienware"})
--]]
function clearitem( item , globalval )
local types = {"weapon_mods", "masks", "materials", "textures", "colors"}
if not globalval then globalval = "all" end
for t = 1, #types do
local itype = types[t]
for global_value, categories in pairs( Global.blackmarket_manager.inventory ) do
if (globalval == "all" or globalval == global_value) and categories[itype] then
for id,amount in pairs( categories[itype] ) do
if (type(item) == "table" and in_table(item, id)) or (type(item) ~= "table" and id == item) then
Global.blackmarket_manager.inventory[global_value][itype][id] = 0
end
end
end
end
end
end
-------------------------------------------------------------------------
--clearnewitems( itype )
--[[
Clears the new item flags from the given types
--]]
function clearnewitems( itype )
local types = {"weapon_mods", "masks", "materials", "textures", "colors"}
if type(itype) == "table" then types = itype end
if itype == "all" or type(itype) == "table" then
for i = 1, #types do clearnewitems(types[i]) end
return
elseif not in_table(types, itype) then return end
for mat_id,_ in pairs(tweak_data.blackmarket[itype]) do
local global_value = { "normal" }
if _.global_value then
global_value = { _.global_value }
elseif _.infamous then
global_value = { "infamous" }
elseif _.dlcs or _.dlc then
global_value = _.dlcs or {}
if _.dlc then table.insert( global_value, _.dlc ) end
end
for i = 1, #global_value do
if managers.blackmarket:got_new_drop( global_value[i], itype, mat_id ) then
managers.blackmarket:remove_new_drop( global_value[i], itype, mat_id )
end
end
end
end
-------------------------------------------------------------------------
--unlockitems( itype )
--[[
Unlocks items from the given type
--]]
function unlockitems( itype )
local types = {"weapon_mods", "masks", "materials", "textures", "colors", "weapons"}
if type(itype) == "table" then types = itype end
if itype == "all" or type(itype) == "table" then
for i = 1, #types do unlockitems(types[i]) end
return
elseif not in_table(types, itype) then return end
if itype == "weapons" then
for wep_id,_ in pairs(tweak_data.upgrades.definitions) do
if _.category == "weapon" and not string.find(wep_id, "_primary") and not string.find(wep_id, "_secondary") then
if not managers.upgrades:aquired(wep_id) then managers.upgrades:aquire(wep_id) end
end
end
else
for mat_id,_ in pairs(tweak_data.blackmarket[itype]) do
if _.unlocked == false then _.unlocked = true end
end
end
end
--------------------------------------------------------------
if managers and managers.menu_component then
managers.menu_component:post_event("menu_enter")
end
--------------------------------------------------------------
clearitems("all")
giveitems("all", 20)
Examples: