Layer Reset Button (position)
  • martyw79
    activ8 member
    Posts: 54
    Joined: Wed Sep 23, 2009 5:26 am

    Layer Reset Button (position)

    by martyw79 » Tue May 01, 2012 11:41 am

    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
  • martyw79
    activ8 member
    Posts: 54
    Joined: Wed Sep 23, 2009 5:26 am

    Re: Layer Reset Button (position)

    by martyw79 » Tue May 01, 2012 11:45 am

    I've created two buttons to reset each axis (x & y) layer position, but looking to combine this into one button.
  • User avatar
    The Midi Thief
    master
    Posts: 483
    Joined: Thu Sep 29, 2005 7:19 pm
    Location: Stockholm, Sweden
    Contact:

    Re: Layer Reset Button (position)

    by The Midi Thief » Tue May 01, 2012 6:30 pm

    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!
    Last edited by The Midi Thief on Tue May 01, 2012 7:10 pm, edited 4 times in total.
  • martyw79
    activ8 member
    Posts: 54
    Joined: Wed Sep 23, 2009 5:26 am

    Re: Layer Reset Button (position)

    by martyw79 » Tue May 01, 2012 6:55 pm

    The Midi Thief,

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


    Marty
  • User avatar
    sigmasix
    master
    Posts: 1224
    Joined: Thu Dec 02, 2004 2:12 pm
    Location: gva | switzerland
    Contact:

    Re: Layer Reset Button (position)

    by sigmasix » Tue May 01, 2012 10:27 pm

    check the manual or the online modules manual, you can achieve this simple task without code

Who is online

Users browsing this forum: No registered users and 10 guests