Fix some bugs with achievements thanks to @asl97; fixes #35
This commit is contained in:
parent
eb7171bd0c
commit
40f5bee790
@ -79,6 +79,20 @@ function achievements.trigger_achievement(player, aname, times)
|
|||||||
save_achievements()
|
save_achievements()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Load achievements table
|
||||||
|
|
||||||
|
local function on_load()
|
||||||
|
load_achievements()
|
||||||
|
end
|
||||||
|
|
||||||
|
-- New player
|
||||||
|
|
||||||
|
local function on_newplayer(player)
|
||||||
|
achievements.achievements[player:get_player_name()] = {}
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Interaction callbacks
|
||||||
|
|
||||||
local function on_craft(itemstack, player, craftgrid, craftinv)
|
local function on_craft(itemstack, player, craftgrid, craftinv)
|
||||||
for aname, def in pairs(achievements.registered_achievements) do
|
for aname, def in pairs(achievements.registered_achievements) do
|
||||||
if def.craftitem ~= nil then
|
if def.craftitem ~= nil then
|
||||||
@ -128,10 +142,18 @@ local function on_place(pos, newnode, player, oldnode, itemstack, pointed_thing)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Add callback functions
|
||||||
|
|
||||||
|
minetest.after(0, on_load)
|
||||||
|
|
||||||
|
minetest.register_on_newplayer(on_newplayer)
|
||||||
|
|
||||||
minetest.register_on_craft(on_craft)
|
minetest.register_on_craft(on_craft)
|
||||||
minetest.register_on_dignode(on_dig)
|
minetest.register_on_dignode(on_dig)
|
||||||
minetest.register_on_placenode(on_place)
|
minetest.register_on_placenode(on_place)
|
||||||
|
|
||||||
|
-- Formspecs
|
||||||
|
|
||||||
local form = default.ui.get_page("core")
|
local form = default.ui.get_page("core")
|
||||||
form = form .. "tableoptions[background=#DDDDDD30]"
|
form = form .. "tableoptions[background=#DDDDDD30]"
|
||||||
form = form .. "tablecolumns[text,align=left,width=11;text,align=left,width=28;text,align=left,width=5]"
|
form = form .. "tablecolumns[text,align=left,width=11;text,align=left,width=28;text,align=left,width=5]"
|
||||||
@ -220,7 +242,6 @@ end
|
|||||||
|
|
||||||
minetest.register_on_player_receive_fields(receive_fields)
|
minetest.register_on_player_receive_fields(receive_fields)
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Below is the default achievements
|
-- Below is the default achievements
|
||||||
--
|
--
|
||||||
|
Loading…
Reference in New Issue
Block a user