errors and warnings / stdlib / E8070
E8070 error
Settings control bound to a field of the wrong type
- area
- stdlib (x8xxx)
- fails the build
- yes
A wowlua:settings control is bound to a store field of a type it can't edit.
A checkbox needs a boolean field, a slider a number field and a color
a { r: number, g: number, b: number, a: number? } field. The compiler checks
each control in the controls list against the type of store (what
saved.bind returns). Use the control that fits the field, or change the
field's default value to the type the control needs.
Example
{ "package": { "name": "playground", "version": "0.1.0", "wowlua": "^0.13" }, "flavors": { "camelot": {} }, "addon": { "saved-variables": ["PlaygroundDB"] }}import * as settings from "wowlua:settings"import * as saved from "wowlua:saved" local db = saved.bind("PlaygroundDB", { version = 1, defaults = { scale = 1, locked = false } }) settings.register({ title = "Playground", store = db, controls = { settings.checkbox("scale", { label = "Scale" }) },}){ "package": { "name": "playground", "version": "0.1.0", "wowlua": "^0.13" }, "flavors": { "camelot": {} }, "addon": { "saved-variables": ["PlaygroundDB"] }}import * as settings from "wowlua:settings"import * as saved from "wowlua:saved" local db = saved.bind("PlaygroundDB", { version = 1, defaults = { scale = 1, locked = false } }) settings.register({ title = "Playground", store = db, controls = { settings.slider("scale", { label = "Scale", min = 0.5, max = 2, step = 0.1 }), settings.checkbox("locked", { label = "Lock frame" }), },})The compiler reports it like this:
error[E8070]: `scale` is `number`; a checkbox needs `boolean` ┌─ src/main.wowlua:9:36 │ 9 │ controls = { settings.checkbox("scale", { label = "Scale" }) }, │ ^^^^^^^ here
Related codes
| code | message |
|---|---|
| E8113 | Settings control key not found in the store's type |
| E8107 | Settings dropdown option value not in the field's type |
Offline
$ wowlua explain E8070 E8070 (error): Settings control bound to a field of the wrong type