init.lua 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. -- Unified Inventory for Minetest 0.4.8+
  2. local modpath = minetest.get_modpath(minetest.get_current_modname())
  3. local worldpath = minetest.get_worldpath()
  4. local mygettext
  5. if rawget(_G, "intllib") then
  6. mygettext = intllib.Getter()
  7. else
  8. function mygettext(s, ...)
  9. local t = { ... }
  10. return (s:gsub("@(%d+)", function(n) return t[tonumber(n)] end))
  11. end
  12. end
  13. -- Data tables definitions
  14. unified_inventory = {
  15. activefilter = {},
  16. active_search_direction = {},
  17. alternate = {},
  18. current_page = {},
  19. current_searchbox = {},
  20. current_index = {},
  21. current_item = {},
  22. current_craft_direction = {},
  23. registered_craft_types = {},
  24. crafts_for = {usage = {}, recipe = {} },
  25. players = {},
  26. items_list_size = 0,
  27. items_list = {},
  28. filtered_items_list_size = {},
  29. filtered_items_list = {},
  30. pages = {},
  31. buttons = {},
  32. -- Homepos stuff
  33. home_pos = {},
  34. home_filename = worldpath.."/unified_inventory_home.home",
  35. -- Default inventory page
  36. default = "craft",
  37. -- intllib
  38. gettext = mygettext,
  39. fgettext = function(...) return minetest.formspec_escape(mygettext(...)) end,
  40. -- "Lite" mode
  41. lite_mode = minetest.setting_getbool("unified_inventory_lite"),
  42. -- Trash enabled
  43. trash_enabled = (minetest.setting_getbool("unified_inventory_trash") ~= false),
  44. pagecols = 8,
  45. pagerows = 10,
  46. page_y = 0,
  47. formspec_y = 1,
  48. main_button_x = 0,
  49. main_button_y = 9,
  50. craft_result_x = 0.3,
  51. craft_result_y = 0.5,
  52. form_header_y = 0
  53. }
  54. -- Disable default creative inventory
  55. local creative = rawget(_G, "creative") or rawget(_G, "creative_inventory")
  56. if creative then
  57. function creative.set_creative_formspec(player, start_i, pagenum)
  58. return
  59. end
  60. end
  61. -- Disable sfinv inventory
  62. local sfinv = rawget(_G, "sfinv")
  63. if sfinv then
  64. sfinv.enabled = false
  65. end
  66. dofile(modpath.."/group.lua")
  67. dofile(modpath.."/api.lua")
  68. dofile(modpath.."/internal.lua")
  69. dofile(modpath.."/callbacks.lua")
  70. dofile(modpath.."/register.lua")
  71. if minetest.setting_getbool("unified_inventory_bags") ~= false then
  72. dofile(modpath.."/bags.lua")
  73. end
  74. dofile(modpath.."/item_names.lua")
  75. if minetest.get_modpath("datastorage") then
  76. dofile(modpath.."/waypoints.lua")
  77. end