Support

If you have a problem or need to report a bug please email : support@dsprobotics.com

There are 3 sections to this support area:

DOWNLOADS: access to product manuals, support files and drivers

HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects

USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here

NEW REGISTRATIONS - please contact us if you wish to register on the forum

Users are reminded of the forum rules they sign up to which prohibits any activity that violates any laws including posting material covered by copyright

RUBY - XY Surface

For general discussion related FlowStone

Re: RUBY - XY Surface

Postby Rocko » Wed Feb 10, 2016 3:43 pm

Appreciated...

I had changed the variables to lower case... But still doesn't work.

I noticed that this works:
@sx=getViewSize;


But this doesn't:
@sx=getViewSize[0];

Why can;t I assign @sx to be a single variable out of an array ?
Rocko
 
Posts: 186
Joined: Tue May 15, 2012 12:42 pm

Re: RUBY - XY Surface

Postby tulamide » Wed Feb 10, 2016 10:24 pm

You can assign a single variable from an array, and it is done just as you tried it. If it doesn't work it could mean you previously used the same variable for an array. However, wild guessing won't help you. Prepare a schematic that shows your issue, so that we can have a look. I wouldn't know how else to help.
"There lies the dog buried" (German saying translated literally)
tulamide
 
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: RUBY - XY Surface

Postby billv » Thu Feb 11, 2016 2:41 am

In your fsm Rocko, there's a redraw in the draw section.
I think it also helps to define the @vw and @vh in the draw section.
For eg: This works fine...
Code: Select all
def isInMousePoint x,y
true
end
def mouseLDown x,y
    captureMouse
end
def mouseMoveCaptured x,y
    if x > @vw then output 0, x = @vw end
    if x < 0   then output 0, x = 0   end
    if y > @vh then output 1, y = @vh end
    if y < 0   then output 1, y = 0   end
    output 0, @x=x
    output 1, @y=y
    redraw
end
def mouseLUp x,y
   releaseMouse
end

def draw v
@vh = v.height-1
@vw = v.width-1
pen = Brush.new @c1,0.2
v. drawEllipse pen,[@x,@y,1,1]

end
billv
 
Posts: 1157
Joined: Tue Aug 31, 2010 3:34 pm
Location: Australia

Re: RUBY - XY Surface

Postby Rocko » Thu Feb 11, 2016 11:12 am

Hi,

Your help to offer is really appreciated. Here is my code for your reference.
Attachments
XY_Test_v4.fsm
(1.44 KiB) Downloaded 1096 times
Rocko
 
Posts: 186
Joined: Tue May 15, 2012 12:42 pm

Re: RUBY - XY Surface

Postby RJHollins » Thu Feb 11, 2016 11:41 am

hmm ... Now I've lost track ... Is there still a problem ???

Seems to work as expected here.

The only thing I suggest ... if the window is re-sized, everything recalculates and places the 'select ball' in field.
RJHollins
 
Posts: 1571
Joined: Thu Mar 08, 2012 7:58 pm

Re: RUBY - XY Surface

Postby Rocko » Thu Feb 11, 2016 11:59 am

Hi,

Notice this line with the '#' mark:
#@sx=getViewSize[0]; //This is the problematic line

If you remove the # to make it active. Then restart the FSM, it doesn't start and reports an error.
Rocko
 
Posts: 186
Joined: Tue May 15, 2012 12:42 pm

Re: RUBY - XY Surface

Postby tulamide » Thu Feb 11, 2016 12:58 pm

Hey Rocko,

this fix should work. It was like I said, you try to access the view before it is initialized. Another tip: always use methods, don't just declare variables somewhere in the RubyEdit. The right place for this is a method called init. In this case a variation is used: Instead of initializing the vars at init of the RubyEdit, I use an afterload trigger to run another method (you can name this method as you see fit). This way I make sure that the view already exists before you access it via getViewSize.
Attachments
XY_Test_v4 [tula].fsm
(1.45 KiB) Downloaded 1070 times
"There lies the dog buried" (German saying translated literally)
tulamide
 
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: RUBY - XY Surface

Postby Rocko » Thu Feb 11, 2016 1:40 pm

Hi,

This is working great and now better understood. Appreciated :D :D

Currently @cx and @cy are initialized after load. This might contradict saving it in 'flowstones preset' (which I usually use to save VST data like knob and slider values).
Any hints on how to save @cx and @cy from last read - on DAW (like preset auto save mode)?
Rocko
 
Posts: 186
Joined: Tue May 15, 2012 12:42 pm

Re: RUBY - XY Surface

Postby tulamide » Thu Feb 11, 2016 2:06 pm

If you use this method:
Code: Select all
def init
  #initialize @cx/@cy here
end


the variables will be initialized when the RubyEdit is initialized. They can then be easily overwritten by an input from the preset manager (presets update after load). You do that by extending the already existing event method:

Code: Select all
#assuming there are two inputs named px and py that are sent from the preset
def event i, v
  if i == 'px'
    @cx = v
    redraw
  elsif i == 'py'
    @cy = v
    redraw
  end
end
"There lies the dog buried" (German saying translated literally)
tulamide
 
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: RUBY - XY Surface

Postby clemensweinhold » Thu Feb 11, 2016 6:40 pm

Does somebody know how to make a loop in ruby for multiple objects?
clemensweinhold
 
Posts: 2
Joined: Wed Apr 08, 2015 7:06 pm

PreviousNext

Return to General

Who is online

Users browsing this forum: No registered users and 48 guests