Track Design Patterns

    Gearbest Tablet-PC Promotion promotion
    • From the screenshots this looks like a really nice piece of work. Thank you for creating this mod.

      I am allowed to ask some questions:

      • How do you calculated the track bezier curve outline to place the walls?
      • Would you accept a small commonapi patch so all track types are possible? (I won't change anything when commonapi wouldn't be loaded)
    • eis_os schrieb:

      How do you calculated the track bezier curve outline to place the walls?
      I didn't try to fit bezier, since the result from the game fit's well circular arc under approx. 60°, I just let all coordinates go with circular arcs. I make my arc generate two edges each time and it can support up to 90° without much errors.

      eis_os schrieb:

      Would you accept a small commonapi patch so all track types are possible? (I won't change anything when commonapi wouldn't be loaded)
      Having seen you mod last night on Steam, I am also thinking of it. The selection of track file is done directly in updateFn like following:


      Quellcode

      1. local trackType = ({"standard.lua", "high_speed.lua"})[params.trackType + 1]



      if you want to patch them, how can you patch a single line in the function?

      However I am interested in working with your api, do I need to expose this single line as a function or a callback to make the patching easier? I have yet looked into your api due to limited time.
      This guy is too lazy to create a signature. 8o
    • The easiest way is with commonapi.uiparameter.modifyTrackCatenary, that does a lot of the stuff under the hood so you don't need to pass any objects around.

      I did post an example here:
      Common API - immer noch macOS Nutzer gesucht! -

      Technical you simple pass the params array and an "array" of trackTypes (exact two entries) to it and it will modify your params and your trackTypes.
      (LUA tables are passed pretty much as references, so this works generally quite well on all constructions).

      So you need somewhere an array local to your data function in the con.
      Then you access this array in your params and updateFn. The fastest way would be to add extra function parameters.
      (Note: I did this without any testing, as you already have a params construction function it should technical pretty simple)

      Quellcode

      1. local function params(trackTypes)
      2. local result = {
      3. ...
      4. }
      5. if (commonapi ~= nil and commonapi.uiparameter ~= nil) then
      6. commonapi.uiparameter.modifyTrackCatenary(result, {selectionlist = trackTypes})
      7. end
      8. return result
      9. end

      Quellcode

      1. local updateFn = function(models, trackTypes)
      2. return function(params)
      3. defaultParams(params)
      4. local trackType = trackTypes[(params.trackType or 0)+ 1] or "standard.lua"
      5. ...

      Quellcode

      1. function data()
      2. local trackTypes = {"standard.lua", "high_speed.lua"}
      3. return {
      4. type = "RAIL_DEPOT",
      5. ...
      6. params = params(trackTypes)
      7. updateFn = updateFn( .... , trackTypes)



      But defaultParams could be a bit tricky to cheat, as it needs the trackTypes as well.
      Technical I would only create the ui-params once and not run the params again when doing the defaultParams call.

      Running modifyTrackCatenary with already patched trackTypes will surely fail, so this is not a final patch.
    • You don't have a direct dependency, the line ensures that the code will run only when commonapi is loaded:

      if (commonapi ~= nil and commonapi.uiparameter ~= nil) then

      end

      CommonAPI works without require or hard dependency, so no worry ;)

      -edit-
      Here a working tunnel_entry.con, again, there is no dependency on CommonAPI, if it's loaded, it will be used, otherwise nothing will be changed:

      Unterschiede-Datei: tunnel_entry.con.diff

      1. --- tunnel_entry.con_old Sat Oct 14 02:10:07 2017
      2. +++ tunnel_entry.con Sat Oct 14 20:12:46 2017
      3. @@ -20,9 +20,9 @@
      4. "track_design_patterns/arch_wall.mdl",
      5. }
      6. -local function params()
      7. +local function params(trackTypes)
      8. local sp = "----------------------------\n"
      9. - return {
      10. + local uiparams = {
      11. paramsutil.makeTrackTypeParam(),
      12. paramsutil.makeTrackCatenaryParam(),
      13. {
      14. @@ -104,22 +104,25 @@
      15. defaultIndex = 10
      16. }
      17. }
      18. -
      19. + if (commonapi ~= nil and commonapi.uiparameter ~= nil) then
      20. + commonapi.uiparameter.modifyTrackCatenary(uiparams, {selectionlist = trackTypes})
      21. + end
      22. + return uiparams
      23. end
      24. -local function defaultParams(param)
      25. +local function defaultParams(param, uiparams)
      26. local function limiter(d, u)
      27. return function(v) return v and v < u and v or d end
      28. end
      29. - func.forEach(params(), function(i)param[i.key] = limiter(i.defaultIndex or 0, #i.values)(param[i.key]) end)
      30. + func.forEach(uiparams, function(i)param[i.key] = limiter(i.defaultIndex or 0, #i.values)(param[i.key]) end)
      31. end
      32. -local updateFn = function(models)
      33. +local updateFn = function(models, uiparams, trackTypes)
      34. return function(params)
      35. - defaultParams(params)
      36. + defaultParams(params, uiparams)
      37. - local trackType = ({"standard.lua", "high_speed.lua"})[params.trackType + 1]
      38. + local trackType = trackTypes[(params.trackType or 0) + 1] or "standard.lua"
      39. local catenary = params.catenary == 1
      40. local trackBuilder = trackEdge.builder(catenary, trackType)
      41. local height = 8.5
      42. @@ -331,6 +334,8 @@
      43. function data()
      44. + local trackTypes = {"standard.lua", "high_speed.lua"}
      45. + local uiparams = params(trackTypes)
      46. return {
      47. type = "RAIL_DEPOT",
      48. description = {
      49. @@ -343,14 +348,16 @@
      50. order = 27219,
      51. skipCollision = false,
      52. autoRemovable = false,
      53. - params = params(),
      54. + params = uiparams,
      55. updateFn = updateFn(
      56. {
      57. mRoofFenceF = "track_design_patterns/roof_fence_front.mdl",
      58. mRoof = "track_design_patterns/roof.mdl",
      59. - }
      60. - )
      61. + },
      62. + uiparams,
      63. + trackTypes
      64. + )
      65. }
      66. end
      Alles anzeigen
    • eis_os schrieb:

      You don't have a direct dependency, the line ensures that the code will run only when commonapi is loaded:
      Thank you for giving working code, yes I know it but reading global variables in lua is not free.

      But I think patching mod follows a good logical separation rule and will be useful if someday maybe you want to make some changes to api, at least I don't need to upgrade my mod immediately if it comes, and the player will have choice, if he has installed 100 tracks and he doesn't want to see a heavy menu. I have been asked for many times if the tracks under the flying junction can be other tracks so I think working with your api will be very constructive.

      I will look into this later, very tired by the mod for the moment, need to take a rest.
      This guy is too lazy to create a signature. 8o
    • Not right now (only when u change code). I think he said that he adds the CommonAPI sometime later.

      For the manual change follow the steps bellow:

      Go in the modfolder ( in steam its steamapps/workshop/content/446800/1168068230 ; else its the Foldername u downloaded)

      go to res/construction and open all of the files (for example with Notepad++ )

      search this line: local trackType = ({"standard.lua", "high_speed.lua"})[params.trackType + 1]
      should be arround the 100 - 150

      and change it to

      local trackType = ({"standard.lua", "high_speed.lua", "extra.lua"})[params.trackType + 1]

      for extra u can add the .lua file of ur track u want to add.


      If you do this for all of your Files yous should have the new track as possible option.
      Warum einfach, wenn es auch schwer geht?
    • I can't find this Option too. I think it's a missing Value thing.

      function StationBuilder.trackTypeUiParam(config)
      return {
      key = "tom_trackType",
      name = _("Track type"),
      values = { _("Standard"), _("High-speed") },
      yearFrom = 1925,
      yearTo = 0
      }
      end

      Something like this. I made some changes to Stations where this was in. Added the track Types in Config and added Values in Script Folder. Some Stations don't have this Lines and thats where im completly lost. By the way. I don't recommend this changes for saved Games. I had crazy behaviours.
    • Advertising