wip(0.S3): packages and examples migrated in one run - ludic migrate state packages <every example program> packages/ludic.lab/example/plate.ludic
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
d490d4f9f1
commit
3eda72e8c2
172 changed files with 3094 additions and 2966 deletions
|
|
@ -3,14 +3,16 @@
|
|||
# `Damage` has two @On listeners: one prints the amount, one accumulates a total.
|
||||
# Emitting it twice runs both listeners each time. Prints 10 / 32 / 42.
|
||||
program ModEvents {
|
||||
var total: int = 0
|
||||
state ModeventsState {
|
||||
total: int = 0
|
||||
}
|
||||
event Damage { amount: int = 0 }
|
||||
@On(Damage) handler Native { print(amount) } # prints each hit
|
||||
@On(Damage) handler Accum { total += amount } # sums them
|
||||
@On(Damage) handler Accum(modevents_st: mut ModeventsState) { modevents_st.total += amount } # sums them
|
||||
|
||||
entry {
|
||||
entry (modevents_st: ModeventsState) {
|
||||
emit Damage(amount: 10) # Native prints 10
|
||||
emit Damage(amount: 32) # Native prints 32
|
||||
print(total) # 42
|
||||
print(modevents_st.total) # 42
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue