Added builder skills and future proofed XP events
This commit is contained in:
parent
a62323b2ba
commit
21bfb31a99
60
init.lua
60
init.lua
@ -143,49 +143,73 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|||||||
show_formspec(name, "miner")
|
show_formspec(name, "miner")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if fields.healpick then healTool(player, "pick", "miner", 100) end
|
if fields.healpick then healTool(player, "pick", "miner", 100) return end
|
||||||
if fields.upgradepick then upgradeTool(player, "pick", "miner", 200) end
|
if fields.upgradepick then upgradeTool(player, "pick", "miner", 200) return end
|
||||||
if fields.superheatpick then addSpecial2Tool(player, "superheat", "pick", "miner", 500) end
|
if fields.superheatpick then addSpecial2Tool(player, "superheat", "pick", "miner", 500) return end
|
||||||
|
|
||||||
--LUMBERJACK
|
--LUMBERJACK
|
||||||
if fields.lumberjack then
|
if fields.lumberjack then
|
||||||
show_formspec(name, "lumberjack")
|
show_formspec(name, "lumberjack")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if fields.healaxe then healTool(player, "axe", "lumberjack", 100) end
|
if fields.healaxe then healTool(player, "axe", "lumberjack", 100) return end
|
||||||
if fields.upgradeaxe then upgradeTool(player, "axe", "lumberjack", 200) end
|
if fields.upgradeaxe then upgradeTool(player, "axe", "lumberjack", 200) return end
|
||||||
if fields.superheataxe then addSpecial2Tool(player, "superheat", "axe", "lumberjack", 500) end
|
if fields.superheataxe then addSpecial2Tool(player, "superheat", "axe", "lumberjack", 500) return end
|
||||||
if fields.felleraxe then addSpecial2Tool(player, "feller", "axe", "lumberjack", 750) end
|
if fields.felleraxe then addSpecial2Tool(player, "feller", "axe", "lumberjack", 750) return end
|
||||||
|
|
||||||
--DIGGER
|
--DIGGER
|
||||||
if fields.digger then
|
if fields.digger then
|
||||||
show_formspec(name, "digger")
|
show_formspec(name, "digger")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if fields.healshovel then healTool(player, "shovel", "digger", 100) end
|
if fields.healshovel then healTool(player, "shovel", "digger", 100) return end
|
||||||
if fields.upgradeshovel then upgradeTool(player, "shovel", "digger", 200) end
|
if fields.upgradeshovel then upgradeTool(player, "shovel", "digger", 200) return end
|
||||||
if fields.superheatshovel then addSpecial2Tool(player, "superheat", "shovel", "digger", 500) end
|
if fields.superheatshovel then addSpecial2Tool(player, "superheat", "shovel", "digger", 500) return end
|
||||||
|
|
||||||
--FARMER
|
--FARMER
|
||||||
if fields.farmer then
|
if fields.farmer then
|
||||||
show_formspec(name, "farmer")
|
show_formspec(name, "farmer")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if fields.healhoe then healTool(player, "hoe", "farmer", 100) end
|
if fields.healhoe then healTool(player, "hoe", "farmer", 100) return end
|
||||||
if fields.upgradehoe then upgradeTool(player, "hoe", "farmer", 200) end
|
if fields.upgradehoe then upgradeTool(player, "hoe", "farmer", 200) return end
|
||||||
if fields.greenthumb then addSpecial2Tool(player, "greenthumb", "hoe", "farmer", 500) end
|
if fields.greenthumb then addSpecial2Tool(player, "greenthumb", "hoe", "farmer", 500) return end
|
||||||
|
|
||||||
--BUILDER
|
--BUILDER
|
||||||
if fields.builder then
|
if fields.builder then
|
||||||
show_formspec(name, "builder")
|
show_formspec(name, "builder")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
if fields.grantfast then
|
||||||
|
if specialties.changeXP(name, "builder", -600) then
|
||||||
|
local privs = minetest.get_player_privs(name)
|
||||||
|
if privs.fast == false or privs.fast == nil then
|
||||||
|
privs.fast = true
|
||||||
|
end
|
||||||
|
minetest.set_player_privs(name, privs)
|
||||||
|
show_formspec(name, "builder")
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if fields.grantfly then
|
||||||
|
if specialties.changeXP(name, "builder", -800) then
|
||||||
|
local privs = minetest.get_player_privs(name)
|
||||||
|
if privs.fly == false or privs.fly == nil then
|
||||||
|
privs.fly = true
|
||||||
|
end
|
||||||
|
minetest.set_player_privs(name, privs)
|
||||||
|
show_formspec(name, "builder")
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--XP Events
|
--XP Events
|
||||||
minetest.register_on_dignode(function(pos, oldnode, digger)
|
local node_dig = minetest.node_dig
|
||||||
|
function minetest.node_dig(pos, oldnode, digger)
|
||||||
|
node_dig(pos, oldnode, digger)
|
||||||
if digger == nil then
|
if digger == nil then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -216,10 +240,12 @@ minetest.register_on_dignode(function(pos, oldnode, digger)
|
|||||||
if oldnode.name:find("farming") ~= nil then
|
if oldnode.name:find("farming") ~= nil then
|
||||||
specialties.changeXP(name, "farmer", 5)
|
specialties.changeXP(name, "farmer", 5)
|
||||||
end
|
end
|
||||||
end)
|
end
|
||||||
minetest.register_on_placenode(function(pos, newnode, placer, oldnode)
|
local place_node = minetest.item_place_node
|
||||||
|
function minetest.item_place_node(itemstack, placer, pointed_thing)
|
||||||
|
place_node(itemstack, placer, pointed_thing)
|
||||||
specialties.changeXP(placer:get_player_name(), "builder", 1)
|
specialties.changeXP(placer:get_player_name(), "builder", 1)
|
||||||
end)
|
end
|
||||||
minetest.register_globalstep(function(dtime)
|
minetest.register_globalstep(function(dtime)
|
||||||
if time+dtime < 10 then
|
if time+dtime < 10 then
|
||||||
time = time+dtime
|
time = time+dtime
|
||||||
|
Loading…
Reference in New Issue
Block a user