n? , w? What is this saying

Trying to decipher the wiki info. What are the ‘n’ and ‘w’ placeholders for when actually coding. Trying to script the creation of a container COMP from a CHOP execute DAT. And trying to figure out how to access the info on these WIKI pages in general, not very successfully.

1 Like

We are talking about python here so you don’t need to define the variables as a certain type.

In this example they did not include what the variable ‘n’ stands for. but the ‘w’ variable will represent the ‘boxSOP’ that is being created.

the ‘n’ variable is the op that you will be creating the new op inside.

in this situation you could do this:

n = parent() # make the destination the parent, so it shows up in the current window n.create(waveCHOP) # create a wave chop within the current op w = n.create(boxSOP, 'box12') # create a boxSOP and assign it to var 'w' w.nodeX = 200 # move the box sop over 200

Thanks harveymoon! It seems so simple but for non-programmers like me, some explanations in the wiki and elsewhere seem to assume ‘computer’ knowledge/skills that we don’t all have.

I’m thinking that if a common python phrase in TD like op(‘moviefilein1’).par.play starts with the ‘location’ of the event then with the “create.x” expression maybe you need to start with a ‘location’ for the event to happen as well? I’m just trying to figure out why I should have known what ‘n’ might have been is the first place.

Anyway, thanks again.
Eric

Yes, n and w are cryptic here. We will try to make the wiki doc more clear for novice scripters. Thanks for pointing this out.

n is a component in which you create the new node. n = op(‘base1’)

w is the operator that it creates, not sure why ‘w’ was chosen as its name.

Greg Hermanovic

if you’re not familiar with classes and objects in OOP, the Python wiki can seem a bit impenetrable.

you might think of it this way:

each operator has a set of pre-defined tasks that it can do, called methods. some methods are unique to specific operators, while others are common to related operators or even all operators, like the .cook() method.

The way we tell operators what to do is by first calling it out, adding a period (read as ‘dot’), and then calling the method, or task, that we want it to do.

‘n’ is just a stand-in used in the Python wiki for whatever operator you’re going to tell to do something; you could think of it as a short-hand for ‘node’.

so if we say op(‘container1’).create(boxSOP, ‘box 12’) what that means is "Hey container1, create a boxSOP called ‘box 12’. "

we could also say:

n = op(‘container1’)
n.create(boxSOP, ‘box 12’)