rework miner experience in rudimentary direction (#58)

* rework miner experience in rudimentary direction

* remove useless print
This commit is contained in:
pandaro 2017-04-22 19:24:29 +02:00 committed by cd2
parent aa2455c400
commit e1b068bafe
3 changed files with 65 additions and 30 deletions

View File

@ -154,6 +154,7 @@ minetest.register_node("default:stones_on_floor", {
},
drop = "default:stone_item 2",
})
minetest.register_node("default:rope", {
@ -541,6 +542,7 @@ default.register_wool("black")
minetest.register_node("default:stone", {
description = "Stone",
tiles = {"default_stone.png"},
groups = {cracky = 3, stone= 1},
drop = {
@ -551,6 +553,7 @@ minetest.register_node("default:stone", {
}
},
sounds = default.sounds.stone(),
miner_xp ={xp = 10,rnd = 20},
})
minetest.register_node("default:desert_stone", {
@ -662,6 +665,7 @@ minetest.register_node("default:stone_with_coal", {
groups = {cracky = 2},
drop = "default:coal_lump",
sounds = default.sounds.stone(),
miner_xp ={xp = -1, rm = true}
})
minetest.register_node("default:stone_with_iron", {
@ -669,6 +673,7 @@ minetest.register_node("default:stone_with_iron", {
tiles = {"default_stone_with_iron.png"},
groups = {cracky = 2},
sounds = default.sounds.stone(),
miner_xp = {xp = 50},
})
minetest.register_node("default:stone_with_copper", {
@ -705,6 +710,7 @@ minetest.register_node("default:stone_with_diamond", {
groups = {hard = 2},
drop = "default:diamond",
sounds = default.sounds.stone(),
miner_xp = {xp = 14, lvls = 5}
})
minetest.register_node("default:stone_with_ruby", {

View File

@ -405,36 +405,38 @@ skills.register_tool("bow", 1, 30, {
})
minetest.override_item("default:stone_with_coal", {
on_dig = function(pos, node, player)
if skills.lvls[player:get_player_name()] then
xp.add_xp(player, (skills.lvls[player:get_player_name()]["miner"]-1))
end
minetest.node_dig(pos, node, player)
end,
})
minetest.override_item("default:stone_with_diamond", {
on_dig = function(pos, node, player)
if skills.lvls[player:get_player_name()] and skills.lvls[player:get_player_name()]["miner"] > 5 then
xp.add_xp(player,xp.get_xp(xp.player_levels[player:get_player_name()], 14))
end
minetest.node_dig(pos, node, player)
end,
})
minetest.override_item("default:stone", {
on_dig = function(pos, node, player)
if skills.lvls[player:get_player_name()] and skills.lvls[player:get_player_name()]["miner"] then
if skills.lvls[player:get_player_name()]["miner"] > 1 then
if math.random(0, 20) == 1 then
xp.add_xp(player,10)
end
end
end
minetest.node_dig(pos, node, player)
end,
})
-- minetest.override_item("default:stone_with_coal", {
-- on_dig = function(pos, node, player)
-- if skills.lvls[player:get_player_name()] then
-- xp.add_xp(player, (skills.lvls[player:get_player_name()]["miner"]-1))
-- end
-- minetest.node_dig(pos, node, player)
-- end,
-- })
--
-- minetest.override_item("default:stone_with_diamond", {
-- on_dig = function(pos, node, player)
-- if skills.lvls[player:get_player_name()] and skills.lvls[player:get_player_name()]["miner"] > 5 then
-- xp.add_xp(player,xp.get_xp(xp.player_levels[player:get_player_name()], 14))
-- end
-- minetest.node_dig(pos, node, player)
-- end,
-- })
--
-- minetest.override_item("default:stone", {
-- on_dig = function(pos, node, player)
-- if skills.lvls[player:get_player_name()] and skills.lvls[player:get_player_name()]["miner"] then
-- if skills.lvls[player:get_player_name()]["miner"] > 1 then
-- if math.random(0, 20) == 1 then
-- xp.add_xp(player,10)
-- end
-- end
-- end
-- minetest.node_dig(pos, node, player)
-- end,
--
--
-- })
local modpath = minetest.get_modpath("skills")

View File

@ -182,7 +182,34 @@ function xp.crafter_xp()
end)
end
function xp.miner_xp()
minetest.register_on_dignode(function(pos, oldnode, digger)
local miner_xp = minetest.registered_nodes[oldnode.name].miner_xp
local player = digger:get_player_name()
local player_lvls = skills.lvls[player]
if not miner_xp then
elseif miner_xp.rm then
if player_lvls then
xp.add_xp(digger, (player_lvls["miner"]-1))
end
elseif miner_xp.lvls then
if player_lvls and player_lvls["miner"] > 5 then
xp.add_xp(digger,xp.get_xp(xp.player_levels[player], 14))
end
elseif miner_xp.rnd then
if math.random(miner_xp.rnd) == miner_xp.rnd then
xp.add_xp(digger, miner_xp.xp)
end
elseif miner_xp.xp then
xp.add_xp(digger, miner_xp.xp)
end
end)
end
xp.miner_xp()
xp.crafter_xp()
xp.explorer_xp()
xp.load_xp()
xp.load_levels()