added paraglider

This commit is contained in:
cale 2016-03-12 11:45:04 +01:00
parent fabcf0d703
commit 012bb6afe2
3 changed files with 62 additions and 0 deletions

View File

@ -0,0 +1,16 @@
License for Code
----------------
Copyright (C) 2016 cd2 (cdqwertz) <cdqwertz@gmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
http://www.gnu.org/licenses/lgpl-2.1.html
License for Media
-----------------
CC-BY-SA 3.0 UNPORTED. Created by cd2 (cdqwertz)

46
mods/paraglider/init.lua Normal file
View File

@ -0,0 +1,46 @@
paraglider = {}
paraglider.use = {}
paraglider.automatic = false
minetest.register_craftitem("paraglider:paraglider", {
description = "Paraglider",
inventory_image = "paraglider_item.png",
on_use = function(itemstack, user, pointed_thing)
if not user then
return
end
if paraglider.use[user:get_player_name()] == true then
user:set_physics_override({
gravity = 1,
jump = 1,
})
paraglider.use[user:get_player_name()] = false
else
user:set_physics_override({
gravity = 0.02,
jump = 0,
})
paraglider.use[user:get_player_name()] = true
end
end
})
if paraglider.automatic then
minetest.register_globalstep(function(dtime)
for _, player in pairs(minetest.get_connected_players()) do
local name = player:get_player_name()
--local controls = player:get_player_control()
if paraglider.use[name] == true then
local pos = player:getpos()
if minetest.get_node(vector.new(pos.x, pos.y-1, pos.z)).name ~= "air" then
player:set_physics_override({
gravity = 1,
jump = 1,
})
paraglider.use[name] = false
end
end
end
end)
end

Binary file not shown.

After

Width:  |  Height:  |  Size: 250 B