Page 1 of 1

Is addConnector() badly borked (a technical term)?

Posted: Sun Sep 29, 2024 9:45 pm
by DaggorathMaster
Is addConnector() badly borked?
I tried to add connectors in a specific case, runtime rather than littering the def files with hook definitions.

And I get an untraceable error (event-triggered, which dumps the event-handling stack and kindly omits anything I ever did).
Saying that "map" is nil. My scripts (for this) do not reference "map"

It may be particular to items, or their attack/action components.

Adding a connector with the same arguments, in the def files, works without error.
But requires editing all the def files. Trying to cut back on tediousness...

Code: Select all

function set_hook (item)
local act_nm = item:getPrimaryAction()
local compo = item.go:getComponent (act_nm)
compo:addConnector ("onHitMonster", self.go.id, "onHitMonster")
In this case, pre-checked (before calling this function) that getClass() == "MeleeAttackComponent"
And it was verified that:
- This script includes a valid "onHitMonster" function.
- "self" is this script, not reused as something else (like vanilla def files tend to do...)

It's pretty annoying to have to edit all the defs when trying to do something that using "addConnector" - in one place - was pretty clearly intended to do, but can't seem to handle.
<Frodo> We've been here before. We're going in circles!" </Frodo>

Re: Is addConnector() badly borked (a technical term)?

Posted: Mon Sep 30, 2024 12:58 am
by minmay
Connectors only work if the object with the connector and the target of the connector are both on a map. If you want to do something with objects that may not always be on a map, such as objects with ItemComponents, use hooks instead of connectors.