lumberjack.lua 4.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. local priv_lumberjack_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>~~Lumberjack Privilege~~</style></center>]'
  7. local esc = minetest.formspec_escape
  8. local lesson = "The lumberjack mod should automatically give you the lumberjack privilege after "..
  9. "you harvest enough trees and plant saplings, but it seems to not always work, so if you don't have "..
  10. "the privilege there is this course you can take to get it. :)\n"..
  11. "The lumberjack privilege lets you chop and entire tree by just breaking one node at the bottom.\n"..
  12. "There are no hard rules reguarding chopping down trees, but you should replant when possible so we "..
  13. "don't run out of wood.\n"..
  14. "When cutting down a full tree your axe will take the combined damage of all the nodes, so a very large tree "..
  15. "may add a lot of wear. This is not a bug!"
  16. local priv_lumberjack_formspec_lesson =
  17. priv_lumberjack_formspec_base..
  18. "textarea[.75,1.5;11.25,6;;;"..esc(lesson).."]" ..
  19. 'button[4.5,5;3,1;go;Take Quiz]'
  20. local priv_lumberjack_formspec_1 =
  21. priv_lumberjack_formspec_base..
  22. "textarea[1,1.5;11,3;;;What does the lumberjack priv let you do?]" ..
  23. 'button[1,4;3,1;wrong;A) Grow an epic beard.]'..
  24. 'button[4.5,4;3,1;wrong;B) Do tricks with axes.]'..
  25. 'button[8,4;3,1;wrong;C) Ride log rafts.]'..
  26. 'button[1,5.5;3,1;wrong;D) Juggle chainsaws.]'..
  27. 'button[4.5,5.5;3,1;right;E) Chop down entire trees.]'..
  28. 'button[8,5.5;3,1;wrong;F) Tame blue oxen.]'
  29. local priv_lumberjack_formspec_2 =
  30. priv_lumberjack_formspec_base..
  31. "textarea[1,1.5;11,3;;;Are you REQUIRED to replant every tree you cut down?]" ..
  32. 'button[1,4;3,1;right;A) No]'..
  33. 'button[4.5,4;3,1;right;B) No]'..
  34. 'button[8,4;3,1;right;C) No]'..
  35. 'button[1,5.5;3,1;wrong;D) Yes]'..
  36. 'button[4.5,5.5;3,1;wrong;E) Yes]'..
  37. 'button[8,5.5;3,1;wrong;F) Yes]'
  38. local priv_lumberjack_formspec_3 =
  39. priv_lumberjack_formspec_base..
  40. "textarea[1,1.5;11,3;;;You've passed the quiz! You now have the lumberjack privilege]"..
  41. 'button_exit[4.5,5;3,1;;Exit]'
  42. minetest.register_on_player_receive_fields(function(player, formname, fields)
  43. local name = player:get_player_name()
  44. if formname == 'hall:priv_lumberjack_lesson' then
  45. if fields.go then
  46. minetest.show_formspec(name, 'hall:priv_lumberjack_1', priv_lumberjack_formspec_1)
  47. end
  48. elseif formname == 'hall:priv_lumberjack_1' then
  49. if fields.right then
  50. minetest.show_formspec(name, 'hall:priv_lumberjack_2', priv_lumberjack_formspec_2)
  51. elseif fields.wrong then
  52. minetest.show_formspec(name, 'hall:priv_lumberjack_lesson', priv_lumberjack_formspec_lesson)
  53. end
  54. elseif formname == 'hall:priv_lumberjack_2' then
  55. if fields.right then
  56. minetest.show_formspec(name, 'hall:priv_lumberjack_3', priv_lumberjack_formspec_3)
  57. local privs = minetest.get_player_privs(name)
  58. privs.lumberjack = true
  59. minetest.set_player_privs(name, privs)
  60. elseif fields.wrong then
  61. minetest.show_formspec(name, 'hall:priv_lumberjack_lesson', priv_lumberjack_formspec_lesson)
  62. end
  63. end
  64. end)
  65. minetest.register_node('hall:priv_lumberjack', {
  66. description = 'Lumberjack Course',
  67. drawtype = 'mesh',
  68. mesh = 'hall_chalkboard.obj',
  69. tiles = {'hall_chalkboard_lumberjack.png'},
  70. paramtype2 = 'facedir',
  71. paramtype = 'light',
  72. selection_box = {
  73. type = 'fixed',
  74. fixed = {-1, -.75, .4375, 1, .5, .5},
  75. },
  76. collision_box = {
  77. type = 'fixed',
  78. fixed = {-1, -.75, .4375, 1, .5, .5},
  79. },
  80. groups = {oddly_breakable_by_hand = 2, choppy=3, not_in_creative_inventory=1},
  81. on_rightclick = function(pos, node, clicker, itemstack)
  82. local meta = minetest.get_meta(pos)
  83. meta:set_string('infotext', 'Lumberjack Privs Course')
  84. local name = clicker:get_player_name()
  85. minetest.show_formspec(name, 'hall:priv_lumberjack_lesson', priv_lumberjack_formspec_lesson)
  86. end,
  87. })