Jump to content

Need some help with less functions more tables


Recommended Posts

I want to combine these two functions into one and use tables where i can, im horrible with tables if anyone can help

 

local tt7 = {}
addEventHandler("onClientResourceStart", resourceRoot, function ()
    tt7.low = dxCreateTexture('shader/low/camonet_east_co.bmp',"dxt5",true)
    tt7.medium = dxCreateTexture('shader/medium/camonet_east_co.bmp',"dxt5",true)
    tt7.high = dxCreateTexture('shader/img/camonet_east_co.bmp',"dxt5",true)
    shader = dxCreateShader("shader/fx/shader.fx")
end)

local ammo = 'ammotrn92tarp128'
addEventHandler('pp', root, function()
local shader = dxCreateShader("shader/fx/shader.fx")
if setting == 1 then
    terrain = tt7.low
elseif setting == 2 then
    terrain = tt7.medium
elseif setting == 3 then
terrain = tt7.high
end
if terrain then
dxSetShaderValue(shader, 'Tex0', terrain)
engineApplyShaderToWorldTexture (shader,ammo)
end
end
)

local tt8 = {}
addEventHandler("onClientResourceStart", resourceRoot, function ()
    tt8.low = dxCreateTexture('shader/low/mountchillad.jpg',"dxt5",true)
    tt8.medium = dxCreateTexture('shader/medium/mountchillad.jpg',"dxt5",true)
    tt8.high = dxCreateTexture('shader/img/mountchillad.jpg',"dxt5",true)
    shader = dxCreateShader("shader/fx/shader.fx")
end)

local mountchillad = {'rock_country128','sw_rockgrassb1lod','desclifftypebs','sw_rockgrassb1','rocktbrn128lod','rocktbrn128_lod','rocktbrn128','rocktbrn_dirt2','sw_rockgrass1','cw2_mountdirtscree','rocktq128',"sm_rock2_desert",'des_crackeddirt1','des_redrock1','des_redrock2','cw2_mountrock','cs_rockdetail2'}
addEventHandler('pp', root, function()
local shader = dxCreateShader("shader/fx/shader.fx")
if setting == 1 then
    terrain = tt8.low
elseif setting == 2 then
    terrain = tt8.medium
elseif setting == 3 then
terrain = tt8.high
end
if terrain then
dxSetShaderValue(shader, 'Tex0', terrain)
for i=1, #mountchillad do
    engineApplyShaderToWorldTexture(shader, mountchillad[i])
  end
end
end
)

 

Edited by greentumbleweed
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...