Skip to content

on_damage event not being handled as a detected event #21

@WolfGangS

Description

@WolfGangS

on_damage is not being passed the new DetectedEvent userdata values

I suspect this is due to this set containing "damage" instead of "on_damage"

slua/VM/src/lllevents.cpp

Lines 512 to 522 in ecea738

static const std::unordered_set<std::string> MULTI_EVENT_NAMES = {
"touch_start",
"touch_end",
"touch",
"collision_start",
"collision",
"collision_end",
"sensor",
"damage",
"final_damage"
};

Reproduction

  1. Create a prim
  2. Take a copy
  3. Add the copy to the prim's inventory (leave it's name as Object)
  4. add this script to the prim
local touchStart = function(detected)
    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("touch_start",touchStart)

LLEvents:on("on_damage",function(a)
    ll.OwnerSay(`on_damage {a} {typeof(a)}`)
end)
  1. Click the prim
  2. Notice the message on_damage 1 number in chat

Additional

Personally I would prefer on_damage, on_rez, and on_death to drop their on_ prefix, as

LLEvents:on("damage", ...)

Reads cleaner than

LLEvents:on("on_damage", ...)

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions