ludic migrate state packages <every example program> packages/ludic.lab/example/plate.ludic 1804 vars into 126 states, 64 into lets; 23498 edits in 460 files Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
22 lines
1,009 B
Text
22 lines
1,009 B
Text
# input_auto.ludic — proves the frame loop commits the device layer automatically
|
|
# (#83): a real handler game reads Input.active in its Update phase and NEVER calls
|
|
# Input.poll by hand, yet the action fires from the live key. Before this fix the
|
|
# loop only fed Input.key(), so Input.active read empty unless the game polled.
|
|
#
|
|
# Driven headless by the keys on stdin — one char per frame. With "llq": frame 1
|
|
# and 2 read 'l' (the action key), frame 3 reads 'q' (which quits). So the action
|
|
# is active on exactly two frames.
|
|
#
|
|
# Run: printf 'llq' | bin/ludic examples/library/input_auto.ludic -> 2
|
|
program InputAuto {
|
|
property Tag { n: int = 0 }
|
|
model Player { Tag }
|
|
|
|
state InputAutoState {
|
|
hits: int = 0
|
|
}
|
|
|
|
@OnStart handler Boot { Input.action("go", 'l') } # 'l' == 108
|
|
handler Sense(input_auto_st: mut InputAutoState) phase Update { if Input.active("go") { input_auto_st.hits += 1 } }
|
|
@OnQuit handler Report(input_auto_st: InputAutoState) { print(input_auto_st.hits) }
|
|
}
|