1
0
mirror of https://github.com/MinetestForFun/quests.git synced 2025-07-06 18:30:22 +02:00

A bit of clean up. Moved mod integration lua files to their own folder with a single file designed to check if supported mods are present and load the appropriate local file to setup for it.

This commit is contained in:
DomtronVox
2020-05-03 19:15:16 -04:00
parent 765e34bfe5
commit 4b9565e8b6
6 changed files with 27 additions and 19 deletions

View File

@ -0,0 +1,9 @@
function quests.show_message(t, playername, text)
if (quests.hud[playername].central_message_enabled) then
local player = minetest.get_player_by_name(playername)
cmsg.push_message_player(player, text, quests.colors[t])
minetest.sound_play("quests_" .. t, {to_player = playername})
end
end

View File

@ -0,0 +1,9 @@
minetest.register_on_joinplayer(function(player)
inventory_plus.register_button(player, "quests")
end)
minetest.register_on_player_receive_fields(function(player, formname, fields)
if (fields.quests) then
quests.show_formspec(player:get_player_name())
end
end)

View File

@ -0,0 +1,17 @@
-- support for several inventory mods
if minetest.get_modpath("unified_inventory") then
dofile(minetest.get_modpath("quests") .. "/mod_integrations/unified_inventory.lua")
end
if minetest.get_modpath("inventory_plus") then
dofile(minetest.get_modpath("quests") .. "/mod_integrations/inventory_plus.lua")
end
--mod that displays notifications in the screen's center
if minetest.get_modpath("central_message") then
dofile(minetest.get_modpath("quests") .. "/mod_integrations/central_message.lua")
else -- define blank function so we can still use this in the code later
function quests.show_message(...) end
end

View File

@ -0,0 +1,48 @@
unified_inventory.register_button("quests", {
type = "image",
image = "inventory_plus_quests.png",
tooltip = "Show the questlog",
-- action = function(player)
-- quests.show_formspec(player:get_player_name())
-- end
})
unified_inventory.register_page("quests", {
get_formspec = function(player)
local playername = player:get_player_name()
local formspec = quests.create_formspec(playername, "1", true)
return {formspec = formspec, draw_inventory=false}
end
})
unified_inventory.register_page("quests_successfull", {
get_formspec = function(player)
local playername = player:get_player_name()
local formspec = quests.create_formspec(playername, "2", true)
return {formspec = formspec, draw_inventory=false}
end
})
unified_inventory.register_page("quests_failed", {
get_formspec = function(player)
local playername = player:get_player_name()
local formspec = quests.create_formspec(playername, "3", true)
return {formspec = formspec, draw_inventory=false}
end
})
unified_inventory.register_page("quests_config", {
get_formspec = function(player)
local playername = player:get_player_name()
local formspec = quests.create_config(playername, true)
return {formspec = formspec, draw_inventory = false }
end
})
unified_inventory.register_page("quests_info", {
get_formspec = function(player)
local playername = player:get_player_name()
local formspec = quests.create_info(playername, quests.formspec_lists[playername].list[quests.formspec_lists[playername].id],
quests.formspec_lists[playername].taskid, true)
return {formspec = formspec, draw_inventory = false }
end
})