Okay, it’s a little hacky but it’s better than nothing. Here it is:
-- Number comparing
-- Use this function to perform your initial setup
function setup()
print("Hello World!")
local cb = function()
output.clear()
compare(a, b)
end
parameter.number("a", 0, 10000, 583.235, cb)
parameter.number("b", 0, 10000, 763.1, cb)
output.clear()
compare(583.235, 763.1)
end
function compare(num, num2)
local numstr = tostring(num)
local numstr2 = tostring(num2)
local _ = string.find(numstr, ".", 1, true)
local _2 = string.find(numstr2, ".", 1, true)
local d = false
local d2 = false
if _ ~= nil then
d = _
end
if _2 ~= nil then
d2 = _2
end
local nslen = string.len(numstr)
local ns2len = string.len(numstr2)
local nsflen = string.len(tostring(math.floor(tonumber(numstr))))
local ns2flen = string.len(tostring(math.floor(tonumber(numstr2))))
numstr = string.rep("0", math.max(nslen, ns2len) - (d or 0)) .. numstr
numstr2 = string.rep("0", math.max(nslen, ns2len) - (d2 or 0)) .. numstr2
numstr = numstr .. string.rep("0", math.max(math.max(0, nsflen) - (d2 or 0), math.max(0, ns2flen) - (d2 or 0)))
numstr2 = numstr2 .. string.rep("0", math.max(math.max(0, nsflen) - (d or 0), math.max(0, ns2flen) - (d2 or 0)))
print(numstr .. "\
" .. numstr2)
local _ = string.find(numstr, ".", 1, true)
local _2 = string.find(numstr2, ".", 1, true)
local d = false
local d2 = false
if _ ~= nil then
d = _
end
if _2 ~= nil then
d2 = _2
end
print("Decimal 1: " .. tostring(d))
print("Decimal 2: " .. tostring(d2))
for i = math.max(string.len(numstr), string.len(numstr2)), 1, -1 do
local c = "0"
if i <= string.len(numstr) then
c = string.sub(numstr, i, i) or "0"
end
local c2 = "0"
if i <= string.len(numstr2) then
c2 = string.sub(numstr2, i, i) or "0"
end
-- Compare c and c2.
if i ~= d and i ~= d2 and (c ~= "0" or c2 ~= "0") then
local n = tonumber(c) or 0
local n2 = tonumber(c2) or 0
if n > n2 then
print(c .. " > " .. c2)
elseif n < n2 then
print(c .. " < " .. c2)
elseif n == n2 then
print(c .. " = " .. c2)
end
elseif i == d and i == d2 then
print("Both decimals reached.")
elseif i == d then
print("#1 decimal reached.")
elseif i == d2 then
print("#2 decimal reached.")
end
end
end
-- This function gets called once every frame
function draw()
-- This sets a dark background color
background(40, 40, 50)
-- This sets the line thickness
strokeWidth(5)
-- Do your drawing here
end