From 0e1e964948c39bd4fb0c747bfbedb404b12bd06d Mon Sep 17 00:00:00 2001 From: sammy-ette Date: Sat, 14 Jun 2025 10:39:58 -0400 Subject: [PATCH] feat: impl bool for clua --- moonlight/runtime_clua.go | 2 ++ moonlight/value_clua.go | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/moonlight/runtime_clua.go b/moonlight/runtime_clua.go index 5e114da5..943dc0bd 100644 --- a/moonlight/runtime_clua.go +++ b/moonlight/runtime_clua.go @@ -49,6 +49,8 @@ func (mlr *Runtime) pushToState(v Value) { mlr.state.PushNil() case StringType: mlr.state.PushString(v.AsString()) + case BoolType: + mlr.state.PushBoolean(v.AsBool()) case TableType: tbl := v.AsTable() tbl.SetRuntime(mlr) diff --git a/moonlight/value_clua.go b/moonlight/value_clua.go index 0157e330..4e8578c3 100644 --- a/moonlight/value_clua.go +++ b/moonlight/value_clua.go @@ -102,6 +102,14 @@ func (v Value) AsString() string { return v.iface.(string) } +func (v Value) AsBool() bool { + if v.Type() != BoolType { + panic("value type was not bool") + } + + return v.iface.(bool) +} + func (v Value) AsTable() *Table { return v.iface.(*Table) }