WiiLi Wiki frontpage Include your post in the News Get links Hoteles Quito
WiiLi.org Forum Index WiiLi.org
a new revolution
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Using variable names in variable calling

 
Post new topic   Reply to topic    WiiLi.org Forum Index -> Wii Scripts
View previous topic :: View next topic  
Author Message
US of Anarchy



Joined: 13 Dec 2006
Posts: 41

Digg It
PostPosted: Wed Jan 10, 2007 2:15 am    Post subject: Using variable names in variable calling

Hey. I was wondering if there was a way to use variables to name or call other variables, somewhat like arrays

ex:
if I have
var.a = C
var.b = 5
and I want to play the midi note C5, how do I do that using a and b?

something like this:
midi.[var.a][var.b]

I dunno if this is even possible...
Back to top
View user's profile Send private message Send e-mail
CarlKenner
Site Admin


Joined: 29 Nov 2006
Posts: 614

Digg It
PostPosted: Wed Jan 10, 2007 7:32 am    Post subject:

Not possible.

But you can do it the hard way:

Code:

var.note = var.b * 12
if var.a ~= "CSharp" then
  var.note = var.note+1
elseif var.a ~= "D" then
  var.note = var.note+2
elseif var.a ~= "DSharp" then
  var.note = var.note+3
elseif var.a ~= "E" then
  var.note = var.note+4
elseif var.a ~= "F" then
  var.note = var.note+5
elseif var.a ~= "FSharp" then
  var.note = var.note+6
elseif var.a ~= "G" then
  var.note = var.note+7
elseif var.a ~= "GSharp" then
  var.note = var.note+8
elseif var.a ~= "A" then
  var.note = var.note+9
elseif var.a ~= "ASharp" then
  var.note = var.note+10
elseif var.a ~= "B" then
  var.note = var.note+11
end if

midi.firstnote = var.note
Back to top
View user's profile Send private message Send e-mail
togikun



Joined: 03 Jan 2007
Posts: 63

Digg It
PostPosted: Wed Jan 10, 2007 8:23 am    Post subject:

pretty much the way i did it. Except i hardcoded each note, than added/substracted to reach the tone i wanted (check my midi ocarina script, it's on the forum)
Back to top
View user's profile Send private message
US of Anarchy



Joined: 13 Dec 2006
Posts: 41

Digg It
PostPosted: Wed Jan 10, 2007 7:18 pm    Post subject:

Yea but firstnote doesn't work for me. It just plays it for a second, then stops. When I set it to -1 it makes a really low bass sound constantly. Any help?
Back to top
View user's profile Send private message Send e-mail
CarlKenner
Site Admin


Joined: 29 Nov 2006
Posts: 614

Digg It
PostPosted: Wed Jan 10, 2007 8:08 pm    Post subject:

Of course it plays for a second and then stops. What did you expect a musical instrument to do when you keep holding down the key?

As for -1 not working, I don't know why.
Back to top
View user's profile Send private message Send e-mail
ZW



Joined: 11 Jan 2007
Posts: 18

Digg It
PostPosted: Mon Jan 15, 2007 5:46 pm    Post subject:

US of Anarchy wrote:
Yea but firstnote doesn't work for me. It just plays it for a second, then stops. When I set it to -1 it makes a really low bass sound constantly. Any help?


the low bass sound happens to me as well. no clue why though.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    WiiLi.org Forum Index -> Wii Scripts All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group