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

[SOLVED... kinda] openPeripherals: get key with terminal glasses

Started by speedyMACHO, 12 April 2014 - 05:28 AM
speedyMACHO #1
Posted 12 April 2014 - 07:28 AM
Hello, I'm playing tekkit (with openPeripherals) and trying to make a remotely controlled turtle with terminal glasses.
Basically what I'm trying to reach: terminal glasses registers key input and sends it to the computer, the computer broadcasts on rednet and the turtle reacts to it.
So I need a function like os.pullEvent("key") but one that works outside the computer.
Can anyone help?

thanks
speedyMACHO
Edited on 13 April 2014 - 06:05 AM
CometWolf #2
Posted 12 April 2014 - 10:19 AM
They can't do that. You can however use chat commands, prefixed by $$. eg

$$test
would fire an event on the computer the glasses are connected to with the following parameters
event = "chat_command"
p1 = "test"
p2 = "CometWolf"
These can then be used to do things on your computer.
Edited on 12 April 2014 - 12:50 PM
redstonedude0 #3
Posted 12 April 2014 - 02:35 PM
event = "chat_command" @CometWolf
CometWolf #4
Posted 12 April 2014 - 02:39 PM
Ah right, i was supposed to correct that. I haven't used the glasses in ages, so i just skimmed one of my old programs to find the event info, where i was also using the chat peripheral from miscP :P/>
theoriginalbit #5
Posted 12 April 2014 - 02:52 PM
uhhhh, no. I just checked with our latest code in OpenP and assuming I were to send the chat '$$hello' it would return the following
  • chat_command
  • hello
  • theoriginalbit
  • [guid]
  • [name]
where [guid] is a random string it seems, and [name] is either the side the Terminal Bridge is on, or its network name.
CometWolf #6
Posted 12 April 2014 - 02:55 PM
You should really put together some offical documentation for the glasses >.>
speedyMACHO #7
Posted 13 April 2014 - 08:04 AM
Ahh that's to bad. Something like $$forward $$dig $$digup $$digdown $$left $$dig wouldn't be really productive.
Thanks anyway, cometwolf.
redstonedude0 #8
Posted 13 April 2014 - 02:43 PM
you could either have an advanced monitor which allows for buttons to be pushed, have a pocket computer which can be interacted with mouse clicks, or use player sensors or pressure plates to detect player movement and send that information to the turtle

OR if you want to be really technical and work outside of CC you can get a keybinding program which sets values in a RSS feed on a domain you own, you can then ue the HTTP API to read the RSS feed and move the turtle accordingly :P/>
redstonedude0 #9
Posted 13 April 2014 - 02:54 PM
I have been playing around with it a bit and I tested it last night and it gave the results shown above but I tried it just now and it worked…weird i must have made an error somewhere and fixed it when re-tying some of the lines of code as i had messed around with them a bit. Well thanks anyway for the help, here is the working code for anyone who finds this thread of use in the future for OOP in lua:


local version = "V1.0"

local Render = {width = 640, height = 640, peripheral = nil, setPeripheral = function(self, name) self.peripheral = name end}

function help()
  print("OpenPeripheral Render API "..version.." by Redstonedude")
end

function setPeripheral2(self,name)
  self.peripheral = name
end

function getPeripheral(self)
  return self.peripheral
end

function newRender (p)
  if peripheral.getType(p) == "openperipheral_glassesbridge" then
    return setmetatable({},{__index=Render})
  else
    error("Peripheral is not an Openperipheral Glasses Bridge",2)
  end
end