View Full Version : working with variable
chriss
September 18th, 2009, 01:11 AM
hi i am a newbie tor girder. trying to find out how to work with variables. i want to recieve control change midi data and send the recieved value to mouse move x. anybody who could give some help?? if not with midi...maybe with something else...just to find out how to put revieved values in a variable and send it to someting else :-)
greetz and thanks
chriss
Rob H
September 18th, 2009, 11:31 AM
When you receive an event it you will get parameters in the variables pld1, pld2, pld3 and pld4. Usually the one you're interested in will be in pld1.
Create a scripting action something like
myVariable = pld1
and drag the event from the logger to that action.
For a mouse move you can probably just do this directly e.g. if pld1 contains the x value and pld2 the y value then create the mouse move action and use [pld1] and [pld2] for the X & Y parameters - note the square brackets here.
chriss
September 19th, 2009, 10:02 AM
hi rob
first thx for reply but:
1st i am realy new to girder
2nd: if i learn the midi event it is an absolut value but i want to have a part of the event as a variable how can i do that?? and do i have always to put values (if they are variables) in the data fields (for eg in the mouse abs fields)?
greetz
chriss
Rob H
September 19th, 2009, 10:14 AM
I'm not really familiar with the MIDI plugin so not sure what it does with events.
Can you show me some examples of the events that it generates?
If necessary we can use a bit of Lua scripting, but it's best to try to avoid that until we have to.
chriss
September 19th, 2009, 11:00 AM
uuhhh...thats quick :-)
firts: here the link with infos about the plugin:
http://promixis.com/forums/showthread.php?t=19650&highlight=midi
and here a copy of the logging:
Time Date Source Details Payloads
16:58:14:181 9/19/2009 MIDI Plugin (0) 176:0:1:127
the 127 at the and is the variable part....and if have to start start with lua...i would try also because at the end i have to multiply to values to get the final values :-)
thx and greetz
chriss
Rob H
September 19th, 2009, 06:47 PM
Okay, that's not too bad.
You'll need to create a scripting action
local _, _, value = string.find(pld1, ":(%d*)$")
if value then
gir.TriggerEvent("MIDIMouseMove", 18, value)
end
And drag the MIDI event from the logger to that action.
That will give you a modified event that you can use to trigger your mouse move action.
Let me know if you have a problem.
chriss
September 20th, 2009, 08:33 AM
hope i have done everything right but lua send an error:
[string "test.gml:\New\Scripting"]:1: bad argument #1 to `find' (string expected, got nil)
stack traceback:
[C]: in function `find'
[string "test.gml:\New\Scripting"]:1: in main chunk
any idear?? and if i send anything else then 127 at the end there is no script action.
big thx in advance :-)
chriss
Rob H
September 20th, 2009, 08:55 AM
Ah, is the "176:0:1:127" the event string? Rather than a payload?
In that case change the pld1 in that script to EventString
chriss
September 20th, 2009, 05:07 PM
mmmmhhhh
Time Date Source Details Payloads
23:59:02:680 9/20/2009 Girder MIDIMouseMove 127
23:59:02:681 9/20/2009 Scripting Lua Success (Nothing Triggered)test.gml:\New\Scripting
23:59:02:675 9/20/2009 MIDI Plugin (0) 176:0:1:127
23:58:53:075 9/20/2009 MIDI Plugin (0) 176:0:1:1
as you see, if i send something else then 127 at the end nothing happens. if i send 127 at the end the script is triggered but the mouse doesnt move?! is the MIDIMouseMove some action what i have to create first??
greetz
chriss
Rob H
September 21st, 2009, 05:45 AM
Hmm... that pattern should work for any string that ends in a colon followed by any number of digits.
And yes, you'll need to use the MIDIMouseMove event to trigger your mouse move action
chriss
September 21st, 2009, 01:19 PM
hi rob
MIDIMouseMove is now working but the script works still only if i send the 127 at the end.... any idear?? problem is....i dont understand the :(%d*)$") in the script :-) and some aditional info for you: it shoul only work if 176:0:1: is part of the string!!
thx and greetz
chriss
chriss
September 21st, 2009, 01:26 PM
me again
i think it is not a problem of the script....i think it is the trigger. the script is only triggered if i send exactly this string because i dragged exatly this event from the logging on the action. is it possible to change the event with any wild cards at the end??
greetz
chriss
chriss
September 21st, 2009, 02:37 PM
hi rob
if i invert the event propertys it triggers alway exept of the 127 :-) but do you maybe have a solution that it triggers always if the string starts with
176:0:1:
thx and greetz
chriss
chriss
September 21st, 2009, 02:47 PM
ok i got it....was easy :-) just put the 176:0:1 in front of the kryptik part in your script :-)
but now the next question:
i get values on 176:0:1 and 176:0:2 how can i multiply these two values before i send them to the mouse action??
thx and greetz
chriss
Rob H
September 21st, 2009, 03:00 PM
So do you want it to trigger for any MIDI event or only a subset?
This can be done using Lua. What's the lowest common denominator of MIDI event you want to trigger on?
chriss
September 21st, 2009, 03:13 PM
seems that i have problems to declare global variable. i did one action with the script:
value1 = string.find(EventString, "176:0:1:(%d*)$")
and one with:
value2 = string.find(EventString, "176:0:2:(%d*)$")
if value2 then
posX=value1+value2
gir.TriggerEvent("MIDIMouseMove", 18, posX)
end
but i get an error:
[string "test.gml:\New\Scripting"]:3: attempt to perform arithmetic on global `value1' (a nil value)
stack traceback:
[string "test.gml:\New\Scripting"]:3: in main chunk
any idear??
thx chriss
chriss
September 21st, 2009, 03:39 PM
ok i think i got it :-) dont know whats realy going on, but it works :-) here the scipt:
_, _, value = string.find(EventString, "176:0:1:(%d*)$")
if value then
value1=value
end
_, _, value2 = string.find(EventString, "176:0:2:(%d*)$")
if value2 then
posX = value1+value2
gir.TriggerEvent("MIDIMouseMove", 18, posX)
end
thx
chriss
chriss
September 22nd, 2009, 09:45 AM
hi rob
now i tried to move y also and i thought in the action:
gir.TriggerEvent("MIDIMouseMove", 18, value)
18 stand for y but if i change 18 to anything else it doesnt work?!
thx and greetz
chriss
chriss
September 22nd, 2009, 10:08 AM
ok....just again to stupid :-)
thx
chriss
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.