Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

As described in the v1.36 release notes, sending a "synthetic" event to a contraption instance would cause it to be handled by the contraption's "external" (per-instance) script.

The deck-level script, like most scripts, is not executed while Decker is not in Interact mode. The only opportunity for a Contraption's scripts to execute during editing is the code inside custom attribute handlers, which is capped within a very brief quota. In both cases, these constraints exist to prevent incomplete or malformed scripts from wedging Decker and rendering it unusable.

(1 edit)

got it! Thanks for replying my flurry of questions and giving me leads to overcome my issues :)

I'm documenting my fix here, in case someone has similar needs.

1. Adding a template script.

I have created a view function in the prototype's template script, calling me.init[], the function that uses internal widgets to restore persistent data

on view do
  me.init[]
end

2. Exposing the inner init function.

The init function is located in the prototype's script, so it cannot be reached from a contraption's script. It has to be exposed by creating a get_x function in that same script

on init do
  # here should be some logic to restore persistent data
end
on get_init do
  # expose init function, so that it can be called from outside the prototype's script
  init
end

With these two changes: every contraption made from that prototype is created with that view function, which lets me send "synthetic" view events & the way these events are processed is still relying on the prototype's functions.