Skip to content

Instantly share code, notes, and snippets.

@PilzAdam
Created October 28, 2012 18:06
Show Gist options
  • Save PilzAdam/3969325 to your computer and use it in GitHub Desktop.
Save PilzAdam/3969325 to your computer and use it in GitHub Desktop.
local function shoot(pos, dir, damage, speed)
local obj = minetest.env:add_entity(pos, "com:bullet")
obj:setvelocity({x=dir.x*speed, y=dir.y*speed, z=dir.z*speed})
obj:get_luaentity().damage = damage
end
minetest.register_tool("com:ak47", {
description = "Ak 47",
inventory_image = "com_ak47.png",
on_use = function(itemstack, user, pointed_thing)
local pos = user:getpos()
pos.y = pos.y+1.5
shoot(pos, user:get_look_dir(), 4, 5)
end,
})
minetest.register_entity("com:bullet", {
physical = false,
visual = "sprite",
textures = {"com_bullet.png"},
visual_size = {x=0.01, y=0.01},
collisionbox = {0,0,0,0,0,0},
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment