gmo61520

Untitled

May 27th, 2016
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.35 KB | None | 0 0
  1. [
  2. {
  3. "name": "Same brand & class",
  4. "script": "strutils.equals_i(selected.Brand, tested.Brand) and strutils.equals_i(selected.CarClass, tested.CarClass)"
  5. },
  6. {
  7. "name": "Same era & class",
  8. "script": "selected.Year ~= nil and tested.Year ~= nil and math.abs(selected.Year - tested.Year) < 10 and strutils.equals_i(selected.CarClass, tested.CarClass)"
  9. },
  10. {
  11. "name": "Similar P/W ratio",
  12. /* only 5% difference */
  13. "script": "
  14. return function(tested)
  15. local selectedPwRatio = numutils.numvalue(selected.SpecsPwRatio)
  16. local testedPwRatio = numutils.numvalue(tested.SpecsPwRatio)
  17. return math.abs(selectedPwRatio - testedPwRatio) < selectedPwRatio * 0.05
  18. end"
  19. },
  20. {
  21. "name": "Same subclass only",
  22. "script": "
  23. return function(tested)
  24. local subclass = selected.Tags:FirstOrDefault(function (x) return string.sub(x, 1, 1) == '#' end)
  25. return tested.Tags:Contains(subclass)
  26. end"
  27. },
  28. {
  29. "name": "Same racing class (GT3/GT2/…)",
  30. "filter": "class:race",
  31. "script": "
  32. -- tags to search for
  33. classes = { 'gt3', 'gt2', '#GT4', '#90s touring' }
  34.  
  35. -- try to find some tag in selected car
  36. racingclass = nil
  37. for i, cl in ipairs(classes) do
  38. if selected.Tags:ContainsIgnoringCase(cl) then
  39. racingclass = cl
  40. break
  41. end
  42. end
  43.  
  44. -- logging
  45. if racingclass ~= nil then
  46. log('selected class: ' .. racingclass)
  47. else
  48. log('selected class: NIL')
  49. end
  50.  
  51. -- in case there is no any tag at all, result is false
  52. if racingclass == nil then
  53. return false
  54. end
  55.  
  56. -- result function which will try to find that tag in any tested car
  57. return function(tested)
  58. return tested.Tags:ContainsIgnoringCase(racingclass)
  59. end"
  60. },
  61. {
  62. "name": "Classic race cars",
  63. "filter": "class:race & year<1980"
  64. },
  65. {
  66. "name": "Modern race cars",
  67. "filter": "class:race & year>2000"
  68. },
  69. ]
Advertisement
Add Comment
Please, Sign In to add comment