init.lua 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. -------------------------------------------------------------------------------------------
  21. -- Formspec handling
  22. minetest.register_on_player_receive_fields(function(player, formname, fields)
  23. if "hopper_formspec:" == string.sub(formname, 1, 16) then
  24. local pos = minetest.string_to_pos(string.sub(formname, 17, -1))
  25. local meta = minetest.get_meta(pos)
  26. local eject_setting = meta:get_string("eject") == "true"
  27. local filter_all_setting = meta:get_string("filter_all") == "true"
  28. if fields.eject then
  29. if eject_setting then
  30. meta:set_string("eject", nil)
  31. else
  32. meta:set_string("eject", "true")
  33. end
  34. end
  35. if fields.filter_all then
  36. if filter_all_setting then
  37. meta:set_string("filter_all", nil)
  38. else
  39. meta:set_string("filter_all", "true")
  40. end
  41. end
  42. end
  43. end)