mirror of
https://github.com/kaeza/minetest-soccer.git
synced 2024-09-22 04:00:26 +02:00
Merge 465ad6cb2d
into d1b2a6b268
This commit is contained in:
commit
40b3df0917
45
README.MD
Normal file
45
README.MD
Normal 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.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
|
local BALL_PUSH_CHECK_INTERVAL = 0.1
|
||||||
|
|
||||||
|
@ -20,12 +25,12 @@ local function reg_ball(color)
|
||||||
on_step = function(self, dtime)
|
on_step = function(self, dtime)
|
||||||
self.timer = self.timer + dtime
|
self.timer = self.timer + dtime
|
||||||
if self.timer >= BALL_PUSH_CHECK_INTERVAL then
|
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
|
self.timer = 0
|
||||||
local vel = self.object:getvelocity()
|
local vel = self.object:get_velocity()
|
||||||
local p = self.object:getpos();
|
local p = self.object:get_pos();
|
||||||
p.y = p.y - 0.5
|
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
|
vel.x = vel.x * 0.85
|
||||||
if vel.y < 0 then vel.y = vel.y * -0.65 end
|
if vel.y < 0 then vel.y = vel.y * -0.65 end
|
||||||
vel.z = vel.z * 0.90
|
vel.z = vel.z * 0.90
|
||||||
|
@ -35,9 +40,9 @@ local function reg_ball(color)
|
||||||
vel.x = 0
|
vel.x = 0
|
||||||
vel.z = 0
|
vel.z = 0
|
||||||
end
|
end
|
||||||
self.object:setvelocity(vel)
|
self.object:set_velocity(vel)
|
||||||
local pos = self.object:getpos()
|
local pos = self.object:get_pos()
|
||||||
local objs = minetest.env:get_objects_inside_radius(pos, 1)
|
local objs = minetest.get_objects_inside_radius(pos, 1)
|
||||||
local player_count = 0
|
local player_count = 0
|
||||||
local final_dir = { x=0, y=0, z=0 }
|
local final_dir = { x=0, y=0, z=0 }
|
||||||
for _,obj in ipairs(objs) do
|
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.x = (final_dir.x * 5) / player_count
|
||||||
final_dir.y = (final_dir.y * 5) / player_count
|
final_dir.y = (final_dir.y * 5) / player_count
|
||||||
final_dir.z = (final_dir.z * 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
|
end
|
||||||
end,
|
end,
|
||||||
|
@ -71,12 +76,12 @@ local function reg_ball(color)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
is_moving = function(self)
|
is_moving = function(self)
|
||||||
local v = self.object:getvelocity()
|
local v = self.object:get_velocity()
|
||||||
if (math.abs(v.x) <= 0.1)
|
if (math.abs(v.x) <= 0.1)
|
||||||
and (math.abs(v.z) <= 0.1) then
|
and (math.abs(v.z) <= 0.1) then
|
||||||
v.x = 0
|
v.x = 0
|
||||||
v.z = 0
|
v.z = 0
|
||||||
self.object:setvelocity(v)
|
self.object:set_velocity(v)
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
|
@ -90,8 +95,8 @@ local function reg_ball(color)
|
||||||
on_place = function(itemstack, placer, pointed_thing)
|
on_place = function(itemstack, placer, pointed_thing)
|
||||||
local pos = pointed_thing.above
|
local pos = pointed_thing.above
|
||||||
--pos = { x=pos.x+0.5, y=pos.y, z=pos.z+0.5 }
|
--pos = { x=pos.x+0.5, y=pos.y, z=pos.z+0.5 }
|
||||||
local ent = minetest.env:add_entity(pos, ball_ent_name)
|
local ent = minetest.add_entity(pos, ball_ent_name)
|
||||||
ent:setvelocity({x=0, y=-15, z=0})
|
ent:set_velocity({x=0, y=-15, z=0})
|
||||||
itemstack:take_item()
|
itemstack:take_item()
|
||||||
return itemstack
|
return itemstack
|
||||||
end,
|
end,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user