ludic.ui: a scroll box without scroll-top asks ui_attr_has first - ui_attr's miss made a new null every frame on every screen that scrolls (the gate's one kept block a frame on map, shop, journal and craft)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-28 18:26:46 +03:00
parent 4e0c30488f
commit ab6b666fd6
2 changed files with 13 additions and 2 deletions

View file

@ -85,6 +85,15 @@ export function ui_attr(n: UiNode, key: string) -> Val {
}
return Value.null()
}
# whether an element has the attribute at all: ui_attr's miss is a new null, so a question asked
# every frame asks this first
export function ui_attr_has(n: UiNode, key: string) -> bool {
if n.akeys == null { return false }
for i in 0 .. len(n.akeys) {
if n.akeys[i] == key { return true }
}
return false
}
export function ui_attr_text(n: UiNode, key: string) -> string {
if n.akeys == null { return "" }
for i in 0 .. len(n.akeys) {

View file

@ -25,7 +25,9 @@ function sc_held(ui_st: mut UiState, n: UiNode, off: float, live: bool) -> float
List.pop(pxs)
}
}
let v = ui_attr(n, "scroll-top")
if Value.kind(v) != 0 { at = ui_px(ui_st, el_numv(ui_st, v)) }
if ui_attr_has(n, "scroll-top") {
let v = ui_attr(n, "scroll-top")
if Value.kind(v) != 0 { at = ui_px(ui_st, el_numv(ui_st, v)) }
}
return at
}