• Announcement: Lua.org now officially recommends this forum as a meeting place for the Lua community

PES Lua Module - Switch Banner in match (1 Viewer)

tecno214

Newcomer
Joined
Apr 10, 2021
Messages
3
Reaction score
0
Good evening everyone.
I am programming a module for an old version of PES for self-study purposes.
Placed below the complete content of the module currently being planned for your analysis:

===========================================================
local function stadium_id(ctx)
stadium = ctx.stadium
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
ad_uel = string.format("ad_%s_el.fpk", stid) --ad_st001_el.fpk
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 -- Filename INTER
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 -- Filename MILAN
return string.gsub(filename, "ad_st%d%d%d_normal.fpk", ad_cl) --ad_st030_normal.fpk, ad_st030_cl.fpk
elseif ctx.home_team == 125 then -- Filename ROMA
return string.gsub(filename, "ad_st%d%d%d_normal.fpk", ad_cl) --ad_st006_normal.fpk, ad_st006_cl.fpk
else
return nil
end
end
end

local function get_filepath(ctx, filename, key)
if key then
if ctx.home_team == 119 then -- Home INTER
filepath = ctx.sider_dir .. ".\\modules\\EvoSwitcher\\EvoBanner\\Inter\\" .. filename
elseif ctx.home_team == 121 then -- Home MILAN
filepath = ctx.sider_dir .. ".\\modules\\EvoSwitcher\\EvoBanner\\Milan\\" .. filename
elseif ctx.home_team == 125 then -- Home ROMA
filepath = ctx.sider_dir .. ".\\modules\\EvoSwitcher\\EvoBanner\\Roma\\" .. filename
else
end
return filepath
end
end

function init(ctx)
ctx.register("livecpk_rewrite", rewrite)
ctx.register("after_set_conditions", stadium_id) -- Applica allo stadio
ctx.register("livecpk_get_filepath", get_filepath) -- Vai al percorso del files
end

return { init = init }
==========================================================

What I would like to do is assign a different file name to each stadium, while currently Roma and Milan both run with ad_sc.
With this programming it often happens to find a team with the modules of the other team and vice versa.

Where am I doing wrong?

Thank you in advance for your response..

FILIPPO
 

Attachments

  • PannelliStadio.lua
    1.9 KB · Views: 1

dinsdale247

Moderator
Staff member
Community Patron
Creator of WinLua
Joined
Nov 17, 2020
Messages
93
Reaction score
32
Location
Victoria BC
Website
winlua.net
Hi,

It looks like you're using global variables all over the place. stadium, stid, ad_cl, ad_uel, ad_sc. But I think your problem is in get_filepath. The variable filepath is global and in your if/else you have a blank else.

I would go through and add local to all those variables and see if that fixes things?

Good luck!
 
Top