Advertisement
Guest User

Untitled

a guest
Nov 18th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.95 KB | None | 0 0
  1. -- turfserver by Chuny
  2. -- version 1.1
  3.  
  4. local m = {}
  5. local content_root = ".\\content\\turf-server\\"
  6.  
  7. local function if_exists(path)
  8.     log(string.format("checking: %s", path))
  9.     local f = io.open(content_root .. path)
  10.     if f then
  11.         log(string.format("using: %s", path))
  12.         f:close()
  13.         return path
  14.     end
  15. end
  16.  
  17. function m.make_key(ctx, filename)
  18.     local suffix = (ctx.timeofday == 0) and "DAY" or "NIGHT"
  19.     if string.match(filename, "Asset\\model\\bg\\common\\pitch\\sourceimages\\#windx11\\turf_bsm_alp_rgba32%.ftex") then
  20.         local path = string.format("Asset\\model\\bg\\st%03d\\sourceimages\\tga\\#windx11\\turf_bsm_alp_rgba32_%s.ftex", ctx.stadium, suffix)
  21.         return if_exists(path)
  22.     elseif string.match(filename, "Asset\\model\\bg\\st(%d+)\\sourceimages\\tga\\#windx11\\pitch_alp%.ftex") then
  23.         local path = string.format("Asset\\model\\bg\\st%03d\\sourceimages\\tga\\#windx11\\pitch_alp_%s.ftex", ctx.stadium, suffix)
  24.         return if_exists(path)
  25.     elseif string.match(filename, "Asset\\model\\bg\\st(%d+)\\sourceimages\\tga\\#windx11\\pitch_detail_alp%.ftex") then
  26.         local path = string.format("Asset\\model\\bg\\st%03d\\sourceimages\\tga\\#windx11\\pitch_detail_alp_%s.ftex", ctx.stadium, suffix)
  27.         return if_exists(path)
  28.     elseif string.match(filename, "Asset\\model\\bg\\st(%d+)\\sourceimages\\tga\\#windx11\\pitch_specular_mask%.ftex") then
  29.         local path = string.format("Asset\\model\\bg\\st%03d\\sourceimages\\tga\\#windx11\\pitch_specular_mask_%s.ftex", ctx.stadium, suffix)
  30.         return if_exists(path)
  31.     end
  32. end
  33.  
  34. function m.get_filepath(ctx, filename, key)
  35.     if key then
  36.         return content_root .. key
  37.     end
  38. end
  39.  
  40. function m.init(ctx)
  41.     if content_root:sub(1,1) == "." then
  42.         content_root = ctx.sider_dir .. content_root
  43.     end
  44.     ctx.register("livecpk_make_key", m.make_key)
  45.     ctx.register("livecpk_get_filepath", m.get_filepath)
  46. end
  47.  
  48. return m
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement