take this example (all i can think of right now):
multiple if syntax question
post#2: dasfaker suggests declaring local variables as:
local p1 = nil
local p2 = nil
local p3 = nil
local p4 = nil
local sum = nil
if panel:getModulatorByName("P1"):getValue() == 0 then p1 = 0 else p1 = 1 end
if panel:getModulatorByName("P2"):getValue() == 0 then p2 = 0 else p2 = 1 end
if panel:getModulatorByName("P3"):getValue() == 0 then p3 = 0 else p3 = 1 end
if panel:getModulatorByName("P4"):getValue() == 0 then p4 = 0 else p4 = 1 end
sum = (p1*1) + (p2*2) + (p3*4) + (p3*8)
panel:sendMidiMessageNow(etc)
so i tried different versions: this way, and having
variables as global (“P1″/”P2″/”P3″/”P4”) without assigning nil.
is it maybe because they are local and their value isn’t mentioned
elsewhere, -and the fact that it doesn’t do ie:
p1=panel:getModulatorByName("P1")
so the local ‘p1’ isn’t yet associated with the modulator ‘P1’
what i ended up doing was:
local p1 = panel:getModulatorByName("Partial1_OnOff_Pt1"):getModulatorValue()
so i suppose i didn’t need to create a value by assigning nil there.
as for ~=nil
: so i can interpret that as ‘if (blabla) has a value’ ?
is that a bit of a dummy condition, just so you can put ‘then’
after it?