Module:ValComp: Difference between revisions
From Exiled Kingdoms Wiki
mNo edit summary |
mNo edit summary |
||
Line 1: | Line 1: | ||
--[[ | |||
Setup at top of module | |||
local Comp = require( "Module:ValComp" ) | |||
To use | |||
Comp.Compare(arg1,sym,arg2) | |||
Returns true or false | |||
]] | |||
p = {} | p = {} | ||
Revision as of 20:41, 7 June 2017
--[[ Setup at top of module local Comp = require( "Module:ValComp" )
To use Comp.Compare(arg1,sym,arg2) Returns true or false ]]
p = {}
function p.Compare(Arg1, Symb, Arg2)
result = false if (Symb == 'gt' or Symb == '>') then if (tonumber(Arg1) > tonumber(Arg2)) then result = true end elseif (Symb == 'lt' or Symb == '<') then if (tonumber(Arg1) < tonumber(Arg2)) then result = true end elseif (Symb == 'ge' or Symb == '>=') then if (tonumber(Arg1) >= tonumber(Arg2)) then result = true end elseif (Symb == 'le' or Symb == '<=') then if (tonumber(Arg1) <= tonumber(Arg2)) then result = true end elseif (Symb == 'eq' or Symb == '=') then if (tonumber(Arg1) == tonumber(Arg2)) then result = true end elseif (Symb == 'ne' or Symb == '!=') then if (tonumber(Arg1) ~= tonumber(Arg2)) then result = true end end return result
end
return p