Jump to content




Computronics Chat Box Door Opener


6 replies to this topic

#1 WolfyXK

  • Members
  • 10 posts

Posted 23 December 2015 - 02:20 AM

Just a little program to open a door when you say a selected message in chat, thanks again. - WolfyXK
also this is my first program I have posted on the forums so any advice/improvements would be much appreciated :)

Just place the chatbox anywhere touching the computer

Quote

pastebin get nsqR30yt startup

-- Change this code
local yourname = "WolfyXK"
local openmessage = "open" -- Make this lowercase
local doorside = "right"
local opentime = 4
-- 

while true do

local chat = { os.pullEvent("chat_message") }

if chat[3] == yourname and string.lower(chat[4]) == openmessage then
print("Door Opening")
rs.setOutput(doorside, true)
sleep(opentime)
term.clear()
rs.setOutput(doorside, false)
else
end
end

Posted Image


Posted Image

Edited by WolfyXK, 24 December 2015 - 03:57 AM.


#2 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 23 December 2015 - 05:22 AM

View Postwolfyxk, on 23 December 2015 - 02:20 AM, said:

I wasn't sure how to get the code to restart other than to reboot so any advice would be much appreciated, thanks.

The idea is to wrap the relevant bit of code within a loop structure, for eg:

while true do  -- Loop repeats while condition is true; "true" is always true, so this one goes indefinitely.
  -- Code to repeat here.
end

I recommend a read of this guide.

#3 WolfyXK

  • Members
  • 10 posts

Posted 23 December 2015 - 11:26 AM

That should have been really obvious to me, I was just having some trouble with the event in the earlier stages and had to take the loop out, honestly don't know how I missed that :'D Thanks.

#4 Selim

  • Members
  • 189 posts
  • LocationHiding in Online Storage

Posted 23 December 2015 - 04:13 PM

There is plenty of information out there on Computronics, both a wiki and the source code.
Wiki: http://wiki.vex.tty....ki:computronics
Source: https://github.com/a...ka/Computronics

#5 WolfyXK

  • Members
  • 10 posts

Posted 23 December 2015 - 04:45 PM

Its just for anyone who is new to Lua and wants to use the chat box, as the wiki doesn't tell you exactly how to use the code.

#6 Selim

  • Members
  • 189 posts
  • LocationHiding in Online Storage

Posted 23 December 2015 - 09:00 PM

It isn't a huge deal, but it does:

Computronics Wiki said:


  • say(message) - says a message within the chatbox distance.


  • (0.3.0+) getDistance() - gets the current listening/speaking distance.


  • (0.3.0+) setDistance() - sets the current listening/speaking distance. The maximum is defined in the config.

  • An event is sent every time the Chat Box receives a message. The name of the event is “chat_message”, the first parameter is the username and the second parameter is the message.



#7 LDDestroier

  • Members
  • 1,095 posts
  • LocationACDC Town

Posted 04 January 2016 - 02:07 AM

local openmessage = "mellon"

I hope you get the reference

Edited by LDDestroier, 04 January 2016 - 02:08 AM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users