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 for noobs!
26 posts
• Page 1 of 3 • 1, 2, 3
Ruby for noobs!
Hi guys
I am a completely lost soul when it comes to ruby but i would like to try out scripts that other people have made available on the net! trouble is i have not the slightest clue as to how we use them or prep them for use in FlowStone and Im sure there will be more like me!
I have tried pasting a few into the ruby box but Im lost on how we set up the data ins and outs to use the scripts
Is there any chance one of you more learned fellows could rattle together a little tutorial on this subject? any pointers would be really really appreciated
Best Regards Jay
I am a completely lost soul when it comes to ruby but i would like to try out scripts that other people have made available on the net! trouble is i have not the slightest clue as to how we use them or prep them for use in FlowStone and Im sure there will be more like me!
I have tried pasting a few into the ruby box but Im lost on how we set up the data ins and outs to use the scripts
Is there any chance one of you more learned fellows could rattle together a little tutorial on this subject? any pointers would be really really appreciated
Best Regards Jay
- Jay
- Posts: 276
- Joined: Tue Jul 13, 2010 5:42 pm
Re: Ruby for noobs!
For some time I kept getting ready to start such a subject. I think most users SM did not have to do with some programming language. Or even if they had not sufficiently mastered for various reasons.
When I chose SynthMaker I liked that I could do many things without being forced to write a line of code.
Now I really want to do more, but existing tutorials are not enough. For that I suggest that those who know the language well, they give us simple examples with more detailed comments (if possible) at regular intervals.
I think this would be the benefit of all.
Thank You!
When I chose SynthMaker I liked that I could do many things without being forced to write a line of code.
Now I really want to do more, but existing tutorials are not enough. For that I suggest that those who know the language well, they give us simple examples with more detailed comments (if possible) at regular intervals.
I think this would be the benefit of all.
Thank You!
- pall
- Posts: 31
- Joined: Thu Dec 09, 2010 1:27 pm
- Location: Transilvania
Re: Ruby for noobs!
Let's learn together Ruby. I think it's better to start from the bottom level.
Here is a customizable RoundRectangle. I do not know how accurate it is, therefore please those advanced in ruby, come with corrections.
I think we can learn a lot from each other.
Here is a customizable RoundRectangle. I do not know how accurate it is, therefore please those advanced in ruby, come with corrections.
I think we can learn a lot from each other.
- Attachments
-
- roundrectangle 01.fsm
- correction in prop. pannel
- (720 Bytes) Downloaded 1371 times
- pall
- Posts: 31
- Joined: Thu Dec 09, 2010 1:27 pm
- Location: Transilvania
Re: Ruby for noobs!
here it is with outline, you can turn outline and back to on or off and you can set the outline to inset or center, everything is customizeable in the properties...
- Attachments
-
- roundrectangle 02.fsm
- (1.15 KiB) Downloaded 1391 times
-
Nubeat7 - Posts: 1347
- Joined: Sat Apr 14, 2012 9:59 am
- Location: Vienna
Re: Ruby for noobs!
Hi Nubeat!
I'm glad you're here.
I am very curious if mouse pointer can be applied to RoundRectangle in the same form.
In green primitives be able only square areas.
Cheers!
I'm glad you're here.
I am very curious if mouse pointer can be applied to RoundRectangle in the same form.
In green primitives be able only square areas.
Cheers!
- Attachments
-
- roundrectangle 03.fsm
- (1.67 KiB) Downloaded 1347 times
- pall
- Posts: 31
- Joined: Thu Dec 09, 2010 1:27 pm
- Location: Transilvania
Re: Ruby for noobs!
do you mean the different cursors? its shown in this example how to drag your shape around and how to choose another cursor...
- Attachments
-
- roundrectangle 04.fsm
- (1.4 KiB) Downloaded 1362 times
-
Nubeat7 - Posts: 1347
- Joined: Sat Apr 14, 2012 9:59 am
- Location: Vienna
Re: Ruby for noobs!
ok, while playing with this ihad the idea to do a x/y pad from it, it seems it is working ok but i have the problem that the cursor is not over the middle of the shape which makes it not very comfortable when changing the position ?? someone could fix this? - i couldn`t find the way to do it right.. and also the load and save state should be done! i was wondering why this
after reloading the project i get an error message that loadState is wrong arguments 1 from 0??
anyway i`m not sure if the load and save states that important in this case, i just thuoght because it is also inside the sliders and knobs...
- Code: Select all
def saveState
[@valx,@valy]
end
def loadState
@valx,@valy = v
end
after reloading the project i get an error message that loadState is wrong arguments 1 from 0??
anyway i`m not sure if the load and save states that important in this case, i just thuoght because it is also inside the sliders and knobs...
- Attachments
-
- roundrectangle_xy.fsm
- (1.76 KiB) Downloaded 1368 times
-
Nubeat7 - Posts: 1347
- Joined: Sat Apr 14, 2012 9:59 am
- Location: Vienna
Re: Ruby for noobs!
A suggestion Nubeat...
The main objective for this window (X / Y pad) is to get the correct visual effect. If the output is not correct value, it can be solved with green, or with another ruby.
But maybe I'm wrong?
The main objective for this window (X / Y pad) is to get the correct visual effect. If the output is not correct value, it can be solved with green, or with another ruby.
But maybe I'm wrong?
- Attachments
-
- roundrectangle_xy 01.fsm
- (5.71 KiB) Downloaded 1364 times
- pall
- Posts: 31
- Joined: Thu Dec 09, 2010 1:27 pm
- Location: Transilvania
Re: Ruby for noobs!
Maybe this is more like you are after?
I've just changed the mouseLDown and mouseMoveCaptured methods. Previously, they were using the technique used for knobs - finding out how much the cursor has moved, times sensitivity, then adding that to the current position.
Because you want the object to "stick" to the cursor in this case, it's simpler to just take the absolute value of the cursor position and just scale it by the window size - the object will then stick to the cursor regardless of the window size.
I also slightly edited the 'handle' size variables 'h' and 'w' by putting ".0" after the numbers. That might seem strange, but you need that sometimes to make Ruby realise that you want a float value. Without a decimal point there, it assumes you want an integer; 'h/2' and 'w/2' would then have an integer on both sides of the divide, and Ruby would do an integer divide with an integer answer - which for an odd number would be wrong by 0.5.
You can also force an integer to be treated as a float using the '.to_f' method...
...but in the case of static values, just adding the '.0' is much simpler and more efficient.
You just need to add one letter!
The missing argument is for loadState - the value 'v' used in the variable assignment represents the loaded data, which is fed automatically to the method by FS when it loads. So all that's needed is to declare 'v' as an argument to the method on the 'def' line, so that FS has somewhere to put the data...
Aside from those little glitches it's looking very good - another useful addition to our new FS arsenal of goodies!
I've just changed the mouseLDown and mouseMoveCaptured methods. Previously, they were using the technique used for knobs - finding out how much the cursor has moved, times sensitivity, then adding that to the current position.
Because you want the object to "stick" to the cursor in this case, it's simpler to just take the absolute value of the cursor position and just scale it by the window size - the object will then stick to the cursor regardless of the window size.
I also slightly edited the 'handle' size variables 'h' and 'w' by putting ".0" after the numbers. That might seem strange, but you need that sometimes to make Ruby realise that you want a float value. Without a decimal point there, it assumes you want an integer; 'h/2' and 'w/2' would then have an integer on both sides of the divide, and Ruby would do an integer divide with an integer answer - which for an odd number would be wrong by 0.5.
You can also force an integer to be treated as a float using the '.to_f' method...
- Code: Select all
myInteger = 10
myFloat = myInteger.to_f
...but in the case of static values, just adding the '.0' is much simpler and more efficient.
Nubeat7 wrote:after reloading the project i get an error message that loadState is wrong arguments 1 from 0??
You just need to add one letter!
The missing argument is for loadState - the value 'v' used in the variable assignment represents the loaded data, which is fed automatically to the method by FS when it loads. So all that's needed is to declare 'v' as an argument to the method on the 'def' line, so that FS has somewhere to put the data...
- Code: Select all
def loadState v
# Get your values out of v
end
Aside from those little glitches it's looking very good - another useful addition to our new FS arsenal of goodies!
All schematics/modules I post are free for all to use - but a credit is always polite!
Don't stagnate, mutate to create!
Don't stagnate, mutate to create!
-
trogluddite - Posts: 1730
- Joined: Fri Oct 22, 2010 12:46 am
- Location: Yorkshire, UK
Re: Ruby for noobs!
thanks trog for your improvements!
w,h = getViewSize was doing the trick! thats smart, i tried it yesterday to get this variables into the mouseparts... thats ruby - i always wondering how easy it is at the end
...is the load and save state needful in this example to work correct with a presetmanager?
w,h = getViewSize was doing the trick! thats smart, i tried it yesterday to get this variables into the mouseparts... thats ruby - i always wondering how easy it is at the end
...is the load and save state needful in this example to work correct with a presetmanager?
-
Nubeat7 - Posts: 1347
- Joined: Sat Apr 14, 2012 9:59 am
- Location: Vienna
26 posts
• Page 1 of 3 • 1, 2, 3
Who is online
Users browsing this forum: No registered users and 34 guests