Replace deprecated functions with newer ones

This commit creates compatibility with MT/MTG 5.0.0+.
It replaces deprecated functions with the newer ones.

Also uses "mod.conf" for dependencies and name.
Improved the "README.MD" file: better reading, installation steps, license, dependencies and more.
This commit is contained in:
Panquesito7 2019-06-17 21:25:25 -05:00 committed by GitHub
parent d1b2a6b268
commit 71b2b0d1a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 64 additions and 36 deletions

45
README.MD Normal file
View File

@ -0,0 +1,45 @@
# Soccer
Play soccer on Minetest!
This currently only provides the ball; the actual logic for implementing a match
will be implemented in the future. For now, you can use Mesecons Wooden Pressure
Plates along with some logic to at least handle scoring. Goals are also provided
but have no functionality.
The ball is not craftable ATM. Use /giveme soccer:ball_item, and place it with
right-click. You can take it again by punching it.
You can push the ball by standing near it, and kick it by holding the "sneak"
key (by default "Shift"). The ball will get pushed/kicked in the direction the
player is facing (you can center-on the ball by looking up).
## Dependencies
- default (included in minetest_game)
- wool (included in minetest_game)
## Requirements
- soccer 0.1.0 for MT/MTG 0.4.10+ (may work on older versions of MT/MTG).
- soccer 0.2.0 for MT/MTG 5.0.0+.
## Special thanks
- 12Me21: Ideas about the crafting recipe.
- ecube: Original (black) texture.
- Xiug: Ideas and textures.
## License
See license [here](https://github.com/kaeza/minetest-soccer/blob/master/LICENSE.txt) for further information.
## Installation
- Unzip the archive, rename the folder to "soccer" (**without the quotes**) and
place it in ..minetest/mods/
- GNU/Linux: If you use a system-wide installation place
it in ~/.minetest/mods/.
- If you only want this to be used in a single world, place
the folder in ..worldmods/ in your world directory.
For further information or help, see:
https://wiki.minetest.com/wiki/Installing_Mods

View File

@ -1,24 +0,0 @@
Soccer Mod
----------
Play soccer on Minetest!
This currently only provides the ball; the actual logic for implementing a match
will be implemented in the future. For now, you can use Mesecons Wooden Pressure
Plates along with some logic to at least handle scoring. Goals are also provided
but have no functionality.
The ball is not craftable ATM. Use /giveme soccer:ball_item, and place it with
right-click. You can take it again by punching it.
You can push the ball by standing near it, and kick it by holding the "sneak"
key (by default "Shift"). The ball will get pushed/kicked in the direction the
player is facing (you can center-on the ball by looking up).
Special thanks
--------------
- 12Me21: Ideas about the crafting recipe.
- ecube: Original (black) texture.
- Xiug: Ideas and textures.

View File

@ -1,3 +1,8 @@
--[[
Soccer for Minetest.
Depends: default, wool (both included in minetest_game)
License: BSD-2-Clause (https://github.com/kaeza/minetest-soccer/blob/master/LICENSE.txt)
--]]
local BALL_PUSH_CHECK_INTERVAL = 0.1
@ -20,12 +25,12 @@ local function reg_ball(color)
on_step = function(self, dtime)
self.timer = self.timer + dtime
if self.timer >= BALL_PUSH_CHECK_INTERVAL then
self.object:setacceleration({x=0, y=-10, z=0})
self.object:set_acceleration({x=0, y=-10, z=0})
self.timer = 0
local vel = self.object:getvelocity()
local p = self.object:getpos();
local vel = self.object:get_velocity()
local p = self.object:get_pos();
p.y = p.y - 0.5
if minetest.registered_nodes[minetest.env:get_node(p).name].walkable then
if minetest.registered_nodes[minetest.get_node(p).name].walkable then
vel.x = vel.x * 0.85
if vel.y < 0 then vel.y = vel.y * -0.65 end
vel.z = vel.z * 0.90
@ -35,9 +40,9 @@ local function reg_ball(color)
vel.x = 0
vel.z = 0
end
self.object:setvelocity(vel)
local pos = self.object:getpos()
local objs = minetest.env:get_objects_inside_radius(pos, 1)
self.object:set_velocity(vel)
local pos = self.object:get_pos()
local objs = minetest.get_objects_inside_radius(pos, 1)
local player_count = 0
local final_dir = { x=0, y=0, z=0 }
for _,obj in ipairs(objs) do
@ -57,7 +62,7 @@ local function reg_ball(color)
final_dir.x = (final_dir.x * 5) / player_count
final_dir.y = (final_dir.y * 5) / player_count
final_dir.z = (final_dir.z * 5) / player_count
self.object:setvelocity(final_dir)
self.object:set_velocity(final_dir)
end
end
end,
@ -71,12 +76,12 @@ local function reg_ball(color)
end,
is_moving = function(self)
local v = self.object:getvelocity()
local v = self.object:get_velocity()
if (math.abs(v.x) <= 0.1)
and (math.abs(v.z) <= 0.1) then
v.x = 0
v.z = 0
self.object:setvelocity(v)
self.object:set_velocity(v)
return false
end
return true
@ -90,8 +95,8 @@ local function reg_ball(color)
on_place = function(itemstack, placer, pointed_thing)
local pos = pointed_thing.above
--pos = { x=pos.x+0.5, y=pos.y, z=pos.z+0.5 }
local ent = minetest.env:add_entity(pos, ball_ent_name)
ent:setvelocity({x=0, y=-15, z=0})
local ent = minetest.add_entity(pos, ball_ent_name)
ent:set_velocity({x=0, y=-15, z=0})
itemstack:take_item()
return itemstack
end,

2
mod.conf Normal file
View File

@ -0,0 +1,2 @@
name = soccer
depends = default, wool