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

AlkChat 1.2: First Program!

Started by AlktatStudios, 22 November 2013 - 05:44 PM
AlktatStudios #1
Posted 22 November 2013 - 06:44 PM
AlkChat 1.2

——————————————-

This is a Chatting Program.

Features:


Customizable Username

Terminate Exit

——————————————-

CODE LINKS:

pastebin get VYwzReif AlkChat


——————————————-

If You have any suggestions,

please comment them. Thanks!

——————————————

Change Log:


1.0: Official Release

1.1: Fixed the spelling of "Variables".

1.2: Added Feature to be able to chat again and again on the same program.
Edited on 25 November 2013 - 01:21 PM
awsmazinggenius #2
Posted 22 November 2013 - 10:37 PM
This is an awesome program. Just a quick note: there is a spelling mistake in the comment on line 28: variable is spelt wrong.
AlktatStudios #3
Posted 23 November 2013 - 08:38 AM
Okay, thanks.
apemanzilla #4
Posted 24 November 2013 - 12:17 PM
You should edit the topic title to say 1.1 (Use the full editor)
AlktatStudios #5
Posted 25 November 2013 - 12:37 PM
You should edit the topic title to say 1.1 (Use the full editor)
I don't think I cam

EDIT: I did
Edited on 25 November 2013 - 12:16 PM
Anavrins #6
Posted 27 November 2013 - 02:08 AM
A few things;
Why the "sleep(3)" at line 21?

Why are you calling "shell.run("shell")" to get back to the shell?
Just let the program go to the end and it will automatically go back to the shell.
You'll end up with recursion and is generally a bad thing.
To fix it, you can read up the "vm error: java.lang.ArrayIndexOutOfBoundsException" part of that thread: http://www.computerc...rror-slaying-2/

Line 102, it should be "shell.run(shell.getRunningProgram())", not everybody decides to put your program in "/Files/AlkChat"
Also at line 102, don't ever run a program from within that same program, you'll end up with recursion just like above.

And lastly, please indent your code, it'll make it more readable and will help you a lot.
Edited on 27 November 2013 - 10:05 AM
nateracecar5 #7
Posted 27 November 2013 - 08:49 AM
Add the ability to check where the modem is. The back is an okay side, but all sides would be better. ;)/>
RabbidMeow120 #8
Posted 27 November 2013 - 11:00 AM
To check for a modem, add this:


local present = false
for _, side in pairs(rs.getSides()) do
  if peripheral.getType(side) == "modem" then
    present = true
    rednet.open(side)
  end
end
if not present then
  print("AlkChat requires a wireless modem to work.")
  os.sleep(1)
  os.reboot()
end


It works! It errors with "AlkChat requires a wireless modem to work" if it can't find a modem.
awsmazinggenius #9
Posted 29 November 2013 - 08:19 PM
To check for a modem, add this:


for _, side in pairs(rs.getSides()) do
  if peripheral.getType(side) == "modem" and peripheral.call(side, "isWireless") --[[/* Apparently you want a wireless modem, so check if it is wireless*/]]-- then
	rednet.open(side)
	present = true
  end
end
if not present then --# Lua treats nil as false
  error("AlkChat requires a wireless modem to work.", 0) --# Using error() terminates your program with a custom message. No reboot required.
end

It works! It errors with "AlkChat requires a wireless modem to work" if it can't find a modem.

Slightly improved your code. I hope you've learned something new and useful to you!
Edited on 29 November 2013 - 07:22 PM
mrpoopy345 #10
Posted 30 November 2013 - 04:39 PM
This is a cool program, especially for a beginning coder.