Well, here's a few tips.
All APIs are stored as tables, so you can use the table calls to make some things happen. For your second example, I'm pretty sure you can use:
x,y,z = rednet.receive(timeout)
turtle[y]
And, if that does not work, you can always create a table that does work that way.
tablet = {
["forward"] = {
aliases = {"fd", "forward"}, -- How you want to be able to call this action. If there are two of the same alias, the one listed first will get used.
func = turtle.forward -- This is what the action is supposed to be, here, I've made it use turtle.forward() everytime this action is called.
},
["back"] = {
aliases = {"bk", "back"},
func = turtle.back
},
["180"] = {
aliases = {"2", "turn 2", "rt 2", "lt 2"},
func = function(way) -- Yes, you can make a function inside a table! Awesome, isn't it?
if sting.sub(way, 1,2) == "rt" then
turtle.turnRight()
turtle.turnRight()
elseif string.sub(way, 1,2) == "lt" then
turtle.turnLeft()
turtle.turnLeft()
else
turtle.turnRight()
turtle.turnRight()
end
}
}
Then you can call that, like so.
x, y, z = rednet.receive()
done = false
for k,v in pairs(tablet) do -- Pulls however many commands you've made.
for 1, #k.aliases do -- This will check the aliases for the command sent.
if y == k.aliases[i] then
k.func() -- This calls the action itself, and makes the turtle (or computer) do whatever you told it to remember how to do.
done = true -- See next line
break -- This just closes the loop so multiple actions don't happen.
end
end
if done then -- Closes outer loop.
break
end
end
if not done then -- If the command was not in the alias list
print("Command not recognized")
rednet.send(x, "noact") -- So the computer you sent from knows its wrong.
end
And, I'll put the explanations up in a moment.
EDIT: Alright, explanations in comments. Reply with further questions, if you have them, or if I have neglected to explain something you don't know.