On damage event is only triggering once for a script and needs the script to be reset to work again
This happens in both
SLua
and
LSL: Luau
This does not happen in
LSL
If you setup a
once
registered event handler on each click, those will report correctly but only if you dont have an existing
on
registered handler
Reproduction
  1. Be in a sim with
    allow damage adjustment
    set to true - and in a parcel with damage enabled
  2. Create a prim
  3. Take a copy
  4. Add the copy to the prim's inventory (leave it's name as
    Object
    )
  5. add this script to the prim
LLEvents:on("touch_start", function(detected)
ll.OwnerSay(`{#LLEvents:listeners("on_damage")}`)
ll.RezObjectWithParams(
"Object",
{
REZ_FLAGS, bit32.bor(REZ_FLAG_TEMP,REZ_FLAG_PHYSICAL,REZ_FLAG_DIE_ON_COLLIDE,REZ_FLAG_DIE_ON_NOENTRY),
REZ_POS, vector(0,0,2), true, true,
REZ_DAMAGE, 10,
REZ_DAMAGE_TYPE, DAMAGE_TYPE_BLUDGEONING,
}
)
end)
LLEvents:on("on_damage",function()
ll.OwnerSay(`on damage`)
end)
  1. Click the prim, outputs
1
on damage
  1. Click the prim, outputs
1
Note that every hit after the first prints no
on damage
text
This also happens in
LSL: Luau
LSL Script
default {
touch_start(integer count) {
llRezObjectWithParams(
"Object",
[
REZ_FLAGS, REZ_FLAG_TEMP|REZ_FLAG_PHYSICAL|REZ_FLAG_DIE_ON_COLLIDE|REZ_FLAG_DIE_ON_NOENTRY,
REZ_POS, <0,0,2>, TRUE, TRUE,
REZ_DAMAGE, 10,
REZ_DAMAGE_TYPE, DAMAGE_TYPE_BLUDGEONING
]
);
}
on_damage(integer count) {
llOwnerSay("on damage");
}
}
Saving that back and forth between lsl luau and lsl mono will show the difference