2021-11-19 21:53:30 +00:00
|
|
|
package numeric
|
|
|
|
|
2022-02-10 00:12:57 +00:00
|
|
|
import (
|
|
|
|
"math"
|
|
|
|
|
|
|
|
"github.com/Luzifer/twitch-bot/plugins"
|
|
|
|
)
|
2021-11-19 21:53:30 +00:00
|
|
|
|
|
|
|
func Register(args plugins.RegistrationArguments) error {
|
2022-02-10 00:12:57 +00:00
|
|
|
args.RegisterTemplateFunction("add", plugins.GenericTemplateFunctionGetter(add))
|
|
|
|
args.RegisterTemplateFunction("div", plugins.GenericTemplateFunctionGetter(div))
|
|
|
|
args.RegisterTemplateFunction("mul", plugins.GenericTemplateFunctionGetter(mul))
|
|
|
|
args.RegisterTemplateFunction("multiply", plugins.GenericTemplateFunctionGetter(mul)) // DEPRECATED
|
|
|
|
args.RegisterTemplateFunction("pow", plugins.GenericTemplateFunctionGetter(math.Pow))
|
|
|
|
args.RegisterTemplateFunction("sub", plugins.GenericTemplateFunctionGetter(sub))
|
2021-11-19 21:53:30 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2022-02-10 00:12:57 +00:00
|
|
|
func add(m1, m2 float64) float64 { return m1 + m2 }
|
|
|
|
func div(m1, m2 float64) float64 { return m1 / m2 }
|
|
|
|
func mul(m1, m2 float64) float64 { return m1 * m2 }
|
|
|
|
func sub(m1, m2 float64) float64 { return m1 - m2 }
|