demo.lua 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. -------------------------
  2. -- Sky Layers: Demo
  3. -- Allows quickly test skylayer api
  4. -- Demo disabled by default, see init.lua to enable it.
  5. -- Git: https://gitlab.com/rautars/skylayer
  6. -- License: MIT
  7. -- Credits: rautars
  8. -------------------------
  9. local gradient_plain_with_clouds_sky = function(player_name)
  10. local sl = {}
  11. sl.name = "gradient_plain_with_clouds_sky"
  12. sl.sky_data = {
  13. gradient_colors = {
  14. { r = 68, g = 34, b = 153 },
  15. { r = 59, g = 12, b = 189 },
  16. { r = 51, g = 17, b = 187 },
  17. { r = 68, g = 68, b = 221 },
  18. { r = 17, g = 170, b = 187 },
  19. { r = 18, g = 189, b = 185 },
  20. { r = 34, g = 204, b = 170 },
  21. { r = 105, g = 208, b = 37 },
  22. { r = 170, g = 204, b = 34 },
  23. { r = 208, g = 195, b = 16 },
  24. { r = 204, g = 187, b = 51 },
  25. { r = 254, g = 174, b = 45 },
  26. { r = 255, g = 153, b = 51 },
  27. { r = 255, g = 102, b = 68 },
  28. { r = 255, g = 68, b = 34 },
  29. { r = 255, g = 51, b = 17 },
  30. { r = 248, g = 12, b = 18 },
  31. { r = 255, g = 51, b = 17 },
  32. { r = 255, g = 68, b = 34 },
  33. { r = 255, g = 102, b = 68 },
  34. { r = 255, g = 153, b = 51 },
  35. { r = 254, g = 174, b = 45 },
  36. { r = 204, g = 187, b = 51 },
  37. { r = 208, g = 195, b = 16 },
  38. { r = 170, g = 204, b = 34 },
  39. { r = 105, g = 208, b = 37 },
  40. { r = 34, g = 204, b = 170 },
  41. { r = 18, g = 189, b = 185 },
  42. { r = 17, g = 170, b = 187 },
  43. { r = 68, g = 68, b = 221 },
  44. { r = 51, g = 17, b = 187 },
  45. { r = 59, g = 12, b = 189 }
  46. }
  47. }
  48. sl.clouds_data = {
  49. gradient_colors = {
  50. { r = 34, g = 204, b = 170 },
  51. { r = 105, g = 208, b = 37 },
  52. { r = 170, g = 204, b = 34 },
  53. { r = 208, g = 195, b = 16 },
  54. { r = 204, g = 187, b = 51 },
  55. { r = 254, g = 174, b = 45 },
  56. { r = 255, g = 68, b = 34 },
  57. { r = 255, g = 102, b = 68 },
  58. { r = 255, g = 153, b = 51 },
  59. { r = 254, g = 174, b = 45 },
  60. { r = 59, g = 12, b = 189 }
  61. },
  62. speed = { x = 110, z = -400 }
  63. }
  64. sl.sun_data = {
  65. visible = false,
  66. sunrise_visible = false
  67. }
  68. sl.moon_data = {
  69. visible = false
  70. }
  71. skylayer.add_layer(player_name, sl)
  72. end
  73. local plain_without_clouds_sky = function(player_name)
  74. local sl = {}
  75. sl.name = "plain_without_clouds_sky"
  76. sl.sky_data = {
  77. base_color = { r = 0, g = 0, b = 0 },
  78. clouds = false
  79. }
  80. skylayer.add_layer(player_name, sl)
  81. end
  82. local skybox_with_defaults_sky = function(player_name)
  83. local sl = {}
  84. sl.name = "skybox_with_defaults_sky"
  85. sl.sky_data = {
  86. type = "skybox",
  87. textures = {
  88. "skylayer_demo_stars_sky.png",
  89. "skylayer_demo_stars_sky.png",
  90. "skylayer_demo_stars_sky.png",
  91. "skylayer_demo_stars_sky.png",
  92. "skylayer_demo_stars_sky.png",
  93. "skylayer_demo_stars_sky.png"
  94. }
  95. }
  96. sl.stars_data = {
  97. visible = false
  98. }
  99. skylayer.add_layer(player_name, sl)
  100. end
  101. local custom_moon_with_gradient_stars_sky = function(player_name)
  102. local sl = {}
  103. sl.name = "custom_moon_with_gradient_stars_sky"
  104. sl.moon_data = {
  105. texture = "skylayer_demo_cold_moon.png",
  106. }
  107. sl.stars_data = {
  108. scale = 2,
  109. gradient_star_colors = {
  110. {r=100, g=26, b=0},
  111. {r=100, g=76, b=0},
  112. {r=100, g=0, b=24},
  113. }
  114. }
  115. skylayer.add_layer(player_name, sl)
  116. end
  117. local custom_sun_with_default_sky = function(player_name)
  118. local sl = {}
  119. sl.name = "custom_sun_with_default_sky"
  120. sl.sun_data = {
  121. texture = "skylayer_demo_hot_sun.png",
  122. scale = 3
  123. }
  124. skylayer.add_layer(player_name, sl)
  125. end
  126. local plain_sky_colors_with_defaults_sky = function(player_name)
  127. local sl = {}
  128. sl.name = "plain_sky_colors_with_defaults_sky"
  129. sl.sky_data = {
  130. sky_color = {
  131. day_sky = "#FBF704",
  132. day_horizon = "#F704FB",
  133. dawn_sky = "#EB1914",
  134. dawn_horizon = "#49FF00",
  135. night_sky = "#0F00FF",
  136. night_horizon = "#FF5200",
  137. indoors = "#D9EE11",
  138. fog_sun_tint = "#E0901F",
  139. fog_moon_tint = "#6E9A65"
  140. }
  141. }
  142. skylayer.add_layer(player_name, sl)
  143. end
  144. local gradient_plain_sky_colors_with_defaults_sky = function(player_name)
  145. local sl = {}
  146. sl.name = "gradient_plain_sky_colors_with_defaults_sky"
  147. sl.sky_data = {
  148. gradient_sky = {
  149. day_sky = {
  150. { r = 100, g = 0, b = 6},
  151. { r = 6, g = 100, b = 0},
  152. { r = 0, g = 6, b = 100}
  153. },
  154. day_horizon = {
  155. { r = 100, g = 56, b = 0},
  156. { r = 42, g = 100, b = 0},
  157. { r = 92, g = 100, b = 0}
  158. },
  159. night_sky = {
  160. { r = 0, g = 255, b = 87},
  161. { r = 250, g = 187, b = 100},
  162. { r = 255, g = 82, b = 0}
  163. },
  164. night_horizon = {
  165. { r = 87, g = 100, b = 0},
  166. { r = 0, g = 87, b = 100},
  167. { r = 100, g = 0, b = 87}
  168. },
  169. }
  170. }
  171. skylayer.add_layer(player_name, sl)
  172. end
  173. local sky_definitions = {}
  174. table.insert(sky_definitions, {name = "gradient_plain_with_clouds_sky", func = gradient_plain_with_clouds_sky})
  175. table.insert(sky_definitions, {name = "plain_without_clouds_sky", func = plain_without_clouds_sky})
  176. table.insert(sky_definitions, {name = "skybox_with_defaults_sky", func = skybox_with_defaults_sky})
  177. table.insert(sky_definitions, {name = "custom_moon_with_gradient_stars_sky", func = custom_moon_with_gradient_stars_sky})
  178. table.insert(sky_definitions, {name = "custom_sun_with_default_sky", func = custom_sun_with_default_sky})
  179. table.insert(sky_definitions, {name = "plain_sky_colors_with_defaults_sky", func = plain_sky_colors_with_defaults_sky})
  180. table.insert(sky_definitions, {name = "gradient_plain_sky_colors_with_defaults_sky", func = gradient_plain_sky_colors_with_defaults_sky})
  181. -- register commands for demo for sky definitions from sky_definitions array
  182. local counter = 1
  183. for _, definition in pairs(sky_definitions) do
  184. minetest.register_chatcommand("sl_demo" .. counter .. "_on", {
  185. params = "<player_name>",
  186. description = "Sets sky ".. definition.name .." for a player",
  187. func = function(name, player_name)
  188. if player_name == nil or player_name == "" then
  189. player_name = name
  190. end
  191. definition.func(player_name)
  192. end
  193. })
  194. minetest.register_chatcommand("sl_demo" .. counter .. "_off", {
  195. params = "<player_name>",
  196. description = "Turn off sky ".. definition.name .. " for a player",
  197. func = function(name, player_name)
  198. if player_name == nil or player_name == "" then
  199. player_name = name
  200. end
  201. skylayer.remove_layer(player_name, definition.name)
  202. end
  203. })
  204. counter = counter + 1
  205. end