12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- local S = minetest.get_translator("wood_and_saws")
- crafting.register_recipe(
- {
- output = "saw",
- type = "inv",
- items = {"cobble 4", "iron_ingot"},
- always_known = true,
- })
- local function saw(itemstack)
- local def = itemstack:get_definition()
- if def and def._sawing_result
- then
- itemstack:take_item()
- minetest.sound_play("wood_and_saws_saw",
- {
- gain = 0.3,
- pos = pos,
- pitch = 1 + ((math.random() - 0.5) / 8)
- })
- return ItemStack(def._sawing_result)
- else
- return ItemStack(nil)
- end
- end
- local function saw_rightclick(pos, node, clicker, itemstack)
- local result = saw(itemstack)
- local inv = clicker:get_inventory()
- local ret = inv:add_item("main", result)
- return itemstack
- end
- local function set_infotext(pos)
- local meta = minetest.get_meta(pos)
- meta:set_string("infotext", S("Saw\n@1", S("Use with logs or planks to saw")))
- end
- minetest.register_node("wood_and_saws:saw",
- {
- description = S("Saw@n@1",
- minetest.colorize("#90FFFF", S("Cuts logs to planks and planks to sticks"))),
- drawtype = "mesh",
- mesh = "wood_and_saws_saw.obj",
- on_rightclick = saw_rightclick,
- tiles =
- {
- {
- name = "wood_and_saws_saw_blade.png",
- animation =
- {
- type = "vertical_frames",
- aspect_w = 16,
- aspect_h = 16,
- length = 0.5,
- },
- },
- "wood_and_saws_saw_base.png"
- },
- groups = {cracky = 3,},
- sounds = generic_media.node_sound_metal_defaults(),
- sunlight_propagates = true,
- inventory_image = "wood_and_saws_saw_inventory.png",
- wield_image = "wood_and_saws_saw_inventory.png",
- is_ground_content = false,
- paramtype2 = "facedir",
- collision_box =
- {
- type = "fixed",
- fixed = {
- {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
- },
- },
- selection_box =
- {
- type = "fixed",
- fixed = {
- {-0.5, 0, 0, 0.5, 0.5, 0},
- {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
- },
- },
- damage_per_second = 5,
- on_construct = set_infotext,
- stack_max = 1,
- })
- minetest.register_alias("saw", "wood_and_saws:saw")
- --https://freesound.org/people/180007/sounds/445526/
|