Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

can't access dd from scripts on contraptions within prototypes?

A topic by anniesden created 19 days ago Views: 104 Replies: 3
Viewing posts 1 to 4
(+1)

hi i just started learning Decker! i’m trying to make a prototype which contains a button, with a script on the button that uses the dd module. i have the dd module working directly on contraptions on my card, but for some reason it doesn’t work within a prototype. i’m confused because i can access all the info about the card (which is just the prototype), and the deck, but i cannot access dd (which i figured was part of the deck itself).

i have copied and pasted the same example code to make sure i’m not typing anything in wrong.

(1 edit) (+1)

i noticed if i simply put dd into listener, it says nil anywhere other than at the card-level view…

what is the intended way to access modules from a prototype? i see i can access deck.modules.dd but it does not seem like i can call anything on it…

(+2)

update: dug around in the modules section of the documentation and discovered that the module.value is the same thing as calling “dd” at the card-level. so i can simply do dd:deck.modules.dd.value in my prototype script and it works! it just doesn’t show up in the prototype-view itself, but that’s fair since it is a script on the deck

Developer(+2)

Given a reference to the deck, you can manually obtain the closure for a module like so:

deck.modules.dd.value

See the reference documentation for the Module Interface.

In most cases, though, I'd recommend breaking down the responsibilities of a contraption such that it doesn't internally access or depend upon modules or other contraptions. You might consider a contraption which dispatches events to external scripts, and have those external "widget-level" scripts interact with modules or other deck-level resources, for example. Ideally, modules and prototypes are freestanding, reusable parts.