init.lua 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. -- define global
  2. hopper = {}
  3. -- internationalization boilerplate
  4. local MP = minetest.get_modpath(minetest.get_current_modname())
  5. local S, NS = dofile(MP.."/intllib.lua")
  6. if minetest.get_modpath("default") then
  7. hopper.formspec_bg = default.gui_bg .. default.gui_bg_img .. default.gui_slots
  8. else
  9. hopper.formspec_bg = "bgcolor[#080808BB;true]" .. "listcolors[#00000069;#5A5A5A;#141318;#30434C;#FFF]"
  10. end
  11. dofile(MP.."/config.lua")
  12. dofile(MP.."/api.lua")
  13. dofile(MP.."/utility.lua")
  14. dofile(MP.."/doc.lua")
  15. dofile(MP.."/nodes/hoppers.lua")
  16. dofile(MP.."/nodes/chute.lua")
  17. dofile(MP.."/nodes/sorter.lua")
  18. dofile(MP.."/nodes/trash.lua")
  19. dofile(MP.."/abm.lua")
  20. --dofile(MP.."/crafts.lua") Don't want hoppers craftable by normal means.
  21. -------------------------------------------------------------------------------------------
  22. -- Formspec handling
  23. minetest.register_on_player_receive_fields(function(player, formname, fields)
  24. if "hopper_formspec:" == string.sub(formname, 1, 16) then
  25. local pos = minetest.string_to_pos(string.sub(formname, 17, -1))
  26. local meta = minetest.get_meta(pos)
  27. local eject_setting = meta:get_string("eject") == "true"
  28. local filter_all_setting = meta:get_string("filter_all") == "true"
  29. if fields.eject then
  30. if eject_setting then
  31. meta:set_string("eject", nil)
  32. else
  33. meta:set_string("eject", "true")
  34. end
  35. end
  36. if fields.filter_all then
  37. if filter_all_setting then
  38. meta:set_string("filter_all", nil)
  39. else
  40. meta:set_string("filter_all", "true")
  41. end
  42. end
  43. end
  44. end)