api.txt 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. Here is an example of how to register a bow:
  2. bows.register_bow("bow_wood",{
  3. description = "Wooden bow",
  4. texture = "bows_bow.png",
  5. texture_loaded = "bows_bow_loaded.png",
  6. uses = 50, -- How many time you can use a bow to shoot
  7. level = 1, -- Higher levels mean faster arrows
  8. -- Crafting recipe to make bow, can be left nil
  9. craft = {
  10. {"", "group:stick", "farming:string"},
  11. {"group:stick", "", "farming:string"},
  12. {"", "group:stick", "farming:string"}
  13. },
  14. })
  15. Here is an example of how to register an arrow:
  16. bows.register_arrow("arrow_steel",{
  17. description = "Steel arrow",
  18. -- Arrow texture, the ^[colorize section changes the default arrows colour
  19. texture = "bows_arrow_wood.png^[colorize:#FFFFFFcc",
  20. damage = 8, -- How many 1/2 hearts damage it can do
  21. craft_count = 4, -- How many arrows are made from recipe below
  22. craft = {
  23. {"default:steel_ingot", "group:stick", bows.feather}
  24. },
  25. -- Special function when an entity or mob is hit
  26. on_hit_object = function(self, target, hp, user, lastpos)
  27. if target:get_luaentity().name == "mob_horse:horse" then
  28. print ("--- aww da horsey!!! " .. hp .. " damage points!")
  29. end
  30. end,
  31. -- Special function when arrow hits a node
  32. on_hit_node = function(self, pos, user, arrow_pos)
  33. if self.node.name == "default:glass" then
  34. minetest.sound_play("default_break_glass", {
  35. pos = pos, gain = 1.0, max_hear_distance = 10})
  36. minetest.remove_node(pos)
  37. minetest.add_item(pos, "vessels:glass_fragments")
  38. end
  39. end,
  40. })