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
Trigger Switch in Ruby?
Trigger Switch in Ruby?
Code: Select all
def event i,v
if == 'knob' & @bool = 1
output 0, @knob
end
end
Re: Trigger Switch in Ruby?
Code: Select all
def event i,v
if i == "knob"
output 0, v if @switch
end
endRe: Trigger Switch in Ruby?
Re: Trigger Switch in Ruby?
Code: Select all
def event i,v
if i == "knob" || "switch"
output 0, @knob if @switch
end
endRe: Trigger Switch in Ruby?
Code: Select all
def event i,v
if i == "knob"
@a = some very big and complicated formula
output 0, @a if @switch
end
endRe: Trigger Switch in Ruby?
Code: Select all
def event i,v
if i == "knob"
if @switch
# this block of code is executed only if switch is true
@a = some very big and complicated formula
output 0, @a
end
end
endRe: Trigger Switch in Ruby?
I would reverse it, since there is no need to even check for 'knob' if switch is false:Tronic wrote:add all your code, in the "if" check blockCode: Select all
def event i,v if i == "knob" if @switch # this block of code is executed only if switch is true @a = some very big and complicated formula output 0, @a end end end
Code: Select all
def event i,v
if @switch
if i == "knob"
# this block of code is executed only if switch is true
@a = some very big and complicated formula
output 0, @a
end
end
endCode: Select all
def event i,v
if not @switch then return end
if i == "knob"
# this block of code is executed only if switch is true
@a = some very big and complicated formula
output 0, @a
end
endRe: Trigger Switch in Ruby?
yeah, but this not update the output value when the switch is true and the knob is not moved,tulamide wrote: I would reverse it, since there is no need to even check for 'knob' if switch is false:Code: Select all
def event i,v if @switch if i == "knob" # this block of code is executed only if switch is true @a = some very big and complicated formula output 0, @a end end end
but it has been moved previously.
But of course, it depends on your use.
Code: Select all
def event i,v
if i == "knob" || "switch"
if @switch
# this block of code is executed when the switch is true
# or the switch is true and knob moved
@a = some very big and complicated formula
output 0, @a
end
end
endRe: Trigger Switch in Ruby?
And that is the same behaviour as of the trigger switch, and it was asked for that behaviour. But sure, if you need a trigger on true, even if the knob doesn't change, then my proposal won't work.Tronic wrote:yeah, but this not update the output value when the switch is true and the knob is not moved,
but it has been moved previously.