Posted 30 January 2013 - 11:09 PM
Title: How can i shorten this and Multiple color cables turned on?
I am making my little learning program where i am trying to have the user input what color of wire should be turned on.
As of yet it is long and i don't know of any way to shorten it:
Also how would i go about having the player input able to take multiple.
Right now you would write:
But what if i wanted to turn on the white cable AND the orange cable?
Sure i could add more arguments but then i would need to make more if statements and it would all be a mess.
What could i do in my 2 problems here?
I am making my little learning program where i am trying to have the user input what color of wire should be turned on.
As of yet it is long and i don't know of any way to shorten it:
local tArgs = {...}
input = tArgs[1]
color = nil
if input == "white" then
color = tonumber(1)
elseif input == "orange" then
color = tonumber(2)
etc...
rs.setBundledOutput("back", color)
sleep(2)
rs.setBundledOutput("back", 0)
Also how would i go about having the player input able to take multiple.
Right now you would write:
test white
to turn on the white cable.But what if i wanted to turn on the white cable AND the orange cable?
Sure i could add more arguments but then i would need to make more if statements and it would all be a mess.
What could i do in my 2 problems here?