spill.lua 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. local priv_spill_formspec_base =
  2. 'size[12,7]'..
  3. 'no_prepend[]'..
  4. 'bgcolor[#080808BB;true]'..
  5. 'background[0,0;12,7;hall_chalkboard_bg.png]'..
  6. 'hypertext[0,.2;12,1;;<center><style color=white size=40>~~Spill Privilege~~</style></center>]'
  7. local esc = minetest.formspec_escape
  8. local lesson = "The spill privilege will let you empty liquids from buckets. "..
  9. "Due to the griefing potential of liquids there is this quiz. "..
  10. "There are a few things you should know about liquids and spilling them. Besides the obvious that spills can get messy, "..
  11. "lava will start flammable nodes on fire. If you're going to place lava make sure there isn't anything around that can burn. "..
  12. "Keep in mind that Grass is flammable on this server. Water is less dangerous, but due to it's infinite nature "..
  13. "it can easily make a huge mess that will take a while to clean up. \n"..
  14. "Bulk dumping of water and lava underground, away from other players areas is fine. Be it for farming mobs, or making elevators."..
  15. "You must never empty liquids in such a way that they flow into another players protected area(s)."..
  16. "You may face jail time, or banning for intentionally ignoring these rules."
  17. local priv_spill_formspec_lesson =
  18. priv_spill_formspec_base..
  19. "textarea[.75,1.5;11.25,6;;;"..esc(lesson).."]" ..
  20. 'button[4.5,5;3,1;go;Take Quiz]'
  21. local priv_spill_formspec_1 =
  22. priv_spill_formspec_base..
  23. "textarea[1,1.5;11,3;;;What privilege do you need to empty buckets?]" ..
  24. 'button[1,4;3,1;wrong;A) Bucket]'..
  25. 'button[4.5,4;3,1;wrong;B) Liquid]'..
  26. 'button[8,4;3,1;wrong;C) Splash]'..
  27. 'button[1,5.5;3,1;right;D) Spill]'..
  28. 'button[4.5,5.5;3,1;wrong;E) Water]'..
  29. 'button[8,5.5;3,1;wrong;F) Lava]'
  30. local priv_spill_formspec_2 =
  31. priv_spill_formspec_base..
  32. "textarea[1,1.5;11,3;;;Are water elevators allowed?]" ..
  33. 'button[1,4;3,1;wrong;A) No]'..
  34. 'button[4.5,4;3,1;wrong;B) No]'..
  35. 'button[8,4;3,1;wrong;C) No]'..
  36. 'button[1,5.5;3,1;right;D) Yes]'..
  37. 'button[4.5,5.5;3,1;right;E) Yes]'..
  38. 'button[8,5.5;3,1;right;F) Yes]'
  39. local priv_spill_formspec_3 =
  40. priv_spill_formspec_base..
  41. "textarea[1,1.5;11,3;;;Do you need the spill privilege to pick up liquids with a bucket?]" ..
  42. 'button[1,4;3,1;right;A) No]'..
  43. 'button[4.5,4;3,1;wrong;B) Yes]'..
  44. "button[8,4;3,1;right;C) The lesson didn't say]"..
  45. "button[1,5.5;3,1;right;D) I don't know]"..
  46. 'button[4.5,5.5;3,1;wrong;E) This quiz is junk!]'..
  47. "button[8,5.5;3,1;wrong;F) Don't pick me]"
  48. local priv_spill_formspec_4 =
  49. priv_spill_formspec_base..
  50. "textarea[1,1.5;11,3;;;Are you allowed to grief with liquids?]" ..
  51. 'button[1,4;3,1;wrong;A) Yes]'..
  52. 'button[4.5,4;3,1;wrong;B) Sure]'..
  53. 'button[8,4;3,1;wrong;C) Why not?]'..
  54. 'button[1,5.5;3,1;right;D) No]'..
  55. 'button[4.5,5.5;3,1;right;E) Nope]'..
  56. 'button[8,5.5;3,1;right;F) Absolutely not]'
  57. local priv_spill_formspec_5 =
  58. priv_spill_formspec_base..
  59. "textarea[1,1.5;11,3;;;You've passed the quiz! You now have the spill privilege]"..
  60. 'button_exit[4.5,5;3,1;;Exit]'
  61. minetest.register_on_player_receive_fields(function(player, formname, fields)
  62. local name = player:get_player_name()
  63. if formname == 'hall:priv_spill_lesson' then
  64. if fields.go then
  65. minetest.show_formspec(name, 'hall:priv_spill_1', priv_spill_formspec_1)
  66. end
  67. elseif formname == 'hall:priv_spill_1' then
  68. if fields.right then
  69. minetest.show_formspec(name, 'hall:priv_spill_2', priv_spill_formspec_2)
  70. elseif fields.wrong then
  71. minetest.show_formspec(name, 'hall:priv_spill_lesson', priv_spill_formspec_lesson)
  72. end
  73. elseif formname == 'hall:priv_spill_2' then
  74. if fields.right then
  75. minetest.show_formspec(name, 'hall:priv_spill_3', priv_spill_formspec_3)
  76. elseif fields.wrong then
  77. minetest.show_formspec(name, 'hall:priv_spill_lesson', priv_spill_formspec_lesson)
  78. end
  79. elseif formname == 'hall:priv_spill_3' then
  80. if fields.right then
  81. minetest.show_formspec(name, 'hall:priv_spill_4', priv_spill_formspec_4)
  82. elseif fields.wrong then
  83. minetest.show_formspec(name, 'hall:priv_spill_lesson', priv_spill_formspec_lesson)
  84. end
  85. elseif formname == 'hall:priv_spill_4' then
  86. if fields.right then
  87. minetest.show_formspec(name, 'hall:priv_spill_5', priv_spill_formspec_5)
  88. local privs = minetest.get_player_privs(name)
  89. privs.spill = true
  90. minetest.set_player_privs(name, privs)
  91. elseif fields.wrong then
  92. minetest.show_formspec(name, 'hall:priv_spill_lesson', priv_spill_formspec_lesson)
  93. end
  94. end
  95. end)
  96. minetest.register_node('hall:priv_spill', {
  97. description = 'Spill Course',
  98. drawtype = 'mesh',
  99. mesh = 'hall_chalkboard.obj',
  100. tiles = {'hall_chalkboard_spill.png'},
  101. paramtype2 = 'facedir',
  102. paramtype = 'light',
  103. selection_box = {
  104. type = 'fixed',
  105. fixed = {-1, -.75, .4375, 1, .5, .5},
  106. },
  107. collision_box = {
  108. type = 'fixed',
  109. fixed = {-1, -.75, .4375, 1, .5, .5},
  110. },
  111. groups = {oddly_breakable_by_hand = 2, choppy=3, not_in_creative_inventory=1},
  112. on_rightclick = function(pos, node, clicker, itemstack)
  113. local meta = minetest.get_meta(pos)
  114. local name = clicker:get_player_name()
  115. meta:set_string('infotext', 'Spill Privs Course')
  116. minetest.show_formspec(name, 'hall:priv_spill_lesson', priv_spill_formspec_lesson)
  117. end,
  118. })