Additionally, if you didn't care about the order of the information prompted for either you could do away with storing that information in the sub-tables of choicetab and do something like this instead:
local choicetab = {
Health = function(args) return 70 * ((args["Average Damage"] * args.Size) / args.Speed) end,
Size = function(args) return (args.Health * args.Speed) / (70 * args["Average Damage"]) end,
Speed = function(args) return (70 * args["Average Damage"] * args.Size) / args.Health end,
["Average Damage"] = function(args) return (args.Health * args.Speed) / (70 * args.Size) end,
}
print("Choose what you want to find:")
for name in pairs(choicetab) do
print(name)
end
print()
local chosen = io.read()
local fun = choicetab[chosen]
if not fun then
error("Not a valid choice")
end
local argtab = {}
for name, v in pairs(choicetab) do
if name ~= chosen then
print("Input The "..name)
argtab[name] = io.read()
end
end
print(fun(argtab))
But that depends on the set of choices always being one more than the arguments that the calculation functions need which may or may not be a valid assumption in any broader case.