mirror of
https://github.com/TeTpaAka/quests.git
synced 2024-12-22 16:50:39 +01:00
Added rounded value
This commit is contained in:
parent
807309022e
commit
9a56707c40
9
init.lua
9
init.lua
@ -47,6 +47,11 @@ function quests.hide_hud(playername)
|
|||||||
quests.hud[playername] = nil
|
quests.hud[playername] = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function round(num, n)
|
||||||
|
local mult = 10^(n or 0)
|
||||||
|
return math.floor(num * mult + .5) / mult
|
||||||
|
end
|
||||||
|
|
||||||
-- only for internal use
|
-- only for internal use
|
||||||
-- updates the hud
|
-- updates the hud
|
||||||
function quests.update_hud(playername)
|
function quests.update_hud(playername)
|
||||||
@ -61,7 +66,7 @@ function quests.update_hud(playername)
|
|||||||
local text = "Open Quests:\n\n"
|
local text = "Open Quests:\n\n"
|
||||||
if (quests.registered_quests[playername] ~= nil) then
|
if (quests.registered_quests[playername] ~= nil) then
|
||||||
for questname,questspecs in pairs(quests.registered_quests[playername]) do
|
for questname,questspecs in pairs(quests.registered_quests[playername]) do
|
||||||
text = text .. questspecs["description"].."\n (" .. questspecs["value"] .. "/" .. questspecs["max"] .. ")\n"
|
text = text .. questspecs["description"].."\n (" .. round(questspecs["value"], 2) .. "/" .. questspecs["max"] .. ")\n"
|
||||||
counter = counter + 1
|
counter = counter + 1
|
||||||
if (counter >= show_max) then
|
if (counter >= show_max) then
|
||||||
break
|
break
|
||||||
@ -180,7 +185,7 @@ function quests.create_formspec(playername)
|
|||||||
quests.formspec_lists[playername].id = 1
|
quests.formspec_lists[playername].id = 1
|
||||||
quests.formspec_lists[playername].list = {}
|
quests.formspec_lists[playername].list = {}
|
||||||
for questname,questspecs in pairs(quests.registered_quests[playername]) do
|
for questname,questspecs in pairs(quests.registered_quests[playername]) do
|
||||||
table.insert(questlist, questspecs["description"] .. " - (" .. questspecs["value"] .. "/" .. questspecs["max"] .. ")")
|
table.insert(questlist, questspecs["description"] .. " - (" .. round(questspecs["value"], 2) .. "/" .. questspecs["max"] .. ")")
|
||||||
table.insert(quests.formspec_lists[playername].list, questname)
|
table.insert(quests.formspec_lists[playername].list, questname)
|
||||||
end
|
end
|
||||||
local formspec = "size[7,9]"..
|
local formspec = "size[7,9]"..
|
||||||
|
Loading…
Reference in New Issue
Block a user