summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPiotr Dobrowolski <admin@tastycode.pl>2017-01-24 18:58:00 +0100
committerPiotr Dobrowolski <admin@tastycode.pl>2017-01-24 18:58:00 +0100
commit862d977fce801f191350bd2f57b54877cea1f69a (patch)
treeebfe7ac57a7aad19fcdaaac5229dee97cbb08236
parent615c9e5dee7edc3329d4fd6043fbacb429c26d04 (diff)
downloadlove2d-signage-862d977fce801f191350bd2f57b54877cea1f69a.tar.gz
love2d-signage-862d977fce801f191350bd2f57b54877cea1f69a.tar.bz2
love2d-signage-862d977fce801f191350bd2f57b54877cea1f69a.tar.xz
love2d-signage-862d977fce801f191350bd2f57b54877cea1f69a.zip
Use string.format in newdash, fix slideshow when no files provided
-rw-r--r--nodes/newdash.lua16
-rw-r--r--nodes/slideshow.lua14
2 files changed, 13 insertions, 17 deletions
diff --git a/nodes/newdash.lua b/nodes/newdash.lua
index 37c7a1e..e231342 100644
--- a/nodes/newdash.lua
+++ b/nodes/newdash.lua
@@ -13,7 +13,6 @@ local headerFont = love.graphics.newFont('fonts/Lato-Regular.ttf', 40)
local valueFont = love.graphics.newFont('fonts/Lato-Light.ttf', 45)
local atFont = love.graphics.newFont('fonts/Lato-Light.ttf', 35)
-
local weatherGlyphs = {
snow = "",
mist = "",
@@ -39,7 +38,7 @@ function node:render()
end
love.graphics.setFont(tempFont)
- love.graphics.printf(tostring(self.state.temperature) .. "°", 350, 390, 270, 'center')
+ love.graphics.printf(string.format("%d°", self.state.temperature), 350, 390, 270, 'center')
love.graphics.setFont(headerFont)
love.graphics.printf("Ambient:", 720, 380, 160, 'right')
@@ -48,30 +47,25 @@ function node:render()
love.graphics.setFont(valueFont)
if self.state.insideTemperature then
- love.graphics.printf(tostring(self.state.insideTemperature) .. "° / " .. tostring(self.state.insideHumidity) .. "%RH", 900, 378, 400, 'left')
+ love.graphics.printf(string.format("%d° / %d%%RH", self.state.insideTemperature, self.state.insideHumidity), 900, 378, 400, 'left')
else
love.graphics.printf("?!", 900, 378, 400, 'left')
end
love.graphics.printf("ON or OFF?", 900, 438, 400, 'left')
love.graphics.printf("ON or OFF?", 900, 498, 400, 'left')
- --love.graphics.setFont(atFont)
- --love.graphics.printf(os.date("Last update: %Y/%m/%d %H:%M", self.state.lastUpdate), 0, love.graphics.getHeight() - 60, love.graphics.getWidth(), 'center')
- --if self.state.insideTemperature then
- -- love.graphics.printf("Room: " .. tostring(self.state.insideTemperature) .. "° / " .. tostring(self.state.insideHumidity) .. "%RH", 0, love.graphics.getHeight() - 100, love.graphics.getWidth(), 'center')
- --end
love.graphics.setFont(headerFont)
love.graphics.printf("at hackerspace:", 50, 593, 300, 'left')
love.graphics.setFont(atFont)
if self.state.at then
users = lume.map(self.state.at.users, function(v) return v.login end)
if self.state.at.unknown > 0 then
- users[#users + 1] = tostring(self.state.at.unknown) .. " unknown creatures"
+ users[#users + 1] = string.format("%d unknown creatures", self.state.at.unknown)
end
if self.state.at.kektops > 0 then
- users[#users + 1] = tostring(self.state.at.kektops) .. " kektops"
+ users[#users + 1] = string.format("%d kektops", self.state.at.kektops)
end
if self.state.at.esps > 0 then
- users[#users + 1] = tostring(self.state.at.esps) .. " ESPs"
+ users[#users + 1] = string.format("%d ESPs", self.state.at.esps)
end
end
diff --git a/nodes/slideshow.lua b/nodes/slideshow.lua
index 7c051be..7abf0fe 100644
--- a/nodes/slideshow.lua
+++ b/nodes/slideshow.lua
@@ -8,12 +8,14 @@ function node:init(config)
end
function node:loadImage()
- local files = self:processFiles(self.files)
- if files ~= nil then
- if self.fileName then
- self.fileName = files[(lume.find(files, self.fileName) or 1) % #files + 1]
- else
- self.fileName = files[1]
+ if self.files then
+ local files = self:processFiles(self.files)
+ if files ~= nil then
+ if self.fileName then
+ self.fileName = files[(lume.find(files, self.fileName) or 1) % #files + 1]
+ else
+ self.fileName = files[1]
+ end
end
end