Jump to content




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


  • You cannot reply to this topic
8 replies to this topic

#1 speedyMACHO

  • Members
  • 3 posts

Posted 12 April 2014 - 06: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 by speedyMACHO, 13 April 2014 - 07:05 AM.


#2 CometWolf

  • Members
  • 1,283 posts

Posted 12 April 2014 - 09: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

Quote

event = "chat_command"
p1 = "test"
p2 = "CometWolf"
These can then be used to do things on your computer.

Edited by CometWolf, 12 April 2014 - 01:50 PM.


#3 redstonedude0

  • Members
  • 11 posts

Posted 12 April 2014 - 01:35 PM

event = "chat_command" @CometWolf

#4 CometWolf

  • Members
  • 1,283 posts

Posted 12 April 2014 - 01: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

#5 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 12 April 2014 - 01: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.

#6 CometWolf

  • Members
  • 1,283 posts

Posted 12 April 2014 - 01:55 PM

You should really put together some offical documentation for the glasses >.>

#7 speedyMACHO

  • Members
  • 3 posts

Posted 13 April 2014 - 07:04 AM

Ahh that's to bad. Something like $$forward $$dig $$digup $$digdown $$left $$dig wouldn't be really productive.
Thanks anyway, cometwolf.

#8 redstonedude0

  • Members
  • 11 posts

Posted 13 April 2014 - 01: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

#9 redstonedude0

  • Members
  • 11 posts

Posted 13 April 2014 - 01: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






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users