Drop cart and boat after 300s, move Dropondie and new player Items in player_api, remove deprecated function in sethome, signs
This commit is contained in:
parent
1d1021d25d
commit
dfbf1293f6
|
@ -155,12 +155,12 @@ function boat.on_step(self, dtime)
|
||||||
|
|
||||||
self.count = (self.count or 0) + dtime
|
self.count = (self.count or 0) + dtime
|
||||||
|
|
||||||
-- after 30 seconds remove boat and drop as item if not boarded
|
-- after 300 seconds remove boat and drop as item if not boarded
|
||||||
--[[ if self.count > 10 then
|
if self.count > 300 then
|
||||||
minetest.add_item(self.object:get_pos(), "boats:boat")
|
minetest.add_item(self.object:get_pos(), "boats:boat")
|
||||||
self.object:remove()
|
self.object:remove()
|
||||||
return
|
return
|
||||||
end]]
|
end
|
||||||
|
|
||||||
self.v = get_v(self.object:get_velocity()) * get_sign(self.v)
|
self.v = get_v(self.object:get_velocity()) * get_sign(self.v)
|
||||||
if self.driver then
|
if self.driver then
|
||||||
|
|
|
@ -192,6 +192,24 @@ end
|
||||||
|
|
||||||
local v3_len = vector.length
|
local v3_len = vector.length
|
||||||
function cart_entity:on_step(dtime)
|
function cart_entity:on_step(dtime)
|
||||||
|
|
||||||
|
-- Drop cart if there is no player or items inside.
|
||||||
|
if not self.driver and #self.attached_items == 0 then
|
||||||
|
self.count = (self.count or 0) + dtime
|
||||||
|
|
||||||
|
if self.count > 300 then
|
||||||
|
minetest.add_item(self.object:get_pos(), "carts:cart")
|
||||||
|
if self.sound_handle then
|
||||||
|
minetest.sound_stop(self.sound_handle)
|
||||||
|
end
|
||||||
|
self.object:remove()
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
else
|
||||||
|
self.count = 0
|
||||||
|
end
|
||||||
|
|
||||||
rail_sound(self, dtime)
|
rail_sound(self, dtime)
|
||||||
local vel = self.object:get_velocity()
|
local vel = self.object:get_velocity()
|
||||||
if self.punched then
|
if self.punched then
|
||||||
|
@ -405,16 +423,11 @@ function cart_entity:on_step(dtime)
|
||||||
if player and dir.y ~= old_y_dir then
|
if player and dir.y ~= old_y_dir then
|
||||||
local feet = {x=0, y=0, z=0}
|
local feet = {x=0, y=0, z=0}
|
||||||
local eye = {x=0, y=-4, z=0}
|
local eye = {x=0, y=-4, z=0}
|
||||||
feet.y = boost_cart.old_player_model and 6 or -4
|
feet.y = 6
|
||||||
if dir.y ~= 0 then
|
if dir.y ~= 0 then
|
||||||
-- TODO: Find a better way to calculate this
|
-- TODO: Find a better way to calculate this
|
||||||
if boost_cart.old_player_model then
|
|
||||||
feet.y = feet.y + 2
|
feet.y = feet.y + 2
|
||||||
feet.z = -dir.y * 6
|
feet.z = -dir.y * 6
|
||||||
else
|
|
||||||
feet.y = feet.y + 4
|
|
||||||
feet.z = -dir.y * 2
|
|
||||||
end
|
|
||||||
eye.z = -dir.y * 8
|
eye.z = -dir.y * 8
|
||||||
end
|
end
|
||||||
player:set_attach(self.object, "", feet,
|
player:set_attach(self.object, "", feet,
|
||||||
|
|
|
@ -18,7 +18,7 @@ function boost_cart:manage_attachment(player, obj)
|
||||||
default.player_attached[player_name] = status
|
default.player_attached[player_name] = status
|
||||||
|
|
||||||
if status then
|
if status then
|
||||||
local y_pos = self.old_player_model and 6 or -4
|
local y_pos = 6
|
||||||
if player:get_properties().visual == "upright_sprite" then
|
if player:get_properties().visual == "upright_sprite" then
|
||||||
y_pos = -4
|
y_pos = -4
|
||||||
end
|
end
|
||||||
|
@ -233,7 +233,7 @@ function boost_cart:register_rail(name, def_overwrite)
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = {-1/2, -1/2, -1/2, 1/2, -1/2+1/16, 1/2},
|
fixed = {-1/2, -1/2, -1/2, 1/2, -1/2+1/16, 1/2},
|
||||||
},
|
},
|
||||||
sounds = default.node_sound_metal_defaults(),
|
sounds = default.node_sound_metal_defaults()
|
||||||
}
|
}
|
||||||
for k, v in pairs(def_overwrite) do
|
for k, v in pairs(def_overwrite) do
|
||||||
def[k] = v
|
def[k] = v
|
||||||
|
|
|
@ -17,10 +17,6 @@ if not default.player_attached then
|
||||||
default.player_attached = {}
|
default.player_attached = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.after(0, function()
|
|
||||||
boost_cart.old_player_model = not minetest.global_exists("player_api")
|
|
||||||
end)
|
|
||||||
|
|
||||||
dofile(boost_cart.modpath.."/functions.lua")
|
dofile(boost_cart.modpath.."/functions.lua")
|
||||||
dofile(boost_cart.modpath.."/rails.lua")
|
dofile(boost_cart.modpath.."/rails.lua")
|
||||||
|
|
||||||
|
|
|
@ -18,39 +18,6 @@ minetest.register_craft({
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
--[[
|
|
||||||
-- Moreores' copper rail
|
|
||||||
if minetest.get_modpath("moreores") then
|
|
||||||
minetest.register_alias("carts:copperrail", "moreores:copper_rail")
|
|
||||||
|
|
||||||
if minetest.raillike_group then
|
|
||||||
-- Ensure that this rail uses the same connect_to_raillike
|
|
||||||
local new_groups = minetest.registered_nodes["moreores:copper_rail"].groups
|
|
||||||
new_groups.connect_to_raillike = minetest.raillike_group("rail")
|
|
||||||
minetest.override_item("moreores:copper_rail", {
|
|
||||||
groups = new_groups
|
|
||||||
})
|
|
||||||
end
|
|
||||||
else
|
|
||||||
boost_cart:register_rail(":carts:copperrail", {
|
|
||||||
description = "Copper rail",
|
|
||||||
tiles = {
|
|
||||||
"carts_rail_straight_cp.png", "carts_rail_curved_cp.png",
|
|
||||||
"carts_rail_t_junction_cp.png", "carts_rail_crossing_cp.png"
|
|
||||||
},
|
|
||||||
groups = boost_cart:get_rail_groups()
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_craft({
|
|
||||||
output = "carts:copperrail 12",
|
|
||||||
recipe = {
|
|
||||||
{"default:copper_ingot", "", "default:copper_ingot"},
|
|
||||||
{"default:copper_ingot", "group:stick", "default:copper_ingot"},
|
|
||||||
{"default:copper_ingot", "", "default:copper_ingot"},
|
|
||||||
}
|
|
||||||
})
|
|
||||||
end
|
|
||||||
]]
|
|
||||||
-- Power rail
|
-- Power rail
|
||||||
boost_cart:register_rail(":carts:powerrail", {
|
boost_cart:register_rail(":carts:powerrail", {
|
||||||
description = "Powered rail",
|
description = "Powered rail",
|
||||||
|
|
|
@ -17,10 +17,3 @@ License of media (textures and sounds)
|
||||||
--------------------------------------
|
--------------------------------------
|
||||||
Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
|
Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
|
||||||
http://creativecommons.org/licenses/by-sa/3.0/
|
http://creativecommons.org/licenses/by-sa/3.0/
|
||||||
|
|
||||||
Authors of media files
|
|
||||||
-----------------------
|
|
||||||
Everything not listed in here:
|
|
||||||
Copyright (C) 2010-2012 celeron55, Perttu Ahola <celeron55@gmail.com>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -102,6 +102,8 @@ http://freesound.org/people/Ryding/sounds/94337/
|
||||||
Ferk (CC0 1.0):
|
Ferk (CC0 1.0):
|
||||||
default_item_smoke.ogg, based on a sound by http://opengameart.org/users/bart
|
default_item_smoke.ogg, based on a sound by http://opengameart.org/users/bart
|
||||||
|
|
||||||
|
wool_coat_movement.ogg from freeSFX.co.uk and has a Creative Commons license
|
||||||
|
|
||||||
player_damage.1.ogg
|
player_damage.1.ogg
|
||||||
player_damage.2.ogg
|
player_damage.2.ogg
|
||||||
player_damage.3.ogg
|
player_damage.3.ogg
|
||||||
|
|
|
@ -22,11 +22,3 @@ dofile(default_path.."/craftitems.lua")
|
||||||
dofile(default_path.."/crafting.lua")
|
dofile(default_path.."/crafting.lua")
|
||||||
dofile(default_path.."/mapgen.lua")
|
dofile(default_path.."/mapgen.lua")
|
||||||
dofile(default_path.."/aliases.lua")
|
dofile(default_path.."/aliases.lua")
|
||||||
|
|
||||||
if not minetest.settings:get_bool("creative_mode") then
|
|
||||||
minetest.register_on_newplayer(function (player)
|
|
||||||
player:get_inventory():add_item('main', 'default:sword_steel')
|
|
||||||
player:get_inventory():add_item('main', 'default:torch 8')
|
|
||||||
player:get_inventory():add_item('main', 'default:wood 64')
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
|
|
|
@ -1,47 +0,0 @@
|
||||||
local drop = function(pos, itemstack)
|
|
||||||
|
|
||||||
local obj = core.add_item(pos, itemstack:take_item(itemstack:get_count()))
|
|
||||||
|
|
||||||
if obj then
|
|
||||||
|
|
||||||
-- drop stack random distances from player
|
|
||||||
obj:setvelocity({
|
|
||||||
x = math.random(-10, 10) / 9,
|
|
||||||
y = 5,
|
|
||||||
z = math.random(-10, 10) / 9,
|
|
||||||
})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
minetest.register_on_dieplayer(function(player)
|
|
||||||
|
|
||||||
-- are we in creative?
|
|
||||||
if minetest.setting_getbool("creative_mode") then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local pos = player:get_pos()
|
|
||||||
|
|
||||||
-- display death coordinates
|
|
||||||
minetest.chat_send_player(player:get_player_name(),
|
|
||||||
'last known coords were '
|
|
||||||
.. minetest.pos_to_string(vector.round(pos)))
|
|
||||||
|
|
||||||
local player_inv = player:get_inventory()
|
|
||||||
|
|
||||||
-- drop inventory items
|
|
||||||
for i = 1, player_inv:get_size("main") do
|
|
||||||
|
|
||||||
drop(pos, player_inv:get_stack("main", i))
|
|
||||||
|
|
||||||
player_inv:set_stack("main", i, nil)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- drop crafting grid items
|
|
||||||
for i = 1, player_inv:get_size("craft") do
|
|
||||||
|
|
||||||
drop(pos, player_inv:get_stack("craft", i))
|
|
||||||
|
|
||||||
player_inv:set_stack("craft", i, nil)
|
|
||||||
end
|
|
||||||
end)
|
|
|
@ -1,14 +0,0 @@
|
||||||
|
|
||||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
|
||||||
Version 2, December 2004
|
|
||||||
|
|
||||||
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
|
|
||||||
|
|
||||||
Everyone is permitted to copy and distribute verbatim or modified
|
|
||||||
copies of this license document, and changing it is allowed as long
|
|
||||||
as the name is changed.
|
|
||||||
|
|
||||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
|
||||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
|
||||||
|
|
||||||
0. You just DO WHAT THE FUCK YOU WANT TO.
|
|
|
@ -109,3 +109,36 @@ minetest.register_on_joinplayer(function(player)
|
||||||
|
|
||||||
player:get_inventory():set_stack("hand", 1, "player_api:hand")
|
player:get_inventory():set_stack("hand", 1, "player_api:hand")
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
-- Items for the new player
|
||||||
|
minetest.register_on_newplayer(function (player)
|
||||||
|
if creative_mode_cache then
|
||||||
|
player:get_inventory():add_item('main', 'default:sword_steel')
|
||||||
|
player:get_inventory():add_item('main', 'default:torch 8')
|
||||||
|
player:get_inventory():add_item('main', 'default:wood 64')
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
-- Drop items at death
|
||||||
|
minetest.register_on_dieplayer(function(player)
|
||||||
|
local pos = player:get_pos()
|
||||||
|
local inv = player:get_inventory()
|
||||||
|
|
||||||
|
-- Drop inventory items
|
||||||
|
for i = 1, inv:get_size("main") do
|
||||||
|
local stack = inv:get_stack("main", i)
|
||||||
|
minetest.item_drop(stack, nil, pos)
|
||||||
|
inv:set_stack("main", i, nil)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Drop crafting grid items
|
||||||
|
for i = 1, inv:get_size("craft") do
|
||||||
|
local stack = inv:get_stack("craft", i)
|
||||||
|
minetest.item_drop(stack, nil, pos)
|
||||||
|
inv:set_stack("craft", i, nil)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Display death coordinates
|
||||||
|
minetest.chat_send_player(player:get_player_name(), "Your last coordinates: "
|
||||||
|
.. minetest.pos_to_string(vector.round(pos)))
|
||||||
|
end)
|
||||||
|
|
|
@ -1,43 +1,11 @@
|
||||||
|
|
||||||
sethome = {}
|
sethome = {}
|
||||||
|
|
||||||
local homes_file = minetest.get_worldpath() .. "/homes"
|
|
||||||
local homepos = {}
|
|
||||||
|
|
||||||
local function loadhomes()
|
|
||||||
local input = io.open(homes_file, "r")
|
|
||||||
if not input then
|
|
||||||
return -- no longer an error
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Iterate over all stored positions in the format "x y z player" for each line
|
|
||||||
for pos, name in input:read("*a"):gmatch("(%S+ %S+ %S+)%s([%w_-]+)[\r\n]") do
|
|
||||||
homepos[name] = minetest.string_to_pos(pos)
|
|
||||||
end
|
|
||||||
input:close()
|
|
||||||
end
|
|
||||||
|
|
||||||
loadhomes()
|
|
||||||
|
|
||||||
sethome.set = function(name, pos)
|
sethome.set = function(name, pos)
|
||||||
local player = minetest.get_player_by_name(name)
|
local player = minetest.get_player_by_name(name)
|
||||||
if not player or not pos then
|
if not player or not pos then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
player:set_attribute("sethome:home", minetest.pos_to_string(pos))
|
player:set_attribute("sethome:home", minetest.pos_to_string(pos))
|
||||||
|
|
||||||
-- remove `name` from the old storage file
|
|
||||||
local data = {}
|
|
||||||
local output = io.open(homes_file, "w")
|
|
||||||
if output then
|
|
||||||
homepos[name] = nil
|
|
||||||
for i, v in pairs(homepos) do
|
|
||||||
table.insert(data, string.format("%.1f %.1f %.1f %s\n", v.x, v.y, v.z, i))
|
|
||||||
end
|
|
||||||
output:write(table.concat(data))
|
|
||||||
io.close(output)
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
return true -- if the file doesn't exist - don't return an error.
|
return true -- if the file doesn't exist - don't return an error.
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -47,14 +15,6 @@ sethome.get = function(name)
|
||||||
if pos then
|
if pos then
|
||||||
return pos
|
return pos
|
||||||
end
|
end
|
||||||
|
|
||||||
-- fetch old entry from storage table
|
|
||||||
pos = homepos[name]
|
|
||||||
if pos then
|
|
||||||
return vector.new(pos)
|
|
||||||
else
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
sethome.go = function(name)
|
sethome.go = function(name)
|
||||||
|
|
|
@ -268,5 +268,3 @@ minetest.register_node("signs:wall_sign", {
|
||||||
groups = {oddly_breakable_by_hand = 1, choppy = 3,
|
groups = {oddly_breakable_by_hand = 1, choppy = 3,
|
||||||
not_in_creative_inventory = 1, attached_node = 1},
|
not_in_creative_inventory = 1, attached_node = 1},
|
||||||
})
|
})
|
||||||
|
|
||||||
dofile(minetest.get_modpath("signs") .. "/legacy.lua")
|
|
||||||
|
|
|
@ -1,45 +0,0 @@
|
||||||
minetest.register_node(":default:sign_wall_wood", {
|
|
||||||
tiles = {"default_wood.png"},
|
|
||||||
paramtype = "light",
|
|
||||||
paramtype2 = "wallmounted",
|
|
||||||
sunlight_propagates = true,
|
|
||||||
is_ground_content = false,
|
|
||||||
walkable = false,
|
|
||||||
groups = {choppy = 2, attached_node = 1, flammable = 2,
|
|
||||||
oddly_breakable_by_hand = 3, not_in_creative_inventory = 1},
|
|
||||||
legacy_wallmounted = true,
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_lbm({
|
|
||||||
label = "Upgrade legacy signs",
|
|
||||||
name = "signs:sign_wall_update",
|
|
||||||
nodenames = {"default:sign_wall_wood"},
|
|
||||||
run_at_every_load = false,
|
|
||||||
action = function(pos, node)
|
|
||||||
local meta = minetest.get_meta(pos)
|
|
||||||
local text = meta:get_string("text")
|
|
||||||
local p2 = minetest.get_node(pos).param2
|
|
||||||
if p2 <= 1 then
|
|
||||||
minetest.set_node(pos, {name = "signs:sign", param2 = 0})
|
|
||||||
if text and text ~= "" then
|
|
||||||
local obj = minetest.add_entity(vector.add(pos,
|
|
||||||
signs.sign_positions[0][1]), "signs:sign_text")
|
|
||||||
obj:set_properties({
|
|
||||||
textures = {signs.generate_sign_texture(text), "blank.png"}
|
|
||||||
})
|
|
||||||
obj:set_yaw(signs.sign_positions[0][2])
|
|
||||||
end
|
|
||||||
elseif p2 <= 5 then
|
|
||||||
p2 = p2 - 2
|
|
||||||
minetest.set_node(pos, {name = "signs:wall_sign", param2 = p2 + 2})
|
|
||||||
if text and text ~= "" then
|
|
||||||
local obj = minetest.add_entity(vector.add(pos,
|
|
||||||
signs.wall_sign_positions[p2][1]), "signs:sign_text")
|
|
||||||
obj:set_properties({
|
|
||||||
textures = {signs.generate_sign_texture(text), "blank.png"}
|
|
||||||
})
|
|
||||||
obj:set_yaw(signs.wall_sign_positions[p2][2])
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
})
|
|
|
@ -6,5 +6,3 @@ Authors of source code
|
||||||
Originally by Perttu Ahola (celeron55) <celeron55@gmail.com> (MIT)
|
Originally by Perttu Ahola (celeron55) <celeron55@gmail.com> (MIT)
|
||||||
TenPlus1
|
TenPlus1
|
||||||
Various Minetest developers and contributors (MIT)
|
Various Minetest developers and contributors (MIT)
|
||||||
|
|
||||||
Sound is from freeSFX.co.uk and has a creative-commons license
|
|
||||||
|
|
|
@ -18,7 +18,3 @@ for i = 1, #dyes do
|
||||||
recipe = {"group:dye,color_" .. name, "group:wool"},
|
recipe = {"group:dye,color_" .. name, "group:wool"},
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Legacy
|
|
||||||
minetest.register_alias("wool:dark_blue", "wool:blue")
|
|
||||||
minetest.register_alias("wool:gold", "wool:yellow")
|
|
Loading…
Reference in New Issue