pastebin get VYwzReif AlkChat
This is a read-only snapshot of the ComputerCraft forums,
taken in April 2020.
AlkChat 1.2: First Program!
Started by AlktatStudios, 22 November 2013 - 05:44 PMPosted 22 November 2013 - 06:44 PM
AlkChat 1.2
——————————————-
This is a Chatting Program.
Features:
Customizable Username
Terminate Exit
——————————————-
CODE LINKS:
——————————————-
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
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.
Posted 23 November 2013 - 08:38 AM
Okay, thanks.
Posted 24 November 2013 - 12:17 PM
You should edit the topic title to say 1.1 (Use the full editor)
Posted 25 November 2013 - 12:37 PM
I don't think I camYou should edit the topic title to say 1.1 (Use the full editor)
EDIT: I did
Edited on 25 November 2013 - 12:16 PM
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.
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
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. ;)/>
Posted 27 November 2013 - 11:00 AM
To check for a modem, add this:
It works! It errors with "AlkChat requires a wireless modem to work" if it can't find a modem.
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.
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
Posted 30 November 2013 - 04:39 PM
This is a cool program, especially for a beginning coder.