Merge 465ad6cb2d
into d1b2a6b268
This commit is contained in:
commit
40b3df0917
|
@ -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.8+ (may work on older versions of MT/MTG).
|
||||
- soccer 0.1.1 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.net/Installing_Mods
|
24
README.txt
24
README.txt
|
@ -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.
|
29
init.lua
29
init.lua
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue