SussyCraft/mods/amogus_items/init.lua
2023-01-12 18:13:21 +01:00

126 lines
3.6 KiB
Lua

minetest.register_craftitem("amogus_items:amogus", {
description = "Amogus",
inventory_image = "amogus_item.png",
--on_use = function(itemstack, user)
-- minetest.sound_play("amogus_sound", {
-- pos = user:get_pos(),
-- gain = 1.0,
-- max_hear_distance = 5
-- })
--end,
--on_place = function(itemstack, placer, pointed_thing)
-- local pos = pointed_thing.above
-- local dir = placer:get_look_dir()
-- local yaw = math.atan(dir.x/dir.z)
-- if dir.z > 0 then
-- yaw = yaw + math.pi
-- end
-- minetest.add_entity(pos, "amogus_entities:amogus", yaw)
--end
on_place = function(itemstack, placer, pointed_thing)
if pointed_thing.type == "node" then
local pos = pointed_thing.above
minetest.add_entity(pos, "amogus_entities:amogus")
minetest.sound_play("amogus_sound", {
pos = pos,
gain = 1.0,
max_hear_distance = 5
})
end
return itemstack
end
})
minetest.register_craftitem("amogus_items:sprite", {
description = "Sprite",
inventory_image = "sprite.png",
on_use = minetest.item_eat(1),
})
minetest.register_craftitem("amogus_items:coke", {
description = "Coke",
inventory_image = "coke.png",
on_use = minetest.item_eat(1),
})
minetest.register_craftitem("amogus_items:fanta", {
description = "Fanta",
inventory_image = "fanta.png",
on_use = minetest.item_eat(1),
})
minetest.register_craftitem("amogus_items:tomato", {
description = "Tomato",
inventory_image = "tomato.png",
on_use = minetest.item_eat(1),
})
minetest.register_craftitem("amogus_items:water", {
inventory_image = "water.png",
on_use = minetest.item_eat(1),
})
minetest.register_tool("amogus_items:lightsaber_blue", {
description = "Blue Lightsaber",
inventory_image = "lightsaber_blue.png",
tool_capabilities = {
full_punch_interval = 0.1,
max_drop_level=3,
groupcaps={
snappy={times={[1]=0.1, [2]=0.1, [3]=0.1}, uses=0, maxlevel=3},
},
damage_groups = {fleshy=10},
},
sound = {breaks = "amogus_sound"},
})
minetest.register_tool("amogus_items:lightsaber_red", {
description = "Red Lightsaber",
inventory_image = "lightsaber_red.png",
tool_capabilities = {
full_punch_interval = 0.1,
max_drop_level=3,
groupcaps={
snappy={times={[1]=0.1, [2]=0.1, [3]=0.1}, uses=0, maxlevel=3},
},
damage_groups = {fleshy=10},
},
sound = {breaks = "amogus_sound"},
})
minetest.register_tool("amogus_items:lightsaber_green", {
description = "Green Lightsaber",
inventory_image = "lightsaber_green.png",
tool_capabilities = {
full_punch_interval = 0.1,
max_drop_level=3,
groupcaps={
snappy={times={[1]=0.1, [2]=0.1, [3]=0.1}, uses=0, maxlevel=3},
},
damage_groups = {fleshy=10},
},
sound = {breaks = "amogus_sound"},
})
-- add lucky block with array of loot that can be easly edited
local loot = {
"amogus_items:amogus",
"amogus_items:sprite",
"amogus_items:coke",
"amogus_items:fanta",
"amogus_items:tomato",
"amogus_items:lightsaber_blue",
"amogus_items:lightsaber_red",
"amogus_items:lightsaber_green",
}
minetest.register_node("amogus_items:lucky_block", {
description = "Lucky Block",
tiles = {"luckyblock.png"},
groups = {cracky = 3},
on_punch = function(pos, node, puncher, pointed_thing)
local item = loot[math.random(#loot)]
minetest.add_item(pos, item)
minetest.remove_node(pos)
end
})