123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- gunpowder_barrels = {}
- local modpath = minetest.get_modpath("gunpowder_barrels")
- dofile(modpath.."/explosion.lua")
- dofile(modpath .. "/barrel_entity.lua")
- local S = minetest.get_translator("gunpowder_barrels")
- minetest.register_craftitem("gunpowder_barrels:barrel_item", {
- description = S("Gunpowder Barrel"),
- inventory_image = "gunpowder_barrels_barrel.png",
- stack_max = 16,
- on_use = function(itemstack, user, pointed_thing) --throw
- if user
- then
- if pointed_thing.type == "object"
- then
- assert(pointed_thing.ref, "ref is not")
- pointed_thing.ref:punch(user, 0, {})
- else
- local throwdir = minetest.serialize(vector.multiply(user:get_look_dir(), 10))
- minetest.add_entity(vector.add(user:get_pos(), {x = 0, y = 2, z = 0}),
- "gunpowder_barrels:barrel_entity", throwdir)
- end
- end
- itemstack:take_item(1)
- return itemstack
- end,
- on_place = function(itemstack, user, pointed_thing) --place
- if user and pointed_thing.type == "node"
- then
- minetest.add_entity(pointed_thing.above,
- "gunpowder_barrels:barrel_entity")
- end
- itemstack:take_item(1)
- return itemstack
- end,
- })
- minetest.register_alias("bomb", "gunpowder_barrels:barrel_item")
- minetest.register_alias("gunpowder_barrel", "gunpowder_barrels:barrel_item")
|