init.lua 827 B

1234567891011121314151617181920212223242526272829
  1. -- Load support for intllib.
  2. local MP = minetest.get_modpath(minetest.get_current_modname())
  3. local S, NS = dofile(MP.."/intllib.lua")
  4. local use_count = 0
  5. minetest.log("action", S("Hello, world!"))
  6. minetest.register_craftitem("intltest:test", {
  7. -- Example use of replacements.
  8. -- Translators: @1 is color, @2 is object.
  9. description = S("Test: @1 @2", S("Blue"), S("Car")),
  10. inventory_image = "default_sand.png",
  11. on_use = function(stack, user, pt)
  12. use_count = use_count + 1
  13. -- Example use of `ngettext` function.
  14. -- First `use_count` is `n` for ngettext;
  15. -- Second one is actual replacement.
  16. -- Translators: @1 is use count.
  17. local message = NS("Item has been used @1 time.",
  18. "Item has been used @1 times.",
  19. use_count, use_count)
  20. minetest.chat_send_player(user:get_player_name(), message)
  21. end,
  22. })