Posted 05 January 2015 - 02:28 PM
Hi guys,
This is my first post here and I just wanted to say thanks because you've helped out a ton in the past even if you aren't aware of it :)/>
So, my question: I just wanted to check if there was an equivalent function in Lua of searching a table for a value and returning the index number of it?
Sorry if that seems a very newbie question and has been asked before - I'm fairly new to Lua as a language and I couldn't see anything for it in the wiki, most of the functions seemed to be based upon the idea of a loop going through the index keys.
To put it in context - I'm making a music program for Tekkit currently I have a planned set up of (as a rough example):
And essentially what I'd like to be able to do is have a table that has all of the notes and their associated rednet cable numbers stored in a table so I could do something like:
Sorry if that was a bit convoluted, thank you for any help you can give guys :)/>
This is my first post here and I just wanted to say thanks because you've helped out a ton in the past even if you aren't aware of it :)/>
So, my question: I just wanted to check if there was an equivalent function in Lua of searching a table for a value and returning the index number of it?
Sorry if that seems a very newbie question and has been asked before - I'm fairly new to Lua as a language and I couldn't see anything for it in the wiki, most of the functions seemed to be based upon the idea of a loop going through the index keys.
To put it in context - I'm making a music program for Tekkit currently I have a planned set up of (as a rough example):
table note ={"C","C","D","D","E","E","F","F","G#","F"}
table note_2 = {"A#",0,0,0,0,0,"A#2",0,0,0,0}
table note_3= {"A#2,0,0,0,0,0,0,0,0,0,0}
local Bundled_Left = 0
local Bundled_Back = 0
for i=1, #note do
redstone.setBundledOutput("left",0)
Bundled_Left = 0
os.sleep(0.1)
if note[i] == "F#" then
Bundled_Left = Bundled_Left + 1
elseif note[i] == "G" then
Bundled_Left = Bundled_Left + 2
elseif note[i] == "G#" then
Bundled_Left = Bundled_Left + 4
end
if i <= #note_2 then
if note_2[i] == "F#" then
yada yada
end
end
end
And essentially what I'd like to be able to do is have a table that has all of the notes and their associated rednet cable numbers stored in a table so I could do something like:
local Bundled_Left_Note_Values = {"F#",1,"G",2,"G#",4,"A",8,etc,etc}
local Bundled_Left = 0
for i=1, #note do
Bundled_Left = Bundled_Left + Bundled_Left_Note_Values[TableValueFindingFunctionName(Bundled_Left_Note_Values , Note[i]) + 1]
end
Sorry if that was a bit convoluted, thank you for any help you can give guys :)/>