crafting.lua 935 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. local MT = minetest
  2. local vMod = vm_lighting_wand
  3. local crafting = {}
  4. vMod.set_crafting_items = function(light, handle)
  5. if not light or not handle or light == "LIGHT_ITEM" or handle == "HANDLE_ITEM" then
  6. return
  7. end
  8. crafting = {
  9. light = light,
  10. handle = handle
  11. }
  12. end
  13. vMod.clear_crafting_items = function()
  14. crafting = {}
  15. end
  16. vMod.has_valid_recipe = function()
  17. if not crafting or not crafting.light or not crafting.handle then
  18. return false
  19. end
  20. return true
  21. end
  22. vMod.add_crafting_recipe = function()
  23. if vMod.loaded then
  24. vMod.logger("add_crafting_recipe() called but game is already loaded")
  25. return
  26. end
  27. if not vMod.has_valid_recipe() then
  28. vMod.logger("crafting recipe not registered.")
  29. else
  30. MT.register_craft({
  31. output = vMod.tool,
  32. recipe = { { crafting.light }, { crafting.handle }, { crafting.handle } }
  33. })
  34. vMod.logger("crafting recipe registered.")
  35. end
  36. end