common.lua 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. --[[
  2. signs mod for Minetest - Various signs with text displayed on
  3. (c) Pierre-Yves Rollo
  4. This file is part of signs.
  5. signs is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. signs is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with signs. If not, see <http://www.gnu.org/licenses/>.
  15. --]]
  16. local S = signs.intllib
  17. local F = function(...) return minetest.formspec_escape(S(...)) end
  18. -- Generic callback for show_formspec displayed formspecs of "sign" mod
  19. minetest.register_on_player_receive_fields(function(player, formname, fields)
  20. local found, _, mod, node_name, pos = formname:find("^([%w_]+):([%w_]+)@([^:]+)")
  21. if found then
  22. if mod ~= 'signs' then return end
  23. local ndef = minetest.registered_nodes[mod..":"..node_name]
  24. if ndef and ndef.on_receive_fields then
  25. ndef.on_receive_fields(minetest.string_to_pos(pos), formname, fields, player)
  26. end
  27. end
  28. end)