给脚本中的任何团队分配特定文件

我正在编写 .lua 的程序例行模块,为 PES 2019 的自学模块,我需要在不知道它如何工作的例行程序上下手。

以下是脚本:

local function stadium_id(ctx)
stadium = ctx.stadiu
if string.len(stadium) == 1 then  --st001
   stid = "st00" .. stadium
elseif string.len(stadium) == 2 then
   stid = "st0" .. stadium
elseif string.len(stadium) == 3 then
   stid = "st" .. stadium
end
ad_cl = string.format("ad_%s_cl.fpk", stid) --ad_st001_cl.fpk -- 用于AC米兰121
ad_uel = string.format("ad_%s_el.fpk", stid) --ad_st001_el.fpk -- 用于国际米兰119
ad_sc = string.format("ad_%s_sc.fpk", stid) --ad_st001_sc.fpk
end

function rewrite(ctx, filename)
if ad_cl and ad_uel and ad_sc then
  if ctx.home_team == 119 then -- 文件名国际米兰
      return string.gsub(filename, "ad_st%d%d%d_normal.fpk", ad_uel) --ad_st001_normal.fpk, ad_st001_el.fpk
  elseif ctx.home_team == 121 then -- 文件名AC米兰
      return string.gsub(filename, "ad_st%d%d%d_normal.fpk", ad_cl) --ad_st030_normal.fpk, ad_st030_cl.fpk
  else
      return nil
 end
end
end

local function get_filepath(ctx, filename, key)
if key then
   if ctx.home_team == 119 then -- 主场国际米兰
        filepath = ctx.sider_dir .. ".\\modules\\EvoSwitcher\\EvoBanner\\Inter\\" .. filename
   elseif ctx.home_team == 121 then -- 主场AC米兰
        filepath = ctx.sider_dir .. ".\\modules\\EvoSwitcher\\EvoBanner\\Milan\\" .. filename
        else
   end
   return filepath
   end
end

function init(ctx)
ctx.register("livecpk_rewrite", rewrite)
ctx.register("after_set_conditions", stadium_id) -- 应用于体育场
ctx.register("livecpk_get_filepath", get_filepath) -- 转到文件路径
end

return { init = init }

我想做的是为每个团队分配一个唯一的名称文件,而不是 ad_cl、ad_uel 等,这些名称最初是分配给竞赛而不是团队的...

点赞