areas.lua 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. local priv_areas_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>~~Areas Privilege~~</style></center>]'
  7. local esc = minetest.formspec_escape
  8. local lesson = "The Areas privilege will let you create, rename, transfer, and delete areas that you have created. "..
  9. "To create an area you will need a land deed, one of which will be given to you upon the completion of this course. "..
  10. "Set the corners of the area you want to protect with /area_pos1 and /area_pos2 and protect the area with /protect <areaname>\n"..
  11. "You can add other players to your area using /add_owner <ID> <playername> <areaname>\n"..
  12. "You can list all your areas with /list_areas and can remove an area with /remove_area <ID>\n"..
  13. "If you want to rename an area use /rename_area <ID> <newareaname>\n"..
  14. "The ID of an area can be found by looking in the lower left corner of your screen while you are in the area. It will be a numerical value."..
  15. "You can only protect five areas max size of 128*128*128, and must keep twenty-five nodes space between another players area and your own. "..
  16. "Land deeds are not returned when deleting an area, due to potential exploits. If you want your deed back have an admin delete your area."..
  17. "Be careful when creating an area to make sure there are not other players protection blocks within the area you are trying to protect."
  18. local priv_areas_formspec_lesson =
  19. priv_areas_formspec_base..
  20. "textarea[.75,1.5;11.25,4;;;"..esc(lesson).."]" ..
  21. 'button[4.5,5;3,1;go;Take Quiz]'
  22. local priv_areas_formspec_1 =
  23. priv_areas_formspec_base..
  24. "textarea[1,1.5;11,3;;;What do you need to create an area?]" ..
  25. 'button[1,4;3,1;wrong;A) Land Deed]'..
  26. 'button[4.5,4;3,1;wrong;B) A Diamond Block]'..
  27. 'button[8,4;3,1;wrong;C) A Secret Potion]'..
  28. 'button[1,5.5;3,1;wrong;D) Twenty-five Zombie Teeth]'..
  29. 'button[4.5,5.5;3,1;wrong;E) The Areas Priv]'..
  30. 'button[8,5.5;3,1;right;F) Both A and E]'
  31. local priv_areas_formspec_2 =
  32. priv_areas_formspec_base..
  33. "textarea[1,1.5;11,3;;;How many areas is a player allowed to have?]" ..
  34. 'button[1,4;3,1;wrong;A) One]'..
  35. 'button[4.5,4;3,1;wrong;B) Three]'..
  36. 'button[8,4;3,1;right;C) Five]'..
  37. 'button[1,5.5;3,1;wrong;D) Seven]'..
  38. 'button[4.5,5.5;3,1;wrong;E) Nine]'..
  39. 'button[8,5.5;3,1;wrong;F) Eleven]'
  40. local priv_areas_formspec_3 =
  41. priv_areas_formspec_base..
  42. "textarea[1,1.5;11,3;;;What is the maximum size of an area?]" ..
  43. 'button[1,4;3,1;wrong;A) 32*32*32]'..
  44. 'button[4.5,4;3,1;wrong;B) 40*40*40]'..
  45. 'button[8,4;3,1;wrong;C) 64*64*64]'..
  46. 'button[1,5.5;3,1;wrong;D) 256*256*256]'..
  47. 'button[4.5,5.5;3,1;right;E) 128*128*128]'..
  48. 'button[8,5.5;3,1;wrong;F) 100*100*100]'
  49. local priv_areas_formspec_4 =
  50. priv_areas_formspec_base..
  51. "textarea[1,1.5;11,3;;;How much space do you need to leave between another players area and your own?]" ..
  52. 'button[1,4;3,1;wrong;A) None]'..
  53. 'button[4.5,4;3,1;wrong;B) One Node]'..
  54. 'button[8,4;3,1;wrong;C) Ten Nodes]'..
  55. 'button[1,5.5;3,1;right;D) Twenty-five Nodes]'..
  56. 'button[4.5,5.5;3,1;wrong;E) Fifty Nodes]'..
  57. 'button[8,5.5;3,1;wrong;F) One Hundred Nodes]'
  58. local priv_areas_formspec_5 =
  59. priv_areas_formspec_base..
  60. "textarea[1,1.5;11,3;;;You've passed the quiz! If you haven't taken the quiz before a land deed was added to your inventory, or dropped at your feet.]"..
  61. 'button_exit[4.5,5;3,1;;Exit]'
  62. minetest.register_on_player_receive_fields(function(player, formname, fields)
  63. local name = player:get_player_name()
  64. if formname == 'hall:priv_areas_lesson' then
  65. if fields.go then
  66. minetest.show_formspec(name, 'hall:priv_areas_1', priv_areas_formspec_1)
  67. end
  68. elseif formname == 'hall:priv_areas_1' then
  69. if fields.right then
  70. minetest.show_formspec(name, 'hall:priv_areas_2', priv_areas_formspec_2)
  71. elseif fields.wrong then
  72. minetest.show_formspec(name, 'hall:priv_areas_lesson', priv_areas_formspec_lesson)
  73. end
  74. elseif formname == 'hall:priv_areas_2' then
  75. if fields.right then
  76. minetest.show_formspec(name, 'hall:priv_areas_3', priv_areas_formspec_3)
  77. elseif fields.wrong then
  78. minetest.show_formspec(name, 'hall:priv_areas_lesson', priv_areas_formspec_lesson)
  79. end
  80. elseif formname == 'hall:priv_areas_3' then
  81. if fields.right then
  82. minetest.show_formspec(name, 'hall:priv_areas_4', priv_areas_formspec_4)
  83. elseif fields.wrong then
  84. minetest.show_formspec(name, 'hall:priv_areas_lesson', priv_areas_formspec_lesson)
  85. end
  86. elseif formname == 'hall:priv_areas_4' then
  87. if fields.right then
  88. minetest.show_formspec(name, 'hall:priv_areas_5', priv_areas_formspec_5)
  89. local give = hall.storage:get_string(name..'_areas')
  90. if give ~= 'earned' then
  91. local player_inv = player:get_inventory()
  92. if player_inv:room_for_item('main', 'epic:deed') then
  93. player_inv:add_item('main', 'epic:deed')
  94. else
  95. local drop_pos = player:get_pos()
  96. minetest.add_item(drop_pos, 'epic:deed')
  97. end
  98. end
  99. local privs = minetest.get_player_privs(name)
  100. privs.areas = true
  101. minetest.set_player_privs(name, privs)
  102. hall.storage:set_string(name..'_areas', 'earned')
  103. elseif fields.wrong then
  104. minetest.show_formspec(name, 'hall:priv_areas_lesson', priv_areas_formspec_lesson)
  105. end
  106. end
  107. end)
  108. minetest.register_node('hall:priv_areas', {
  109. description = 'Areas Course',
  110. drawtype = 'mesh',
  111. mesh = 'hall_chalkboard.obj',
  112. tiles = {'hall_chalkboard_areas.png'},
  113. paramtype2 = 'facedir',
  114. paramtype = 'light',
  115. selection_box = {
  116. type = 'fixed',
  117. fixed = {-1, -.75, .4375, 1, .5, .5},
  118. },
  119. collision_box = {
  120. type = 'fixed',
  121. fixed = {-1, -.75, .4375, 1, .5, .5},
  122. },
  123. groups = {oddly_breakable_by_hand = 2, choppy=3, not_in_creative_inventory=1},
  124. on_rightclick = function(pos, node, clicker, itemstack)
  125. local meta = minetest.get_meta(pos)
  126. meta:set_string('infotext', 'Areas Privs Course')
  127. local name = clicker:get_player_name()
  128. minetest.show_formspec(name, 'hall:priv_areas_lesson', priv_areas_formspec_lesson)
  129. end,
  130. })