Skip to content
Snippets Groups Projects
Commit 4ee415b4 authored by DarkGod's avatar DarkGod
Browse files

Sher'tul Fortress Control Orb now displays the current energy count

parent 466659bc
No related branches found
No related tags found
No related merge requests found
......@@ -293,6 +293,45 @@ function _M:listAddons(mod, ignore_compat)
return adds
end
function _M:addonMD5(add, base)
local t = core.game.getTime()
if not base then
if add.teaa then base = fs.getRealPath(add.teaa)
else base = fs.getRealPath(add.dir) end
end
local md5 = require "md5"
local md5s = {}
local function fp(dir)
for i, file in ipairs(fs.list(dir)) do
local f = dir.."/"..file
if fs.isdir(f) then
fp(f)
elseif f:find("%.lua$") then
local fff = fs.open(f, "r")
if fff then
local data = fff:read(10485760)
if data and data ~= "" then
md5s[#md5s+1] = f..":"..md5.sumhexa(data)
end
fff:close()
end
end
end
end
print("[MODULE LOADER] computing addon md5 from", base)
fs.mount(base, "/loaded-addons/"..add.short_name, true)
fp("/loaded-addons/"..add.short_name)
fs.umount(base)
table.sort(md5s)
table.print(md5s)
local fmd5 = md5.sumhexa(table.concat(md5s))
print("[MODULE LOADER] addon ", add.short_name, " MD5", fmd5, "computed in ", core.game.getTime() - t, vbase)
return fmd5
end
function _M:loadAddons(mod, saveuse)
local adds = self:listAddons(mod, true)
......@@ -390,38 +429,11 @@ function _M:loadAddons(mod, saveuse)
end
-- Compute addon md5
local md5 = require "md5"
local md5s = {}
local function fp(dir)
for i, file in ipairs(fs.list(dir)) do
local f = dir.."/"..file
if fs.isdir(f) then
fp(f)
elseif f:find("%.lua$") then
local fff = fs.open(f, "r")
if fff then
local data = fff:read(10485760)
if data and data ~= "" then
md5s[#md5s+1] = f..":"..md5.sumhexa(data)
end
fff:close()
end
end
end
end
local hash_valid, hash_err
local t = core.game.getTime()
if config.settings.cheat then
hash_valid, hash_err = false, "cheat mode skipping addon validation"
else
print("[MODULE LOADER] computing addon md5 from", base)
fs.mount(base, "/loaded-addons/"..add.short_name, true)
fp("/loaded-addons/"..add.short_name)
fs.umount(base)
table.sort(md5s)
table.print(md5s)
local fmd5 = md5.sumhexa(table.concat(md5s))
print("[MODULE LOADER] addon ", add.short_name, " MD5", fmd5, "computed in ", core.game.getTime() - t, vbase)
local fmd5 = self:addonMD5(add)
hash_valid, hash_err = profile:checkAddonHash(mod.short_name, add.version_name, fmd5)
end
......
......@@ -848,6 +848,12 @@ function _M:entityVaultInfos(module, kind)
print("[ONLINE PROFILE] list entity vault", module, kind)
end
function _M:addonEnableUpload()
if not self.auth then return end
core.profile.pushOrder(table.serialize{o="AddonEnableUpload"})
print("[ONLINE PROFILE] enabling addon upload grants")
end
function _M:funFactsGrab(module)
core.profile.pushOrder(table.serialize{o="FunFactsGrab", module=module})
print("[ONLINE PROFILE] fun facts", module)
......
......@@ -20,6 +20,48 @@
load("/data/general/grids/basic.lua")
load("/data/general/grids/fortress.lua")
local energycount = function(self)
if not self._mo then return end
local tex, nblines, wline = nil
local lastenergy = nil
local shader = require("engine.Shader").default.textoutline and require("engine.Shader").default.textoutline.shad
local font = core.display.newFont("/data/font/DroidSansMono.ttf", 16)
local UIBase = require "engine.ui.Base"
local MyUI = require("engine.class").inherit(UIBase){}
MyUI.ui = "metal"
local frame = MyUI:makeFrame("ui/tooltip/", 50, 50)
self._mo:displayCallback(function(x, y, w, h)
local q = game.player:hasQuest("shertul-fortress")
if not q then return end
if not q:isCompleted("chat-energy") and q.shertul_energy <= 0 then return end
if not tex or lastenergy ~= q.shertul_energy then
lastenergy = q.shertul_energy
local text = ("%0.2f Energy Stored"):format(q.shertul_energy)
tex, nblines, wline = font:draw(text, text:toTString():maxWidth(font), 0, 255, 128)
end
y = y - tex[1].h * nblines
x = x - (wline - w) / 2
frame.w = wline + 16 frame.h = tex[1].h * nblines + 16
MyUI:drawFrame(frame, x - 4, y - 4, 0, 0, 0, 0.3)
MyUI:drawFrame(frame, x - 8, y - 8, 1, 1, 1, 0.6)
for i = 1, #tex do
local item = tex[i]
if shader then
shader:use(true)
shader:uniOutlineSize(2, 2)
shader:uniTextSize(item._tex_w, item._tex_h)
else
item._tex:toScreenFull(x+2, y+2, item.w, item.h, item._tex_w, item._tex_h, 0, 0, 0, 0.7)
end
item._tex:toScreenFull(x, y, item.w, item.h, item._tex_w, item._tex_h)
if shader then shader:use(false) end
y = y + item.h
end
return true
end)
end
newEntity{ base = "UP",
define_as = "LAKE_NUR",
name = "stair back to the lake of Nur",
......@@ -37,7 +79,11 @@ newEntity{
newEntity{
define_as = "COMMAND_ORB",
name = "Sher'Tul Control Orb", image = "terrain/solidwall/solid_floor1.png", add_displays = {class.new{image="terrain/shertul_control_orb_blue.png"}},
name = "Sher'Tul Control Orb", image = "terrain/solidwall/solid_floor1.png",
add_displays = {class.new{image="terrain/shertul_control_orb_blue.png",
defineDisplayCallback = energycount,
z = 17,
}},
display = '*', color=colors.PURPLE,
notice = true,
always_remember = true,
......
......@@ -584,6 +584,10 @@ function _M:orderFunFactsGrab(o)
end
end
function _M:orderAddonEnableUpload(o)
self:command("ADDN MODULEMAKER ON")
self:read("200")
end
--------------------------------------------------------------------
-- Pushes comming from the push socket
--------------------------------------------------------------------
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment