[SOLVED] Ruby component problem
Posted: Mon Oct 07, 2013 7:04 pm
Hello.
I have problem with a Ruby component.
My problem in 1 screenshot:

and there is info from manual:

so why error?
Also.
input compare with name not work.


"if (i=0)" - work,
"if (i=="freq")" not working.
this is a working code, because in FL Studio version it works good. But in standalone it throw errors. But I read manual for standalone version and it have section for clearEvents...
whole code
I have problem with a Ruby component.
My problem in 1 screenshot:

and there is info from manual:

so why error?
Also.
input compare with name not work.


"if (i=0)" - work,
"if (i=="freq")" not working.
this is a working code, because in FL Studio version it works good. But in standalone it throw errors. But I read manual for standalone version and it have section for clearEvents...
whole code
Code: Select all
#--------------------------------------------------------------
#--------------------------------------------------------------
def init
@ntick = 0
@counter = 0
@main_freq = 0
@ticking = false
@min_delay = 0.2
#input "state", true, time+1
end
#--------------------------------------------------------------
def freq_setup
if @freq <= 0
@main_freq = 0
else
_mfreq = @period.to_f / @freq.to_f
if _mfreq < 0.1 then
_mfreq = 0.1
end
@main_freq = _mfreq
end
end
#--------------------------------------------------------------
def event i,v,t
if (i=="freq" || i=="period" || i=="state")
watch "f", "lol"
clearEvents
freq_setup()
watch "mfreq", @main_freq
if @state && @main_freq > 0
@ticking = true
input 100,nil,(t+@main_freq)
else
@ticking = false
end
end
case i
when 100 #main_timer
if @state
watch "main_timer", t
input 100,nil,t+@main_freq
rnd = @min_delay + rand((@main_freq.to_f-@min_delay)*100.0)/100.0
watch "rnd", rnd
input 101,nil,(t+rnd)
else
@ticking = false
end
when 101 #event
output "out"
output "led", true
input 102,nil,t+0.1
@counter = @counter + 1
output "counter", @counter
when 102 #led off
output "led", false
end
end