Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function midpoint(width, height)
- local x = math.floor(width / 2)
- local y = math.floor(height / 2)
- return x, y
- end
- function getXPosOfString(str, startX)
- local length = string.len(str)
- local midpoint
- if length % 2 == 0 then
- -- Accept that the string can't be centered on a single character, so generate a best guess
- midpoint = length / 2
- else
- -- The string can be centered on a single character, so select that character
- midpoint = math.floor(length / 2) - 1
- end
- return startX - midpoint
- end
- function hasKey(table, key)
- for k,v in pairs(table) do
- if k == key then
- return true
- end
- end
- return false
- end
- return { midpoint = midpoint, hasKey = hasKey, getXPosOfString = getXPosOfString }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement