Create copy of slide objects in master slide through JS

Problem:

ActivePresenter version: 10

OS: win 10/11

Notes:

Hi,

Is it possible through JS to scan a given slide for a hidden object (e.g. a square) and then create a copy of that object in the master slide where it is made visible and can then be placed in the background of other objects in the master slide.

Or, alternatively,

is it possible to create a copy of an object in the master slide and then insert that copy in a given slide?

To clarify my use case:
I use AP to create something like a game engine for point-and-click adventure games. Objects in the inventory are placed in the master slide because they need to be accessible on all slides. Sometimes this creates problematic effects, when a given slide contains some other object. In that case, something the player takes out of the inventory will suddenly be hidden behind that slide object.

I got my own personal workaround for that problem (with a copy of every slide object in the master slide). However, for the usability of my AP-project as a game-engine (for other people) it would be much nicer, if the game designer could put objects in a given slide and I programmed a routine in JS that created a copy of that object in the master slide (or the alternative as described above) and made sure that it was arranged correctly.

Thanks, Rolf

Hi Rolf,

I think using the Show over multiple slides (top layer) feature by right-clicking the object might help in this case. Could you please give it a try and see if it works for you?

Best regards,

Thanks, Hang,

unfortunately, that does not do the trick.

I attach a sample project and I hope it makes clear what my problem is.

Thanks a lot,

Rolf

Rolf Inventory problem.approj (1.1 MB)

Oh, I see what you mean now.

If you want to reuse objects (such as the inventory) across multiple slides, it’s better to use object templates rather than moving objects between the master slide and normal slides with JavaScript.

Object templates let you save reusable elements (like buttons, icons, or inventory items) and easily drag them onto any slide whenever needed. This way, you can avoid the visibility and layering issues caused by master-slide objects, while also making your game engine much easier for other developers to use in ActivePresenter.

For more details on how to use object templates in ActivePresenter, kindly refer to this tutorial:

Best regards,

Thanks,

I’m not sure …

If I understand you correctly, this would mean they I create an inventory on each game slide. So, if I have 300 slides and 20 items in the inventory that seems like a lot of work …

Is there a way in JS to copy objects from slides?

If that was possible I could have a normal slide that stores all the inventory items and I would create each inventory on every individual slide and create a temporary copy of the inventory objects in the inventory.

Best,

Rolf

No Rolf,

Object Template works like a toolbox that stays visible no matter which slide you’re on. Whenever you need an item from the toolbox, simply drag it from the pane onto the Canvas like this:

Thanks,

Just to clarify.

My idea is:

I have a normal slide called ‘inventory’ with all inventory items called ‘Inv1’, ‘Inv2’ and so on.

If in another slide the player opens the inventory, the following should happen (not in real code).

for all children of slide(inventory)
if childname.startsWith(‘Inv’) AND prez.variable(‘Found_childname’ == TRUE)
then insert child in currently active slide

can this be done in JS?

Thanks, again!!!

Thanks for your clarification.

Unfortunately, that’s not possible in ActivePresenter. Objects must already exist on the current slide, then you can only show or hide them, not copy or insert them from other slides.

Regards,

Thanks for clarifying!!!