summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFernando Carmona Varo <ferkiwi@gmail.com>2015-11-11 00:26:01 +0100
committerFernando Carmona Varo <ferkiwi@gmail.com>2015-11-11 00:26:01 +0100
commitc62d9b9a3dfb32dae3377a2fe27c5d1febd7a05a (patch)
treed680f84eb80c34adbdb28639d7b0bfdb16b8dd96
parentc9a814a173e70746b8756ca39bd1fdc694610e8a (diff)
Fixed turtles going through portals, fly/noclip/fast priviledges will be temporarily disabled during the game, and increased a bit ghost radius
-rwxr-xr-xmario/gamestate.lua10
-rw-r--r--mario/portal.lua10
-rw-r--r--mario/turtle.lua14
-rwxr-xr-xpacmine/gamestate.lua10
-rw-r--r--pacmine/ghost.lua2
5 files changed, 40 insertions, 6 deletions
diff --git a/mario/gamestate.lua b/mario/gamestate.lua
index a2bfb89..7f6ec61 100755
--- a/mario/gamestate.lua
+++ b/mario/gamestate.lua
@@ -47,6 +47,14 @@ function mario.game_start(pos, player, gamedef)
mario.games[id] = gamestate
mario.players[id] = player
+ -- store previous priviledges, disable fly whilöe the game is running
+ gamestate.player_privs = minetest.get_player_privs(player_name)
+ local new_privs = table.copy(gamestate.player_privs)
+ new_privs.fly = nil
+ new_privs.noclip = nil
+ new_privs.fast = nil
+ minetest.set_player_privs(player_name, new_privs)
+
minetest.log("action","New mario game started at " .. id .. " by " .. gamestate.player_name)
-- place schematic
@@ -71,6 +79,8 @@ function mario.game_end(id)
mario.remove_hud(player, gamestate.player_name)
player:moveto(vector.add(gamestate.pos,{x=0.5,y=0.5,z=-1.5}))
end
+ -- Restore player priviledges
+ minetest.set_player_privs(gamestate.player_name, gamestate.player_privs)
-- Save score
if gamestate.scorename then
local ranking = myhighscore.save_score(gamestate.scorename, {
diff --git a/mario/portal.lua b/mario/portal.lua
index 1ff31ee..6bee29b 100644
--- a/mario/portal.lua
+++ b/mario/portal.lua
@@ -9,8 +9,8 @@ minetest.register_node("mario:portal", {
walkable = false,
is_ground_content = false,
groups = {cracky = 2,not_in_creative_inventory=1},
- on_player_collision = function(pos, player, gameid)
- player:setpos({x=pos.x,y=pos.y+12,z=pos.z})
+ on_turtle_collision = function(pos, obj, gameid)
+ obj:setpos({x=pos.x,y=pos.y+12,z=pos.z})
end
})
minetest.register_node("mario:portal_left", {
@@ -25,6 +25,9 @@ minetest.register_node("mario:portal_left", {
groups = {cracky = 2,not_in_creative_inventory=0},
on_player_collision = function(pos, player, gameid)
player:setpos(vector.add(pos,{x=31, y=0, z=0}))
+ end,
+ on_turtle_collision = function(pos, obj, gameid)
+ obj:setpos(vector.add(pos,{x=31, y=0, z=0}))
end
})
minetest.register_node("mario:portal_right", {
@@ -39,5 +42,8 @@ minetest.register_node("mario:portal_right", {
groups = {cracky = 2,not_in_creative_inventory=0},
on_player_collision = function(pos, player, gameid)
player:setpos(vector.add(pos,{x=-31, y=0, z=0}))
+ end,
+ on_turtle_collision = function(pos, obj, gameid)
+ obj:setpos(vector.add(pos,{x=31, y=0, z=0}))
end
})
diff --git a/mario/turtle.lua b/mario/turtle.lua
index 546123f..262997e 100644
--- a/mario/turtle.lua
+++ b/mario/turtle.lua
@@ -80,9 +80,17 @@ for i in ipairs(turtles) do
local velocity = self.object:getvelocity()
- -- if our velocity is close to zero, turn around (we are in collision)
+ -- if our velocity is close to zero, we are in collision
if math.abs(velocity.x) < 0.25 then
- self.direction.x = -self.direction.x
+ -- Check if there's a portal or some other node
+ local pos = self.object:getpos()
+ pos.y = pos.y + 0.5
+ local node = minetest.get_node(pos)
+ if minetest.registered_nodes[node.name].on_turtle_collision then
+ minetest.registered_nodes[node.name].on_turtle_collision(pos, self.object, self.gameid)
+ else
+ self.direction.x = -self.direction.x
+ end
if(self.direction.x == 0) then
self.direction.x = 1
end
@@ -121,7 +129,7 @@ for i in ipairs(turtles) do
end
--end
mario.update_hud(self.gameid, player)
-
+
else
diff --git a/pacmine/gamestate.lua b/pacmine/gamestate.lua
index f028e65..5ba5aab 100755
--- a/pacmine/gamestate.lua
+++ b/pacmine/gamestate.lua
@@ -49,6 +49,14 @@ function pacmine.game_start(pos, player, gamedef)
pacmine.games[id] = gamestate
pacmine.players[id] = player
+ -- store previous priviledges, disable fly whilöe the game is running
+ gamestate.player_privs = minetest.get_player_privs(player_name)
+ local new_privs = table.copy(gamestate.player_privs)
+ new_privs.fly = nil
+ new_privs.noclip = nil
+ new_privs.fast = nil
+ minetest.set_player_privs(player_name, new_privs)
+
minetest.log("action","New pacmine game started at " .. id .. " by " .. gamestate.player_name)
-- place schematic
@@ -69,6 +77,8 @@ function pacmine.game_end(id)
pacmine.remove_hud(player, gamestate.player_name)
player:moveto(vector.add(gamestate.pos,{x=0.5,y=0.5,z=-1.5}))
end
+ -- Restore player priviledges
+ minetest.set_player_privs(gamestate.player_name, gamestate.player_privs)
-- Save score
if gamestate.scorename then
local ranking = myhighscore.save_score(gamestate.scorename, {
diff --git a/pacmine/ghost.lua b/pacmine/ghost.lua
index 08167fa..ca9febd 100644
--- a/pacmine/ghost.lua
+++ b/pacmine/ghost.lua
@@ -80,7 +80,7 @@ for i in ipairs(ghosts) do
-- find distance from ghost to player
local distance = ((p.x-s.x)^2 + (p.y-s.y)^2 + (p.z-s.z)^2)^0.5
- if distance < 1.5 then
+ if distance < 1.6 then
-- player touches ghost!!
if gamestate.power_pellet then