init.lua 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. -- sfinv/init.lua
  2. dofile(minetest.get_modpath('sfinv') .. '/api.lua')
  3. -- Load support for MT game translation.
  4. local S = minetest.get_translator('sfinv')
  5. local esc = minetest.formspec_escape
  6. local modstorage = minetest.get_mod_storage()
  7. sfinv.register_page('sfinv:help', {
  8. title = S('Help'),
  9. get = function(self, player, context)
  10. local player_attributes = player:get_meta()
  11. local xp = player_attributes:get_float('xp')
  12. local luck = player_attributes:get_int('luck')
  13. local health = player_attributes:get_int('hp')
  14. local mode = player_attributes:get_string('mode')
  15. if not creative.is_enabled_for(player:get_player_name()) then
  16. return sfinv.make_formspec(player, context,
  17. 'textarea[.25,0;2,3;;;Player Stats:\n XP: '..xp..'\n HP: '..health..'\n Luck: '..luck..'\n'..
  18. 'Playing as:\n '..mode..']'..
  19. 'textarea[2,0;6.5,5.5;;; Traitor is a game based on Among Us. '..
  20. 'Your goal is to vote out the traitor if you are not the traitor, or to kill all the other players if you are the traitor. '..
  21. 'Visit the shop to buy upgrades, privileges, and at some point cosmetics!\n\n'..
  22. ' To create your own level(s) purchase the builder priv and claim a level button.]'
  23. , true)
  24. else
  25. return sfinv.make_formspec(player, context,
  26. 'textarea[.25,0;2,3;;;Player Stats:\n XP: '..xp..'\n HP: '..health..'\n Luck: '..luck..'\n'..
  27. 'Playing as:\n '..mode..']'..
  28. 'textarea[2,0;6.5,10.5;;; As a builder you have the ability to create your own levels, individually or collaboratively with other builders. '..
  29. 'Build any size and with any theme, your imagination is the only limit. (Contact the admin if you need specific nodes/tasks.) '..
  30. 'The spawn area on the level needs to be at minimum 5x5 to prevent players from spawning inside of objects or outside of the map.\n\n'..
  31. ' The first step to building a level is to select an area on the map. '..
  32. 'You should always protect your area as soon as possible to prevent others from damaging it. '..
  33. 'You can always make it larger and add other players to it if you want to build with a friend. '..
  34. 'Once you have the level in a safely playable state you can claim a button in the spawn lobby and fill out the required information. '..
  35. 'The button can be edited by right-clicking with the hammer or wrench. You can also unclaim a button this way. (Note: this won\'t delete the level)\n\n'..
  36. ' Tasks, once placed can be configured with the wrench tool. You can set the infotext, XP reward, and time range for the task to become available.\n\n'..
  37. ' Standard doors from the doors mod can be locked with the wrench. '..
  38. 'There are several options for the type of locking, and further information is given when configuring the lock.\n\n'..
  39. ' Many items that would normally hold inventory can be setup with a stash of eight items. '..
  40. 'Currently cabinets, chests, clocks, and file cabinets can hold items. '..
  41. 'Punch them with a wrench to setup what items should be available for drops. ]'
  42. , false)
  43. end
  44. end
  45. })
  46. sfinv.register_page('sfinv:notes', {
  47. title = 'Notes',
  48. get = function(self, player, context)
  49. local content = modstorage:get_string(player:get_player_name())
  50. context.notes = content
  51. return sfinv.make_formspec(player, context,
  52. 'textarea[0.25,0;8,10;content;;'..esc(content)..']'..
  53. 'textarea[.25,8.75;5.5,.6;;;BE SURE TO HIT THE SAVE BUTTON!!!]'..
  54. 'button[6,8.5;2,1;save_player_note;Save]'
  55. , false)
  56. end,
  57. on_player_receive_fields = function(self, player, context, fields)
  58. if fields.content then
  59. context.notes = fields.content
  60. end
  61. end
  62. })
  63. minetest.register_on_player_receive_fields(function(player, formname, fields)
  64. local name = player:get_player_name()
  65. if fields.save_player_note then
  66. modstorage:set_string(name, fields.content)
  67. end
  68. end)
  69. sfinv.register_page('sfinv:xp', {
  70. title = 'XP',
  71. is_in_nav = function(self, player, context)
  72. return not creative.is_enabled_for(player:get_player_name())
  73. end,
  74. get = function(self, player, context)
  75. local player_attributes = player:get_meta()
  76. local xp = player_attributes:get_float('xp') or 0
  77. return sfinv.make_formspec(player, context,
  78. 'textarea[.25,0;8,5;;; You currently have '..xp..' xp available. use these points to buy perks in a store.\n\n'..
  79. ' This is NOT a pay to win scheme. Items are cosmetic or give buffs, but won\'t protect you from the traitor in any fashion.\n\n'..
  80. ' If you want to build your own levels you can purchase \'buttons\' with your points, and the required privileges to create. '..
  81. 'When joining a game your privileges are cleared, but can be reset once you\'re back in the lobby'..
  82. ' You earn 25 points for every level you win, either as the traitor, or a surviving team member. You can also earn 1 point for each task you complete in the lobby.]'
  83. , false)
  84. end
  85. })
  86. sfinv.register_page('sfinv:debug', {
  87. title = 'Debug',
  88. is_in_nav = function(self, player, context)
  89. return minetest.check_player_privs(player:get_player_name(), { traitor_dev = true })
  90. end,
  91. get = function(self, player, context)
  92. local name = player:get_player_name()
  93. local player_attributes = player:get_meta()
  94. local xp = player_attributes:get_float('xp')
  95. local luck = player_attributes:get_int('luck')
  96. local health = player_attributes:get_int('hp')
  97. local mode = player_attributes:get_string('mode')
  98. local map_id = lobby.game[name]
  99. return sfinv.make_formspec(player, context,
  100. 'textarea[.25,0;3,2;;;Player Stats:\n XP: '..xp..'\n HP: '..health..'\n Luck: '..luck..']'..
  101. 'textarea[3.5,0;3,2;;;Playing as:\n '..mode..'\nOn map:\n '..map_id..']'..
  102. 'textarea[.25,2.5;8,4;;;This screen will be expanded with time to include helpful debug information for people play testing.]'
  103. , false)
  104. end
  105. })
  106. sfinv.register_page('sfinv:clothing', {
  107. title = 'Clothes',
  108. is_in_nav = function(self, player, context)
  109. local player_attributes = player:get_meta()
  110. local mode = player_attributes:get_string('mode')
  111. if mode == 'player' or mode == 'traitor' then
  112. return false
  113. else
  114. return true
  115. end
  116. end,
  117. get = function(self, player, context)
  118. local name = player:get_player_name()
  119. return sfinv.make_formspec(player, context,
  120. 'textarea[.5,3;7.5,3;;;Clothing is layered from right to left in each row. Lower rows are layered over higher rows. Hats/headgear should go in the top row or they may display incorrectly. Swap around clothing locations to see how it effects your looks!]'..
  121. 'list[detached:'..name..'_clothing;slots;2,0;6,3]'..
  122. 'list[current_player;clothing;0,6;8,3;]'..
  123. 'listring[]'
  124. , false)
  125. end
  126. })