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

Ask for help about creating mods and scripts for Grimrock 2 or share your tips, scripts, tools and assets with other modders here. Warning: forum contains spoilers!
Post Reply
User avatar
DaggorathMaster
Posts: 48
Joined: Thu Sep 08, 2022 7:29 pm

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

Post 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>
minmay
Posts: 2777
Joined: Mon Sep 23, 2013 2:24 am

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

Post 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.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Post Reply