Posted 24 November 2012 - 01:14 PM
Hello
I have been working on an elevator program with some good success so far. Ive run into a small stumbling block. I dont quite fulling understand the string.match() and string.find() functions, and am unaware if I can add wildcards in strings. Heres some examples of what Im trying to do:
I want to send a signal from one comeputer (on the elevatot) to the main computer (Operating motors and such). The signal would simply say floor 1 or floor 2 etc. The receiving computer takes the statement and matches the string floor for a matching statement. Heres a small exert, but not actual code.
while true do
id, message = rednet.receive()
operation, ammount = message (need to break up the message. The first string is the operation, the number is the ammount)
if operation == "floor" then
elevatorMove(ammount)
end
end
so I have the logical parts taken care of, Im just trying to figure out how, or even if it is possible to break up a string. Also, if there is an easier way, such as putting some sort of separator in such as a | or other that could work as well.
Please advise, and thanks in advance.
Raev82
I have been working on an elevator program with some good success so far. Ive run into a small stumbling block. I dont quite fulling understand the string.match() and string.find() functions, and am unaware if I can add wildcards in strings. Heres some examples of what Im trying to do:
I want to send a signal from one comeputer (on the elevatot) to the main computer (Operating motors and such). The signal would simply say floor 1 or floor 2 etc. The receiving computer takes the statement and matches the string floor for a matching statement. Heres a small exert, but not actual code.
while true do
id, message = rednet.receive()
operation, ammount = message (need to break up the message. The first string is the operation, the number is the ammount)
if operation == "floor" then
elevatorMove(ammount)
end
end
so I have the logical parts taken care of, Im just trying to figure out how, or even if it is possible to break up a string. Also, if there is an easier way, such as putting some sort of separator in such as a | or other that could work as well.
Please advise, and thanks in advance.
Raev82