Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function refrence(path, file)
- local explodedPath = explode([[\]], path)
- local ref = file.GameData
- local refT = file._TYPE.GameData
- for i = 1, table.getn(explodedPath) do
- if type(ref[explodedPath[i]] == "table") then
- ref = ref[explodedPath[i]]
- refT = refT[explodedPath[i]]
- else
- print("false")
- end
- end
- return {ref, refT}
- end
- function Shorten(file)
- return file.GameData, file._TYPE.GameData
- end
- function insert_entry(path, openFile, info, refFile, baseFile)
- if not runInit then
- runInit = 0
- end
- runInit = runInit + 1
- local exist = 0
- for k,v in pairs(openFile[1]) do
- if k == info[1] then
- exist = exist + 1
- end
- end
- local name
- if exist > 0 then
- name = [[&]] .. info[1] .. [[_]] .. exist
- else
- name = info[1]
- end
- print(name)
- openFile[1][name] = refrence(path, refFile)[1]
- openFile[2][name] = refrence(path, refFile)[2]
- for k,v in pairs(info) do
- if type(k) ~= "number" then
- print(k)
- openFile[1][name][k] = v
- end
- end
- end
- function explode(div, str)
- if (div=='') then return false end
- local pos,arr = 0,{}
- -- run for each divider found
- for st,sp in function() return string.find(str,div,pos,true) end do
- table.insert(arr,string.sub(str,pos,st-1)) -- Attach chars left of current divider
- pos = sp + 1 -- Jump past current divider
- end
- table.insert(arr,string.sub(str,pos)) -- Attach chars right of last divider
- return arr
- end
- loadfile([[C:\Program Files\Steam\steamapps\common\dawn of war 2\test\Macros\lua\utils.lua]])
- modname = [[test]]
- base = compiler_get_source_dir() .. modname .. [[\DataAttrib\simulation\attrib\]]
- -- table with all details in it
- local UCS_start = 0
- local tier2 = [[upgrade\_game\menu\tier_2]]
- local tier3 = [[upgrade\_game\menu\tier_3]]
- local backIcon = [[icon]]
- local t =
- {
- Menus =
- {
- top_level =
- {
- baseSavePath = base .. [[sbps\_game\menu\]],
- relativePath = [[_game\menu\]],
- iconPath = [[]],
- {"hq", tier1, 1, [[icon]]},
- {"troop",tier1, 2, [[icon]]},
- {"elite",tier1, 3, [[icon]]},
- {"fast_attack",tier1, 4, [[icon]]},
- {"heavy_support",tier1, 5, [[icon]]},
- },
- },
- Units = {
- space_marines =
- {
- basePath = base .. [[sbps\_space_marines\menu]],
- iconPath = [[]],
- {"tactical_space_marines", "troop"},
- {"scout_marines", "troop"},
- {"captain", "hq"},
- },
- },
- }
- local ucs = {}
- -- load up the refrence file
- ref = compiler_load_rbf([[::simulation\attrib\refrence.rbf]])
- function create_base_squad_file(file)
- -- add the tables we need
- local top = file.GameData
- local topT = file._TYPE.GameData
- -- squad_loadout_ext
- top.squad_loadout_ext = refrence([[squad_extentions\squad_loadout_ext]], ref)[1]
- topT.squad_loadout_ext = refrence([[squad_extentions\squad_loadout_ext]], ref)[2]
- -- adding the unit
- local info = {"squad_loadout_unit_entry" ,["type"] = [[ebps\_game\invisible_entity]]}
- local files = {top.squad_loadout_ext.unit_list, topT.squad_loadout_ext.unit_list}
- insert_entry([[entries\unit_list\squad_loadout_unit_entry]], files, info, ref)
- -- squad requirments
- top.squad_requirement_ext = refrence([[squad_extentions\squad_requirement_ext]], ref)[1]
- topT.squad_requirement_ext = refrence([[squad_extentions\squad_requirement_ext]], ref)[2]
- -- squad_UI
- top.squad_ui_ext = refrence([[squad_extentions\squad_ui_ext]], ref)[1]
- topT.squad_ui_ext = refrence([[squad_extentions\squad_ui_ext]], ref)[2]
- end
- function create_base_lock_out_upgrade(file)
- local top = file.GameData
- local topT = file._TYPE.GameData
- -- load the bag
- top.upgrade_bag = refrence([[bags\upgrade_bag]], ref)[1]
- topT.upgrade_bag = refrence([[bags\upgrade_bag]], ref)[2]
- end
- local UCS1, UCS2
- local openUPGS = {}
- -- first make the menus
- for k,v in pairs(t.Menus) do
- for i = 1, table.getn(v) do
- -- first we need to make ALL the open upgs
- -- load blank file
- openUpgrade = compiler_load_rbf([[::simulation\attrib\blank_file.rbf]])
- -- create the base file
- create_base_lock_out_upgrade(openUpgrade)
- -- create its path
- local upgRelative = [[upgrade\]] .. v.relativePath .. v[i][1] .. [[_open]]
- local upgSavePath = base .. upgRelative .. [[.rbf]]
- -- insert into table
- openUPGS[v[i][1]] = {save = upgSavePath, relative = upgRelative}
- -- create upg
- compiler_make_rbf(openUpgrade, upgSavePath)
- -- create ability that removes upg
- -- *********************TO DO!!!!!!!!!!!!!!!!!**************************
- end
- for i = 1, table.getn(v) do
- if not UCS2 then
- UCS1 = UCS_start
- UCS2 = UCS1 + 1
- else
- UCS1 = UCS2 + 1
- UCS2 = UCS1 + 1
- end
- -- load up the blank_file
- squadFile = compiler_load_rbf([[::simulation\attrib\blank_file.rbf]])
- -- create the base
- create_base_squad_file(squadFile)
- local top = squadFile.GameData
- local topT = squadFile._TYPE.GameData
- -- add the tier requirement if needed
- if v[i][2] then
- end
- -- add icon path
- top.squad_ui_ext.icon_name = v[i][4]
- -- add UCS entries
- top.squad_ui_ext.squad_name = UCS1
- top.squad_ui_ext.screen_name = UCS1
- top.squad_ui_ext.help_text = UCS2
- -- loop through the created open UPGS and have it require NON of them to be present
- for menuName,value in pairs(openUPGS) do
- print(value.relative)
- -- insert a requirement into the sbps
- local info =
- {
- "required_player_upgrade",
- is_present = false,
- reason = [[display_and_usage_and_produce]],
- upgrade_name = value.relative
- }
- local files = {top.squad_requirement_ext.requirement_table, topT.squad_requirement_ext.requirement_table}
- insert_entry([[requirements\required_player_upgrade]], files, info, ref)
- end
- -- create file
- local savePath = v.baseSavePath .. v[i][1] .. [[.rbf]]
- compiler_make_rbf(squadFile, savePath)
- -- create back squad
- --- ****** TO DO *!!!!!!************************
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement