loadbang only when abstraction made

elmiller's icon

Sorry for the odd title, I'm not even sure what to call this.

I made an abstraction (simplified version attached) which when added to a parent patcher will create a new flonum in the parent patcher. The problem is that once the parent is saved and reloaded, another flonum is then stacked on top of the original. I am not sure how I could gate it so that the script message only goes through the first time. I thought perhaps some kind of query to see if a named object already existed, but I could not find info on if or how that's done.

Max Patch
Copy patch and select New From Clipboard in Max.

parent patch:

Max Patch
Copy patch and select New From Clipboard in Max.

abstraction [flonum_creator]:

Thanks,
Eric

Roman Thilenius's icon

change the abstraction so that it will always attempt do delete, then create the object.

elmiller's icon

Thanks Roman. I had thought of that as well, but there are two issues I have with it (should have mentioned them in the first post)

1) I want to make this reusable and be able to change the appearance/behavior of the flonum with the inspector for separate instances (rather than hard code it during creation)

2) I need to be able to connect each instance to different objects in a patch (rather than hard code a connection during creation as well)

The reason I am doing this is to have a decent amount of code in the [flonum_creator] abstraction with specific sends/receives and other data affecting the flonum. I basically want to add a bunch of functionality to the flonum (and other ui objects). I thought about jsui, but it is way more than I would have an idea to do with js. I also thought about using a bpatcher with all the other code inside, but then could not use the inspector to adjust appearance and behavior of the flonum. Ideally, I would like to be able to add the abstraction [flonum_creator] to a patch and have a flonum appear with a scripting name and all connections to the code in the [flonum_creator] already linked to the object, then be able to edit the flonum through the inpsector like any flonum object (and have those changes not get overwritten when loading the parent patch).

Not sure if anyone reading this is familiar with ppooll, but when the abstraction [actmaker] is added to a patch, other objects are created around it, but not recreated every time the patch is made. I've spent hours looking at it, but it's so nested that I can't make sense of it. I'll keep trying to untangle it, but if anyone knows of any solutions or suggestions, I'd appreciate it. I apologize for the length of this post.

Thanks,
Eric

Tj Shredder's icon

Give your object a name, use pattrexists to find out if it exists, only create if it doesn't...

Stefan

elmiller's icon

Perfect; I had no idea about this. Thanks Stefan!