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

Use the text editor of your choice

Started by Dunkhan, 29 August 2012 - 04:34 PM
Dunkhan #1
Posted 29 August 2012 - 06:34 PM
I use notepad++ for all my coding, and the default editor for computercraft is not great (don't get me wrong the mod is the best thing to happen to computer gaming in years). Regardless of why I use notepad++ (foss, light, fast, functional) each of us has a text editor of choice. So I wrote a short autohotkey script that copies everything from a text file to the console in game. It is very simple. You need to download autohotkey for it to work. The script is as follows:


filename = default
InputBox, filename, Enter Name of File
sleep 3000
Loop, read, C:Documents and SettingsMeApplication Data.techniclauncherProgramming%filename%.txt
{
	send %A_LoopReadLine% {enter}
}

You will need to change the path on line 4 to point to where you keep your scripts (save them as .txt files). Also on line 3 the number is the delay in milliseconds between clicking ok and it starting to type. The script sends keyboard input to minecraft so you just have to have the CC editor open and ready to accept your text ingame.

edit: forgot to mention you have to escape some characters. the only one I have encountered so far is + which has to be written {+}
Xtansia #2
Posted 30 August 2012 - 04:46 AM
You do realise if it's ssp you can edit the files directly with np++
Dunkhan #3
Posted 02 September 2012 - 11:30 PM
It is smp
kaj #4
Posted 21 September 2012 - 03:29 AM
This is win. Works a charm.
If only there was a way around the {+} thing.
Cranium #5
Posted 21 September 2012 - 05:09 PM
I don't really understand how this works, mostly because I am such a coding noob outside of Lua. Could someone post a step by step checklist on how to do this?
matejdro #6
Posted 25 September 2012 - 09:59 PM
I don't really know AutoHotKey, but by looking at code I think it will re-type file into CC console by simulating keyboard presses.

On our server, we did similar things using AutoIt and that is what we learned:
1. It's much faster to paste script line-by-line instead of typing it. And not that hard to implement, at least not in AutoIt.
2. If you can, go for HTTP. We set up FTP/HTTP server combo and made simple script that will transfer program to FTP and then download it on CC computer. It can transfer program of any length in few seconds. And very reliable.
Cranium #7
Posted 25 September 2012 - 10:08 PM
That's just the thing. Sometimes server owners set up a server, like in Tekkit, but don't even know that the HTTP API is disabled by default. Then they look at you with slack-jawed confusion when you try to explain how to change config files in something they just downloaded and slapped their name on it.
kaj #8
Posted 26 September 2012 - 11:16 PM
Hey I'm going to post back here and say I'm having a little trouble with AHK
(seems to jumble long programs - im looking into it)

@cranium: I.K.R. qq. It's massive hassle trying to get server owners to enable stuff server side.
I remember having nightmares with allowing turtles to dig etc.
If you can convince / explain to your op how/why you need the http on, I would fully recommend going with that over any third party software.
I think it's actually a lot quicker than auto-typers - as autos type it in char for char, while pastebin just imports the whole file.

If you get stuck with the ahk thing pm me or sumthing, but as I said its a little weird with long programs - and I'v not managed to find a workaround yet.

-kaj