items.lua 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. local S = minetest.get_translator("sailing_canoe")
  2. minetest.register_craftitem("sailing_canoe:sail", {
  3. description = S("Sail"),
  4. inventory_image = "sailing_canoe_sail.png",
  5. })
  6. local itemdef =
  7. {
  8. description = S("Canoe"),
  9. stack_max = 1,
  10. inventory_image = "sailing_canoe_inventory.png",
  11. wield_image = "sailing_canoe_wield.png",
  12. wield_scale = {x = 2, y = 2, z = 1},
  13. liquids_pointable = true,
  14. groups = {flammable = 2},
  15. on_place = function(itemstack, placer, pointed_thing)
  16. if pointed_thing.type ~= "node"
  17. then
  18. return
  19. end
  20. local meta = itemstack:get_meta()
  21. local flag_color = meta:get_string("flag_color")
  22. local sail_color = meta:get_string("sail_color")
  23. if flag_color == ""
  24. then
  25. flag_color = "red"
  26. end
  27. if sail_color == ""
  28. then
  29. sail_color = "white"
  30. end
  31. local staticdata = minetest.serialize(
  32. {
  33. flag_color = flag_color,
  34. sail_color = sail_color,
  35. })
  36. minetest.add_entity(pointed_thing.above, "sailing_canoe:canoe", staticdata)
  37. itemstack:take_item()
  38. return itemstack
  39. end,
  40. }
  41. minetest.register_craftitem("sailing_canoe:canoe", itemdef)