forked from LizzyFleckenstein03/Memeclone
Add “On A Rail” achievement
This commit is contained in:
parent
419169d06b
commit
a60c7bbcb6
|
@ -3,6 +3,5 @@ mcl_tools
|
||||||
mcl_core
|
mcl_core
|
||||||
mcl_cake
|
mcl_cake
|
||||||
mcl_mobitems
|
mcl_mobitems
|
||||||
mcl_minecarts
|
|
||||||
mcl_flowerpots
|
mcl_flowerpots
|
||||||
intllib?
|
intllib?
|
||||||
|
|
|
@ -134,6 +134,15 @@ awards.register_achievement("mcl:cookFish", {
|
||||||
icon = "mcl_fishing_fish_cooked.png",
|
icon = "mcl_fishing_fish_cooked.png",
|
||||||
})
|
})
|
||||||
|
|
||||||
|
-- Other achievements triggered outside of mcl_achievements
|
||||||
|
|
||||||
|
-- Triggered in mcl_minecarts
|
||||||
|
awards.register_achievement("mcl:onARail", {
|
||||||
|
title = S("On A Rail"),
|
||||||
|
description = S("Travel by minecart for at least 1000 meters from your starting point in a single ride."),
|
||||||
|
icon = "default_rail.png",
|
||||||
|
})
|
||||||
|
|
||||||
-- NON-PC ACHIEVEMENTS (XBox, Pocket Edition, etc.)
|
-- NON-PC ACHIEVEMENTS (XBox, Pocket Edition, etc.)
|
||||||
|
|
||||||
awards.register_achievement("mcl:n_placeDispenser", {
|
awards.register_achievement("mcl:n_placeDispenser", {
|
||||||
|
@ -194,20 +203,6 @@ awards.register_achievement("mcl:n_emeralds", {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
-- NOT IN MINECRAFT
|
|
||||||
|
|
||||||
-- Replacement for “On a Rail”
|
|
||||||
awards.register_achievement("mcl:f_placeRails", {
|
|
||||||
title = S("Railroad"),
|
|
||||||
icon = "default_rail.png",
|
|
||||||
trigger = {
|
|
||||||
type = "place",
|
|
||||||
node = "mcl_minecarts:rail",
|
|
||||||
target = 1000,
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
-- Show achievements formspec when the button was pressed
|
-- Show achievements formspec when the button was pressed
|
||||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
if fields.__mcl_achievements then
|
if fields.__mcl_achievements then
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
mcl_core
|
mcl_core
|
||||||
mcl_sounds
|
mcl_sounds
|
||||||
mcl_player
|
mcl_player
|
||||||
|
mcl_achievements
|
||||||
mesecons?
|
mesecons?
|
||||||
|
|
|
@ -24,6 +24,7 @@ mcl_minecarts.cart = {
|
||||||
_driver = nil,
|
_driver = nil,
|
||||||
_punched = false, -- used to re-send _velocity and position
|
_punched = false, -- used to re-send _velocity and position
|
||||||
_velocity = {x=0, y=0, z=0}, -- only used on punch
|
_velocity = {x=0, y=0, z=0}, -- only used on punch
|
||||||
|
_start_pos = nil, -- Used to calculate distance for “On A Rail” achievement
|
||||||
_old_dir = {x=0, y=0, z=0},
|
_old_dir = {x=0, y=0, z=0},
|
||||||
_old_pos = nil,
|
_old_pos = nil,
|
||||||
_old_switch = 0,
|
_old_switch = 0,
|
||||||
|
@ -37,9 +38,11 @@ function mcl_minecarts.cart:on_rightclick(clicker)
|
||||||
local player_name = clicker:get_player_name()
|
local player_name = clicker:get_player_name()
|
||||||
if self._driver and player_name == self._driver then
|
if self._driver and player_name == self._driver then
|
||||||
self._driver = nil
|
self._driver = nil
|
||||||
|
self._start_pos = nil
|
||||||
clicker:set_detach()
|
clicker:set_detach()
|
||||||
elseif not self._driver then
|
elseif not self._driver then
|
||||||
self._driver = player_name
|
self._driver = player_name
|
||||||
|
self._start_pos = self.object:getpos()
|
||||||
mcl_player.player_attached[player_name] = true
|
mcl_player.player_attached[player_name] = true
|
||||||
clicker:set_attach(self.object, "", {x=0, y=3, z=0}, {x=0, y=0, z=0})
|
clicker:set_attach(self.object, "", {x=0, y=3, z=0}, {x=0, y=0, z=0})
|
||||||
end
|
end
|
||||||
|
@ -227,6 +230,11 @@ function mcl_minecarts.cart:on_step(dtime)
|
||||||
if self._punched then
|
if self._punched then
|
||||||
self._punched = false
|
self._punched = false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Give achievement when player reached a distance of 1000 nodes from the start position
|
||||||
|
if self._driver and (vector.distance(self._start_pos, pos) >= 1000) then
|
||||||
|
awards.unlock(self._driver, "mcl:onARail")
|
||||||
|
end
|
||||||
|
|
||||||
if not (update.vel or update.pos) then
|
if not (update.vel or update.pos) then
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue