SHOW:
|
|
- or go back to the newest paste.
| 1 | - | pos.y = pos.y + 3 |
| 1 | + | minetest.register_craftitem("parachute:parachute_item", {
|
| 2 | - | local ent = minetest.add_entity(pos, "parachute:parachute") |
| 2 | + | inventory_image = "default_brick.png", |
| 3 | - | user:set_attach(ent, "", {x=0,y=0,z=0}, {x=0,y=0,z=0})
|
| 3 | + | on_use = function(itemstack, user, pointed_thing) |
| 4 | - | ent = ent:get_luaentity() |
| 4 | + | local pos = user:getpos() |
| 5 | - | ent:setvelocity({x = 0, y = user:getvelocity().y, z = 0})
|
| 5 | + | local on = minetest.get_node({x = pos.x, y = pos.y - 1, z = pos.z})
|
| 6 | - | ent.attached = user:get_player_name() |
| 6 | + | if on.name == "air" then |
| 7 | pos.y = pos.y + 3 | |
| 8 | local ent = minetest.add_entity(pos, "parachute:parachute") | |
| 9 | user:set_attach(ent, "", {x=0,y=0,z=0}, {x=0,y=0,z=0})
| |
| 10 | ent.object:setvelocity({x = 0, y = user:getvelocity().y, z = 0})
| |
| 11 | ent = ent:get_luaentity() | |
| 12 | ent.attached = user:get_player_name() | |
| 13 | else | |
| 14 | minetest.chat_send_player(user:get_player_name(), "Cannot open parachute on ground!") | |
| 15 | end | |
| 16 | end | |
| 17 | }) |