Advertisement
alaestor

[WTFL] Stellaris - Comparing In A Loop

Apr 13th, 2019 (edited)
549
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.00 KB | None | 0 0
  1. # the following Stellaris event (written in what I have dubbed "WTFLanguage") is used to find whichever star system is furthest from the galactic core (or at least one that's "close enough" due reasons you'll soon discover). One of the biggest "wait, what?" moments is when you realize that we can't assign "last_distance = distance_to_core", we actually need to guess at what the value of "distance_to_core" will be, and then assign that as a literal.
  2.  
  3. # in a perfect world, using C++ syntax for comparison; we would write the following:
  4.  
  5. # system* last = randomSystem();
  6. # for (const auto& s : every_rim_system) if (s.distance > last->distance) last = &s;
  7. # // and now, "last" points to the system with the highest distance from the galactic core.
  8.  
  9. # But, in the nightmare that is Stellaris' WTFL:
  10.  
  11. #****************************#
  12. # Find most outer-rim system #
  13. #****************************#
  14. country_event =
  15. {
  16. id = fgl_on_gamestart.101
  17. hide_window = yes
  18. is_triggered_only = yes
  19.  
  20. immediate =
  21. {
  22. hidden_effect =
  23. {
  24. set_variable = { which = fgl_gm_lastDistance value = 0.0 }
  25. set_variable = { which = fgl_gm_currDistance value = 0.0 }
  26. every_rim_system =
  27. {
  28. limit={AND={ NOT={ exists = space_owner } distance_to_core_percent > 0.79 }}
  29.  
  30. #log = "and we're looping"
  31.  
  32. # Variables can't be assigned values from other variables...
  33. # Yes. You read that right. Welcome to WTFL
  34. # Because we can't just "assign y the value of x", instead
  35. # we need to ask "is x equal to 5? then assign y the value of 5"
  36. # and no, I'm not joking...
  37.  
  38. if = { limit = { distance_to_core_percent > 0.79 } prev = { set_variable = { which = fgl_gm_currDistance value = 0.80 } } }
  39. if = { limit = { distance_to_core_percent > 0.80 } prev = { set_variable = { which = fgl_gm_currDistance value = 0.81 } } }
  40. if = { limit = { distance_to_core_percent > 0.81 } prev = { set_variable = { which = fgl_gm_currDistance value = 0.82 } } }
  41. if = { limit = { distance_to_core_percent > 0.82 } prev = { set_variable = { which = fgl_gm_currDistance value = 0.83 } } }
  42. if = { limit = { distance_to_core_percent > 0.83 } prev = { set_variable = { which = fgl_gm_currDistance value = 0.84 } } }
  43. if = { limit = { distance_to_core_percent > 0.84 } prev = { set_variable = { which = fgl_gm_currDistance value = 0.85 } } }
  44. if = { limit = { distance_to_core_percent > 0.85 } prev = { set_variable = { which = fgl_gm_currDistance value = 0.86 } } }
  45. if = { limit = { distance_to_core_percent > 0.86 } prev = { set_variable = { which = fgl_gm_currDistance value = 0.87 } } }
  46. if = { limit = { distance_to_core_percent > 0.87 } prev = { set_variable = { which = fgl_gm_currDistance value = 0.88 } } }
  47. if = { limit = { distance_to_core_percent > 0.88 } prev = { set_variable = { which = fgl_gm_currDistance value = 0.89 } } }
  48. if = { limit = { distance_to_core_percent > 0.89 } prev = { set_variable = { which = fgl_gm_currDistance value = 0.90 } } }
  49. if = { limit = { distance_to_core_percent > 0.90 } prev = { set_variable = { which = fgl_gm_currDistance value = 0.91 } } }
  50. if = { limit = { distance_to_core_percent > 0.91 } prev = { set_variable = { which = fgl_gm_currDistance value = 0.92 } } }
  51. if = { limit = { distance_to_core_percent > 0.92 } prev = { set_variable = { which = fgl_gm_currDistance value = 0.93 } } }
  52. if = { limit = { distance_to_core_percent > 0.93 } prev = { set_variable = { which = fgl_gm_currDistance value = 0.94 } } }
  53. if = { limit = { distance_to_core_percent > 0.94 } prev = { set_variable = { which = fgl_gm_currDistance value = 0.95 } } }
  54. if = { limit = { distance_to_core_percent > 0.95 } prev = { set_variable = { which = fgl_gm_currDistance value = 0.96 } } }
  55. if = { limit = { distance_to_core_percent > 0.96 } prev = { set_variable = { which = fgl_gm_currDistance value = 0.97 } } }
  56. if = { limit = { distance_to_core_percent > 0.97 } prev = { set_variable = { which = fgl_gm_currDistance value = 0.98 } } }
  57. if = { limit = { distance_to_core_percent > 0.98 } prev = { set_variable = { which = fgl_gm_currDistance value = 0.99 } } }
  58. if = { limit = { distance_to_core_percent > 0.99 } prev = { set_variable = { which = fgl_gm_currDistance value = 1.00 } } }
  59.  
  60. # yep, that's correct... Our decimal place resolution is determined by how many IFs we write.
  61. # God help us if the largest is < 80%... just break I guess?
  62. # now we check to see if currDistance is greater than lastDistance
  63. # if so, we want to change fgl_best_system and update lastDistance
  64.  
  65. if = { limit = { prev = { check_variable = { which = fgl_gm_currDistance value > fgl_gm_lastDistance } } }
  66. save_event_target_as = fgl_best_system
  67. #log = "fgl_best_system updated"
  68.  
  69. prev =
  70. {
  71. set_variable = { which = fgl_gm_lastDistance value = 0.79 }
  72. while ={limit = { check_variable = { which = fgl_gm_lastDistance value < fgl_gm_currDistance } }
  73. change_variable = { which = fgl_gm_lastDistance value = 0.01 }
  74. }
  75. }
  76. }
  77. }
  78. }
  79. }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement