This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
tomtomtaco's profile picture

turtle butler coding

Started by tomtomtaco, 12 August 2015 - 12:18 PM
tomtomtaco #1
Posted 12 August 2015 - 02:18 PM
ok so I want to make a code for a turtle to basically be a butler, as in I say in chat "turtle get me {item id}" and the turtle would go to the me system and then bring me the item, I know this is silly considering there is an me controller, but I would still want it, is that possible? I don't know java yet, I'm learning it this year though.
ShadowDisruptor #2
Posted 12 August 2015 - 05:29 PM
Well, for one thing, ComputerCraft scripts are coded in Lua. Also, by default, there is no way to get player's chat messages; however, there are some mods that make this possible.
Edited on 12 August 2015 - 03:30 PM
SquidDev #3
Posted 12 August 2015 - 08:06 PM
Your best mod for your above features is probably Peripherals++ (though MoarPeripherals also provides a chat box). You probably want to look at the chat box. This fires a chat event, which you can listen for:


local _, player, message = os.pullEvent("chat")
if player:sub(1, 5) == "turtle" then
  -- Perform some action
end

What is also pretty cool is the player interface. This allows you to directly interface with a player's inventory:

peripheral.call("back", "setInputSide", "north")
local inv = peripheral.call("back", "getPlayerInv", "<username>")
inv.push(1, 64) -- Push 64 items to the player from slot 1 in the chest to the north of the peripheral interface.
Though, you could also use a turtle.

If you don't want another mod, then you could look into using a pocket computer, rednet and GPS - so you'd type your request into a computer and send a message to the turtle. The turtle knows your (and its location) based off the GPS coordinates.
Edited on 12 August 2015 - 06:07 PM