From 1b1780946edebfbf1e8ec2cf095b56fa76733e2b Mon Sep 17 00:00:00 2001
From: Vanessa Ezekowitz <vanessaezekowitz@gmail.com>
Date: Sat, 12 Sep 2015 07:18:16 +0200
Subject: [PATCH] add facedir to tool workshop

---
 technic/helpers.lua |   42 +++++++-----------------------------------
 1 files changed, 7 insertions(+), 35 deletions(-)

diff --git a/technic/helpers.lua b/technic/helpers.lua
index de315d0..e8efcf3 100644
--- a/technic/helpers.lua
+++ b/technic/helpers.lua
@@ -1,5 +1,5 @@
 --load config
-local sepchar, baresepchar = nil, nil
+local sepchar = nil
 do
 	local sepcode = technic.config:get("thousand_separator")
 	--default is SI style
@@ -58,38 +58,10 @@
 	return nil
 end
 
-function technic.format(str, ...)
-	local arg={...}
-	local param = nil
-	local percent = false
-	local res = ""
-	local i = 1
-	for c in str:gmatch"." do
-		if percent then
-			assert(c ~= "%") --syntax error
-			if c == "e" then
-				-- use enhanced number formatting
-				-- only works for unsigned numbers
-				local numstr = tostring(math.abs(arg[i]))
-				local a, b, body, frac = numstr:find("^(%d+)([.]?.-)$")
-				a = 1
-				body = body..baresepchar
-				while a ~= 0 do
-					body, a = body:gsub("(%d)(%d%d%d)"..sepchar, "%1"..sepchar.."%2"..sepchar, 1)
-				end
-				body = body:gsub(sepchar.."$", "")
-				res = res .. body .. frac
-			else
-				--use traditional string:format
-				res = res .. (string.format(("%"..c), arg[i]))
-			end
-			i = i + 1
-			percent = false
-		elseif c == "%" then
-			percent = true
-		else
-			res = res .. c
-		end
-	end
-	return res
+function technic.prettynum(num)
+	local str, k = tostring(num), nil
+	repeat
+		str, k = str:gsub("^(-?%d+)(%d%d%d)", "%1"..sepchar.."%2")
+	until k == 0
+	return str
 end
\ No newline at end of file

--
Gitblit v1.8.0