Page 1 of 1

Layer Reset Button (position)

Posted: Tue May 01, 2012 11:41 am
by martyw79
Hello,

I've new to creating modules.

I'm trying to create a module with a button that when pressed will reset a layers position back to default.
Along with this button I have two sliders that move the layer along the Y and X axis, which I've manage to create.

Looking at the 'Reset' button on the existing 'Centre (Layer)' module I can't really tell what's the code or setting to tell the button to reset the layer?

In a module I've created, I made the settings the same as the Reset button on the 'Centre (Layer)' module, but pressing the button does nothing.

Any help or direction appreciated.

Marty

Re: Layer Reset Button (position)

Posted: Tue May 01, 2012 11:45 am
by martyw79
I've created two buttons to reset each axis (x & y) layer position, but looking to combine this into one button.

Re: Layer Reset Button (position)

Posted: Tue May 01, 2012 6:30 pm
by The Midi Thief
If you want to reset an object to the middle of the screen (position: 0) and you have a button called "reset" (the button is sending the message "reset") then this is the code that you add to the MessageEvent part of the module script:

Code: Select all

if msg == "reset" and param['value']:
   modul8.setValue('ctrl_layer_position_x',0,1)
   modul8.setValue('ctrl_layer_position_y',0,1)

0 is the position and 1 is the layer number.

I'm seing that the forum is editing out my tab indents. For python it's of utter most importance to have an indent on all the lines after an if statement so both lines starting with "modul8" has a tab in front.

Edit: Haha and then I discoverd the BB code for marking up code, how convenient.

Good luck!

Re: Layer Reset Button (position)

Posted: Tue May 01, 2012 6:55 pm
by martyw79
The Midi Thief,

That's exactly what I needed!
Thanks for your help kind Sir.


Marty

Re: Layer Reset Button (position)

Posted: Tue May 01, 2012 10:27 pm
by sigmasix
check the manual or the online modules manual, you can achieve this simple task without code