Posted 24 May 2012 - 01:08 AM
[Computercraft] [1.33] [lua] [question] "Usages"
Excuse me if im asking too many things but im fairly new to programming.
In certain programs there will be Usages messages
For EX:
if you type "move"
it will say
Usages: "move <target> <destination>"
I was wondering the coding for this
i have a small factory with another mod and i need coolant for it
whenever u type coolant, i had it said "Turn on or off?"
but thats just annoying.
i got it to the point where if u typed coolant off (for example) it would say "usages <on or off>,
but i would need to type coolant off AGAIN for it to actually work.
im wondering how to get it to work if i JUST have to type "coolant on" or "coolant off" once and have it work
Without having to make multiple programs for it.
so i want the result to be
If they type "coolant" it would say "Usages: coolant <on or off>"
if they type "coolant on" (WITHOUT TYPING "coolant" FIRST) it would turn a redstone signal on
if they type "coolant off" WITHOUT TYPING "coolant" FIRST) it would turn off a redstone signal
————————————————————————————————————————
I KNOW it is NOT correct, (probably not even close)
but this is what i have currently:
————————————————————————————————————————
print "Usage:"
print "coolant <ON or OFF>"
input = read()
if "coolant on" == input then
print "Coolant turned on!"
redstone.setOutput("back",true)
elseif "coolant off" == input then
print "Coolant turned off!"
redstone.setOutput("back",false)
else
print "Try again!"
end
————————————————————————————————————————-
Thanks for the help, these forums have active admins and i appreciate that.
Thanks,
Rapidfire52
Excuse me if im asking too many things but im fairly new to programming.
In certain programs there will be Usages messages
For EX:
if you type "move"
it will say
Usages: "move <target> <destination>"
I was wondering the coding for this
i have a small factory with another mod and i need coolant for it
whenever u type coolant, i had it said "Turn on or off?"
but thats just annoying.
i got it to the point where if u typed coolant off (for example) it would say "usages <on or off>,
but i would need to type coolant off AGAIN for it to actually work.
im wondering how to get it to work if i JUST have to type "coolant on" or "coolant off" once and have it work
Without having to make multiple programs for it.
so i want the result to be
If they type "coolant" it would say "Usages: coolant <on or off>"
if they type "coolant on" (WITHOUT TYPING "coolant" FIRST) it would turn a redstone signal on
if they type "coolant off" WITHOUT TYPING "coolant" FIRST) it would turn off a redstone signal
————————————————————————————————————————
I KNOW it is NOT correct, (probably not even close)
but this is what i have currently:
————————————————————————————————————————
print "Usage:"
print "coolant <ON or OFF>"
input = read()
if "coolant on" == input then
print "Coolant turned on!"
redstone.setOutput("back",true)
elseif "coolant off" == input then
print "Coolant turned off!"
redstone.setOutput("back",false)
else
print "Try again!"
end
————————————————————————————————————————-
Thanks for the help, these forums have active admins and i appreciate that.
Thanks,
Rapidfire52