fire.lua 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. local priv_fire_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>~~Fire Privilege~~</style></center>]'
  7. local esc = minetest.formspec_escape
  8. local lesson = "The Fire privilege will let you start things on fire, and use explosives. "..
  9. "Due to the potentially dangerous nature of these things it's important that you understand required safety precautions. "..
  10. "On this server grass can burn, so it is all the more important to construct fire lanes before starting fires. "..
  11. "A good firelane will be two nodes wide, built of a nonflammable material, and have some anti-fire powder placed in it as well. "..
  12. "If you don't have anti-fire powder be sure and watch the fire lane and stop any fire that may pass over. "..
  13. "Starting fires that get out of hand can be grounds for jailing, and if repeated potential banning. "..
  14. "You can start fires with Flint & Steel and Lava."
  15. local priv_fire_formspec_lesson =
  16. priv_fire_formspec_base..
  17. "textarea[.75,1.5;11.25,6;;;"..esc(lesson).."]" ..
  18. 'button[4.5,5;3,1;go;Take Quiz]'
  19. local priv_fire_formspec_1 =
  20. priv_fire_formspec_base..
  21. "textarea[1,1.5;11,3;;;Is fire enabled on this server?]" ..
  22. 'button[1,4;3,1;wrong;A) Do pigs fly?]'..
  23. 'button[4.5,4;3,1;wrong;B) Certainly Not]'..
  24. 'button[8,4;3,1;wrong;C) A Nope]'..
  25. 'button[1,5.5;3,1;right;D) Yes]'..
  26. 'button[4.5,5.5;3,1;wrong;E) No]'..
  27. 'button[8,5.5;3,1;right;F) Yep]'
  28. local priv_fire_formspec_2 =
  29. priv_fire_formspec_base..
  30. "textarea[1,1.5;11,3;;;What makes a good fire lane?]" ..
  31. 'button[1,4;3,1;wrong;A) Lava]'..
  32. 'button[4.5,4;3,1;right;B) Water]'..
  33. 'button[8,4;3,1;wrong;C) Dirt with Grass]'..
  34. 'button[1,5.5;3,1;right;D) Stone]'..
  35. 'button[4.5,5.5;3,1;right;E) Anti-fire Powder]'..
  36. 'button[8,5.5;3,1;right;F) Nonflamable Nodes]'
  37. local priv_fire_formspec_3 =
  38. priv_fire_formspec_base..
  39. "textarea[1,1.5;11,3;;;How wide should a firelane be?]" ..
  40. 'button[1,4;3,1;wrong;A) 1 Node or More]'..
  41. 'button[4.5,4;3,1;right;B) 2 Nodes or More]'..
  42. 'button[8,4;3,1;wrong;C) 3 Nodes or More]'..
  43. 'button[1,5.5;3,1;wrong;D) 4 Nodes or More]'..
  44. 'button[4.5,5.5;3,1;wrong;E) 5 Nodes or More]'..
  45. 'button[8,5.5;3,1;wrong;F) 6 Nodes or More]'
  46. local priv_fire_formspec_4 =
  47. priv_fire_formspec_base..
  48. "textarea[1,1.5;11,3;;;Which of the follow can start fires.?]" ..
  49. 'button[1,4;3,1;wrong;A) Flint & Steel]'..
  50. 'button[4.5,4;3,1;wrong;B) Lava]'..
  51. 'button[8,4;3,1;wrong;C) Torches]'..
  52. 'button[1,5.5;3,1;wrong;D) Brasiers]'..
  53. 'button[4.5,5.5;3,1;wrong;E) Hot Cobble]'..
  54. 'button[8,5.5;3,1;right;F) Both A and B]'
  55. local priv_fire_formspec_5 =
  56. priv_fire_formspec_base..
  57. "textarea[1,1.5;11,3;;;You've passed the quiz! You now have the fire privilege. Remember only YOU can prevent forest fires.]"..
  58. 'button_exit[4.5,5;3,1;;Exit]'
  59. minetest.register_on_player_receive_fields(function(player, formname, fields)
  60. local name = player:get_player_name()
  61. if formname == 'hall:priv_fire_lesson' then
  62. if fields.go then
  63. minetest.show_formspec(name, 'hall:priv_fire_1', priv_fire_formspec_1)
  64. end
  65. elseif formname == 'hall:priv_fire_1' then
  66. if fields.right then
  67. minetest.show_formspec(name, 'hall:priv_fire_2', priv_fire_formspec_2)
  68. elseif fields.wrong then
  69. minetest.show_formspec(name, 'hall:priv_fire_lesson', priv_fire_formspec_lesson)
  70. end
  71. elseif formname == 'hall:priv_fire_2' then
  72. if fields.right then
  73. minetest.show_formspec(name, 'hall:priv_fire_3', priv_fire_formspec_3)
  74. elseif fields.wrong then
  75. minetest.show_formspec(name, 'hall:priv_fire_lesson', priv_fire_formspec_lesson)
  76. end
  77. elseif formname == 'hall:priv_fire_3' then
  78. if fields.right then
  79. minetest.show_formspec(name, 'hall:priv_fire_4', priv_fire_formspec_4)
  80. elseif fields.wrong then
  81. minetest.show_formspec(name, 'hall:priv_fire_lesson', priv_fire_formspec_lesson)
  82. end
  83. elseif formname == 'hall:priv_fire_4' then
  84. if fields.right then
  85. minetest.show_formspec(name, 'hall:priv_fire_5', priv_fire_formspec_5)
  86. local privs = minetest.get_player_privs(name)
  87. privs.fire = true
  88. minetest.set_player_privs(name, privs)
  89. elseif fields.wrong then
  90. minetest.show_formspec(name, 'hall:priv_fire_lesson', priv_fire_formspec_lesson)
  91. end
  92. end
  93. end)
  94. minetest.register_node('hall:priv_fire', {
  95. description = 'Fire Course',
  96. drawtype = 'mesh',
  97. mesh = 'hall_chalkboard.obj',
  98. tiles = {'hall_chalkboard_fire.png'},
  99. paramtype2 = 'facedir',
  100. paramtype = 'light',
  101. selection_box = {
  102. type = 'fixed',
  103. fixed = {-1, -.75, .4375, 1, .5, .5},
  104. },
  105. collision_box = {
  106. type = 'fixed',
  107. fixed = {-1, -.75, .4375, 1, .5, .5},
  108. },
  109. groups = {oddly_breakable_by_hand = 2, choppy=3, not_in_creative_inventory=1},
  110. on_rightclick = function(pos, node, clicker, itemstack)
  111. local meta = minetest.get_meta(pos)
  112. local name = clicker:get_player_name()
  113. meta:set_string('infotext', 'Fire Privs Course')
  114. minetest.show_formspec(name, 'hall:priv_fire_lesson', priv_fire_formspec_lesson)
  115. end,
  116. })