update farming and areas mod

master
crabman77 2015-10-27 00:14:52 +01:00
parent b34cc6c66e
commit b15d1f5d21
47 changed files with 447 additions and 44 deletions

View File

@ -13,6 +13,9 @@ This mod works by adding your new plant to the {growing=1} group and numbering t
Changelog:
1.22 - Added grape bushes at high climates which can be cultivated into grape vines using trellis (9 sticks).
1.21 - Added auto-refill code for planting crops (thanks crabman77), also fixed a few bugs
1.20b- Tidied code, made api compatible with new 0.4.13 changes and changed to soil texture overlays
1.20 - NEW growing routine added that allows crops to grow while player is away doing other things (thanks prestidigitator)
1.14 - Added Green Beans from Crops mod (thanks sofar), little bushels in the wild but need to be grown using beanpoles crafted with 4 sticks (2 either side)
1.13 - Fixed seed double-placement glitch. Mapgen now uses 0.4.12+ for plant generation

View File

@ -9,6 +9,7 @@ minetest.register_craftitem("farming:beans", {
inventory_image = "farming_beans.png",
on_use = minetest.item_eat(1),
on_place = function(itemstack, placer, pointed_thing)
if minetest.is_protected(pointed_thing.above, placer:get_player_name()) then return end
local nod = minetest.get_node_or_nil(pointed_thing.under)
if nod and nod.name == "farming:beanpole" then
minetest.set_node(pointed_thing.under, {name="farming:beanpole_1"})
@ -17,9 +18,15 @@ minetest.register_craftitem("farming:beans", {
end
if not minetest.setting_getbool("creative_mode") then
itemstack:take_item()
if itemstack:get_count() == 0 then--MFF DEBUT crabman(26/08/2015) refill placed plant
minetest.after(0.20, farming.refill_plant, placer, "farming:beans", placer:get_wield_index())
end --MFF FIN
-- check for refill
if itemstack:get_count() == 0 then
minetest.after(0.20,
farming.refill_plant,
placer,
"farming:beans",
placer:get_wield_index()
)
end -- END refill
end
return itemstack
end
@ -57,6 +64,7 @@ minetest.register_node("farming:beanpole", {
},
sounds = default.node_sound_leaves_defaults(),
on_place = function(itemstack, placer, pointed_thing)
if minetest.is_protected(pointed_thing.above, placer:get_player_name()) then return end
local nod = minetest.get_node_or_nil(pointed_thing.under)
if nod and minetest.get_item_group(nod.name, "soil") < 2 then
return
@ -85,6 +93,12 @@ minetest.register_craft({
}
})
minetest.register_craft({
type = "fuel",
recipe = "farming:beanpole",
burntime = 10,
})
-- Define Green Bean growth stages
minetest.register_node("farming:beanpole_1", {
@ -221,4 +235,4 @@ minetest.register_node("farming:beanbush", {
not_in_creative_inventory=1
},
sounds = default.node_sound_leaves_defaults(),
})
})

View File

@ -22,7 +22,7 @@ function place_cocoa(itemstack, placer, pointed_thing, plantname)
end
-- add the node and remove 1 item from the itemstack
minetest.add_node(pt.above, {name = plantname})
minetest.set_node(pt.above, {name = plantname})
if not minetest.setting_getbool("creative_mode") then
itemstack:take_item()
-- check for refill
@ -99,7 +99,7 @@ minetest.register_node("farming:cocoa_1", {
},
selection_box = {
type = "fixed",
fixed = {-0.27, -0.45, -0.27, 0.27, 0.45, 0.27}
fixed = {-0.3, -0.5, -0.3, 0.3, 0.5, 0.3}
},
groups = {
snappy = 3, flammable = 2, plant = 1, growing = 1,

View File

@ -0,0 +1,295 @@
-- Grapes
minetest.register_craftitem("farming:grapes", {
description = "Grapes",
inventory_image = "farming_grapes.png",
on_use = minetest.item_eat(2),
on_place = function(itemstack, placer, pointed_thing)
if minetest.is_protected(pointed_thing.above, placer:get_player_name()) then return end
local nod = minetest.get_node_or_nil(pointed_thing.under)
if nod and nod.name == "farming:trellis" then
minetest.set_node(pointed_thing.under, {name="farming:grapes_1"})
else
return
end
if not minetest.setting_getbool("creative_mode") then
itemstack:take_item()
-- check for refill
if itemstack:get_count() == 0 then
minetest.after(0.20,
farming.refill_plant,
placer,
"farming:grapes",
placer:get_wield_index()
)
end -- END refill
end
return itemstack
end
})
-- Grapes can be used for violet dye
minetest.register_craft({
output = "dye:violet",
recipe = {
{'farming:grapes'},
}
})
-- Trellis
minetest.register_node("farming:trellis", {
description = "Trellis (place on soil before planting grapes)",
drawtype = "plantlike",
tiles = {"farming_trellis.png"},
inventory_image = "farming_trellis.png",
visual_scale = 1.45,
paramtype = "light",
walkable = false,
buildable_to = true,
sunlight_propagates = true,
drop = {
items = {
{items = {'farming:trellis'}, rarity = 1},
}
},
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, attached_node = 1,
},
sounds = default.node_sound_leaves_defaults(),
on_place = function(itemstack, placer, pointed_thing)
if minetest.is_protected(pointed_thing.above, placer:get_player_name()) then return end
local nod = minetest.get_node_or_nil(pointed_thing.under)
if nod and minetest.get_item_group(nod.name, "soil") < 2 then
return
end
local top = {
x = pointed_thing.above.x,
y = pointed_thing.above.y + 1,
z = pointed_thing.above.z
}
nod = minetest.get_node_or_nil(top)
if nod and nod.name ~= "air" then return end
minetest.set_node(pointed_thing.above, {name = "farming:trellis"})
if not minetest.setting_getbool("creative_mode") then
itemstack:take_item()
end
return itemstack
end
})
minetest.register_craft({
output = "farming:trellis",
recipe = {
{'default:stick', 'default:stick', 'default:stick'},
{'default:stick', 'default:stick', 'default:stick'},
{'default:stick', 'default:stick', 'default:stick'},
}
})
minetest.register_craft({
type = "fuel",
recipe = "farming:trellis",
burntime = 15,
})
-- Define Grapes growth stages
minetest.register_node("farming:grapes_1", {
drawtype = "plantlike",
tiles = {"farming_grapes_1.png"},
visual_scale = 1.45,
paramtype = "light",
walkable = false,
buildable_to = true,
sunlight_propagates = true,
drop = {
items = {
{items = {'farming:trellis'}, rarity = 1},
}
},
selection_box = farming.select,
groups = {
snappy = 3, flammable = 3, not_in_creative_inventory = 1,
attached_node = 1, growing = 1
},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("farming:grapes_2", {
drawtype = "plantlike",
tiles = {"farming_grapes_2.png"},
visual_scale = 1.45,
paramtype = "light",
walkable = false,
buildable_to = true,
sunlight_propagates = true,
drop = {
items = {
{items = {'farming:trellis'}, rarity = 1},
}
},
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1, growing = 1
},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("farming:grapes_3", {
drawtype = "plantlike",
tiles = {"farming_grapes_3.png"},
visual_scale = 1.45,
paramtype = "light",
walkable = false,
buildable_to = true,
sunlight_propagates = true,
drop = {
items = {
{items = {'farming:trellis'}, rarity = 1},
}
},
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1, growing = 1
},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("farming:grapes_4", {
drawtype = "plantlike",
tiles = {"farming_grapes_4.png"},
visual_scale = 1.45,
paramtype = "light",
walkable = false,
buildable_to = true,
sunlight_propagates = true,
drop = {
items = {
{items = {'farming:trellis'}, rarity = 1},
}
},
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1, growing = 1
},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("farming:grapes_5", {
drawtype = "plantlike",
tiles = {"farming_grapes_5.png"},
visual_scale = 1.45,
paramtype = "light",
walkable = false,
buildable_to = true,
sunlight_propagates = true,
drop = {
items = {
{items = {'farming:trellis'}, rarity = 1},
}
},
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1, growing = 1
},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("farming:grapes_6", {
drawtype = "plantlike",
tiles = {"farming_grapes_6.png"},
visual_scale = 1.45,
paramtype = "light",
walkable = false,
buildable_to = true,
sunlight_propagates = true,
drop = {
items = {
{items = {'farming:trellis'}, rarity = 1},
}
},
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1, growing = 1
},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("farming:grapes_7", {
drawtype = "plantlike",
tiles = {"farming_grapes_7.png"},
visual_scale = 1.45,
paramtype = "light",
walkable = false,
buildable_to = true,
sunlight_propagates = true,
drop = {
items = {
{items = {'farming:trellis'}, rarity = 1},
}
},
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1, growing = 1
},
sounds = default.node_sound_leaves_defaults(),
})
-- Last stage of growth does not have growing group so abm never checks these
minetest.register_node("farming:grapes_8", {
drawtype = "plantlike",
tiles = {"farming_grapes_8.png"},
visual_scale = 1.45,
paramtype = "light",
walkable = false,
buildable_to = true,
sunlight_propagates = true,
drop = {
items = {
{items = {'farming:trellis'}, rarity = 1},
{items = {'farming:grapes 3'}, rarity = 1},
{items = {'farming:grapes 1'}, rarity = 2},
{items = {'farming:grapes 1'}, rarity = 3},
}
},
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1
},
sounds = default.node_sound_leaves_defaults(),
})
-- Wild Grape Vine (this is what you find on the map)
minetest.register_node("farming:grapebush", {
drawtype = "plantlike",
tiles = {"farming_grapebush.png"},
paramtype = "light",
waving = 1,
walkable = false,
buildable_to = true,
sunlight_propagates = true,
drop = {
items = {
{items = {'farming:grapes 1'}, rarity = 1},
{items = {'farming:grapes 1'}, rarity = 2},
{items = {'farming:grapes 1'}, rarity = 3},
}
},
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory=1
},
sounds = default.node_sound_leaves_defaults(),
})

View File

@ -1,9 +1,9 @@
-- Override default grass and have it drop Wheat Seeds
for i=1,5 do
for i = 1, 5 do
minetest.override_item("default:grass_"..i, {
minetest.override_item("default:grass_" .. i, {
drop = {
max_items = 1,
items = {

View File

@ -76,7 +76,7 @@ function farming.hoe_on_use(itemstack, user, pointed_thing, uses)
return
end
local p = {x=pt.under.x, y=pt.under.y+1, z=pt.under.z}
local p = {x = pt.under.x, y = pt.under.y + 1, z = pt.under.z}
local above = minetest.get_node(p)
-- return if any of the nodes is not registered

View File

@ -1,7 +1,8 @@
--[[
Minetest Farming Redo Mod 1.20 (5th July 2015)
Minetest Farming Redo Mod 1.22 (26th October 2015)
by TenPlus1
NEW growing routine by prestidigitator
auto-refill by crabman77
]]
farming = {}
@ -64,6 +65,7 @@ dofile(farming.path.."/raspberry.lua")
dofile(farming.path.."/blueberry.lua")
dofile(farming.path.."/rhubarb.lua")
dofile(farming.path.."/beanpole.lua")
dofile(farming.path.."/grapes.lua")
dofile(farming.path.."/donut.lua")
dofile(farming.path.."/mapgen.lua")
dofile(farming.path.."/compatibility.lua") -- Farming Plus compatibility
@ -390,7 +392,7 @@ if farming.DEBUG then
end
end
--MFF DEBUT1 crabman(26/08/2015) refill placed plant
-- refill placed plant by crabman (26/08/2015)
local can_refill_plant = {
["farming:blueberry_1"] = "farming:blueberries",
["farming:carrot_1"] = "farming:carrot",
@ -405,7 +407,7 @@ local can_refill_plant = {
["farming:rhubarb_1"] = "farming:rhubarb",
["farming:tomato_1"] = "farming:tomato",
["farming:wheat_1"] = "farming:seed_wheat"
}
}
function farming.refill_plant(player, plantname, index)
local inv = player:get_inventory()
@ -420,7 +422,7 @@ function farming.refill_plant(player, plantname, index)
return
end
end
end --MFF FIN1
end -- END refill
-- Place Seeds on Soil
@ -428,7 +430,7 @@ function farming.place_seed(itemstack, placer, pointed_thing, plantname)
local pt = pointed_thing
-- check if pointing at a node
if not pt and pt.type ~= "node" then
if not pt or pt.type ~= "node" then
return
end
@ -449,18 +451,26 @@ function farming.place_seed(itemstack, placer, pointed_thing, plantname)
-- can I replace above node, and am I pointing at soil
if not minetest.registered_nodes[above.name].buildable_to
or minetest.get_item_group(under.name, "soil") < 2
or minetest.get_item_group(above.name, "plant") ~= 0 then -- ADDED this line for multiple seed placement bug
-- avoid multiple seed placement bug
or minetest.get_item_group(above.name, "plant") ~= 0 then
return
end
-- add the node and remove 1 item from the itemstack
-- if not protected then add node and remove 1 item from the itemstack
if not minetest.is_protected(pt.above, placer:get_player_name()) then
minetest.add_node(pt.above, {name=plantname})
minetest.set_node(pt.above, {name = plantname, param2 = 1})
if not minetest.setting_getbool("creative_mode") then
itemstack:take_item()
if itemstack:get_count() == 0 and can_refill_plant[plantname] then--MFF DEBUT2 crabman(26/08/2015) refill placed plant
minetest.after(0.10, farming.refill_plant, placer, can_refill_plant[plantname], placer:get_wield_index())
end --MFF FIN2
-- check for refill
if itemstack:get_count() == 0
and can_refill_plant[plantname] then
minetest.after(0.10,
farming.refill_plant,
placer,
can_refill_plant[plantname],
placer:get_wield_index()
)
end -- END refill
end
return itemstack
end
@ -508,7 +518,7 @@ farming.register_plant = function(name, def)
})
-- Register growing steps
for i=1,def.steps do
for i = 1, def.steps do
local drop = {
items = {
{items = {mname .. ":" .. pname}, rarity = 9 - i},
@ -532,7 +542,6 @@ farming.register_plant = function(name, def)
paramtype = "light",
walkable = false,
buildable_to = true,
is_ground_content = true,
drop = drop,
selection_box = farming.select,
groups = g,

View File

@ -34,6 +34,7 @@ function farming.register_mgv6_decorations()
register_plant("rhubarb_3", 3, 15, "group:tree", 1)
register_plant("blueberry_4", 3, 10, "", -1)
register_plant("beanbush", 18, 35, "", -1)
register_plant("grapebush", 25, 45, "", -1)
end
-- v7 maps have a beach so plants growing near water is limited to 6- high
@ -51,6 +52,7 @@ function farming.register_mgv7_decorations()
register_plant("rhubarb_3", 3, 15, "group:tree", 1)
register_plant("blueberry_4", 3, 10, "", -1)
register_plant("beanbush", 18, 35, "", -1)
register_plant("grapebush", 25, 45, "", -1)
end
-- detect mapgen

View File

@ -1,23 +1,23 @@
-- normal soil
minetest.register_node("farming:soil", {
description = "Soil",
tiles = {"farming_soil.png", "default_dirt.png"},
tiles = {"default_dirt.png^farming_soil.png", "default_dirt.png"},
drop = "default:dirt",
groups = {crumbly = 3, not_in_creative_inventory = 1, soil = 2},
sounds = default.node_sound_dirt_defaults(),
})
-- sand is not soil, change existing sand-soil to use normal soil
minetest.register_alias("farming:desert_sand_soil", "farming:soil")
-- wet soil
minetest.register_node("farming:soil_wet", {
description = "Wet Soil",
tiles = {"farming_soil_wet.png", "farming_soil_wet_side.png"},
tiles = {"default_dirt.png^farming_soil_wet.png", "default_dirt.png^farming_soil_wet_side.png"},
drop = "default:dirt",
groups = {crumbly = 3, not_in_creative_inventory = 1, soil = 3},
sounds = default.node_sound_dirt_defaults(),
})
-- sand is not soil, change existing sand-soil to use normal soil
minetest.register_alias("farming:desert_sand_soil", "farming:soil")
minetest.register_alias("farming:desert_sand_soil_wet", "farming:soil_wet")
-- if water near soil then change to wet soil

Binary file not shown.

Before

Width:  |  Height:  |  Size: 116 B

After

Width:  |  Height:  |  Size: 110 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 141 B

After

Width:  |  Height:  |  Size: 120 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 162 B

After

Width:  |  Height:  |  Size: 144 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 198 B

After

Width:  |  Height:  |  Size: 150 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 226 B

After

Width:  |  Height:  |  Size: 159 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 290 B

After

Width:  |  Height:  |  Size: 164 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 319 B

After

Width:  |  Height:  |  Size: 170 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 289 B

After

Width:  |  Height:  |  Size: 196 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 271 B

After

Width:  |  Height:  |  Size: 150 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 204 B

After

Width:  |  Height:  |  Size: 159 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 144 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 175 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 255 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 290 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 307 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 330 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 338 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 347 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 358 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 350 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 713 B

After

Width:  |  Height:  |  Size: 706 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 659 B

After

Width:  |  Height:  |  Size: 677 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 721 B

After

Width:  |  Height:  |  Size: 96 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 799 B

After

Width:  |  Height:  |  Size: 892 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 227 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 563 B

After

Width:  |  Height:  |  Size: 241 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 127 B

After

Width:  |  Height:  |  Size: 120 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 164 B

After

Width:  |  Height:  |  Size: 142 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 203 B

After

Width:  |  Height:  |  Size: 172 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 230 B

After

Width:  |  Height:  |  Size: 191 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 298 B

After

Width:  |  Height:  |  Size: 218 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 396 B

After

Width:  |  Height:  |  Size: 234 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 479 B

After

Width:  |  Height:  |  Size: 253 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 582 B

After

Width:  |  Height:  |  Size: 310 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 338 B

After

Width:  |  Height:  |  Size: 141 B

View File

@ -79,7 +79,7 @@ minetest.register_craft({
minetest.register_craftitem("farming:bread", {
description = "Bread",
inventory_image = "farming_bread.png",
on_use = minetest.item_eat(4),
on_use = minetest.item_eat(4), --MFF 4
})
minetest.register_craft({

View File

@ -2,20 +2,10 @@
--plants to place in openfarming
local plants = { ["farming:blueberries"]=1, ["farming:carrot"]=1, ["farming:coffee_beans"]=1, ["farming:corn"]=1, ["farming:cucumber"]=1,
["farming:melon_slice"]=1, ["farming:potato"]=1, ["farming:pumpkin_slice"]=1, ["farming:raspberries"]=1, ["farming:rhubarb"]=1,
["farming:tomato"]=1, ["farming:seed_cotton"]=1, ["farming:seed_wheat"]=1,["default:papyrus"]=1
["farming:tomato"]=1, ["farming:seed_cotton"]=1, ["farming:seed_wheat"]=1,["default:papyrus"]=1, ["farming:trellis"]=1,
["farming:grapes"]=1, ["farming:beanpole"]=1, ["farming:beans"]=1,
}
--tools to dig in openfarming
local in_hand = { ["hand"]=1, ["mobs:shears"]=1,
["default:sword_bronze"]=1, ["default:sword_diamond"]=1, ["default:sword_gold"]=1, ["default:sword_mese"]=1, ["default:sword_nyan"]=1,
["default:sword_steel"]=1, ["default:sword_stone"]=1, ["default:sword_wood"]=1, ["moreores:sword_mithril"]=1, ["moreores:sword_silver"]=1,
["nether:sword_netherrack"]=1, ["nether:sword_netherrack_blue"]=1, ["nether:sword_white"]=1,
["default:axe_bronze"]=1, ["default:axe_diamond"]=1, ["default:axe_gold"]=1, ["default:axe_mese"]=1, ["default:axe_nyan"]=1,
["default:axe_steel"]=1, ["default:axe_stone"]=1, ["default:axe_wood"]=1, ["moreores:axe_mithril"]=1, ["moreores:axe_silver"]=1,
["nether:axe_netherrack"]=1, ["nether:axe_netherrack_blue"]=1, ["nether:axe_white"]=1
}
-- Returns a list of areas that include the provided position
function areas:getAreasAtPos(pos)
local a = {}
@ -50,13 +40,13 @@ function areas:canInteract(pos, name)
local wstack = player:get_wielded_item():get_name()
if wstack == "" then wstack = "hand" end
--on_place
if node == "air" and plants[wstack] ~= nil then
--on_dig
if minetest.get_item_group(node, "plant") == 1 and (wstack == "hand" or minetest.registered_tools[wstack]) then
return true
end
--on_dig
if minetest.get_item_group(node, "plant") == 1 and in_hand[wstack] ~= nil then
--on_place
if node == "air" and plants[wstack] ~= nil then
return true
end
@ -119,3 +109,33 @@ function areas:canInteractInArea(pos1, pos2, name, allow_open)
return true
end
--MFF DEBUT crabman(17/09/2015 ) respawn player in special area(event) if a spawn is set.
local dead_players = {}
minetest.register_on_dieplayer(function(player)
local player_name = player:get_player_name()
if not player_name then return end
local pos = player:getpos()
if pos then
dead_players[player_name] = pos
end
end)
minetest.register_on_respawnplayer(function(player)
local player_name = player:get_player_name()
if not player_name or not dead_players[player_name] then return false end
local pos = dead_players[player_name]
dead_players[player_name] = nil
if pos then
for _, area in pairs(areas:getAreasAtPos(pos)) do
if area.spawn then
player:setpos(area.spawn)
return true
end
end
end
return false
end)
--FIN

View File

@ -424,3 +424,63 @@ minetest.register_chatcommand("area_info", {
end,
})
--MFF DEBUT crabman(17/09/2015 ) respawn player at in special area(event) if a spawn is set.
minetest.register_chatcommand("area_addspawn", {
params = "<ID>",
privs = areas.adminPrivs,
description = "Define special spawn for area",
func = function(name, param)
local id = param:match("^(%d+)")
if not id then
return false, "Invalid usage, see /help area_addspawn."
end
id = tonumber(id)
if not id then
return false, "Error, Param id must be int."
end
local player = minetest.get_player_by_name(name)
if not player then
return false, "Error, there is not player"
end
local pos = player:getpos()
if not pos then
return false, "Error, there is not pos."
end
if not areas.areas[id] then
return false, "Area ".. id .." does not exist."
end
areas.areas[id].spawn = pos
areas:save()
return true, "spawn of area ".. id .." defined."
end
})
minetest.register_chatcommand("area_delspawn", {
params = "<ID>",
privs = areas.adminPrivs,
description = "Delete special spawn of area",
func = function(name, param)
local id = param:match("^(%d+)")
if not id then
return false, "Invalid usage, see /help area_delspawn."
end
id = tonumber(id)
if not id then
return false, "Error, Param id must be int."
end
if not areas.areas[id] then
return false, "Area ".. id .." does not exist."
end
areas.areas[id].spawn = nil
areas:save()
return true, "spawn of area ".. id .." deleted."
end
})
-- FIN