-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathutils.lua
More file actions
35 lines (31 loc) · 765 Bytes
/
utils.lua
File metadata and controls
35 lines (31 loc) · 765 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
local m = {}
local w, h = love.graphics.getWidth(), love.graphics.getHeight()
local unpack = unpack or table.unpack
function m.tc(ux, uy, _w, _h)
w, h = _w or w, _h or h
return ux * w, uy * h
end
function m.tu(cx, cy, _w, _h)
w, h = _w or w, _h or h
return cx / w, cy / h
end
function m.error_handle (...)
local args = {...}
if args[1] == false or args[1] == nil then
local error_mess = args[#args]
m.error (error_mess)
else
--table.remove(args, #args)
return unpack(args)
end
end
m.error = function (err)
io.stderr:write(os.date("[%H:%M] ERROR: ")..(err or "").."\n")
end
m.info = function (text)
io.stdout:write(os.date("[%H:%M] INFO: ")..(text or "").."\n")
end
m.pcall = function (...)
m.error_handle(pcall(...))
end
return m