RedPower computers are pretty unforgiving. If you make a mistake in Forth, it remembers that mistake and keeps punishing you for it. If you define a series of words and there's a bug in one of them, then you have to delete all the words since that word and re-enter them. There are tools to read Forth programs from text files, but I've solved the problem in my own particular way.
I use a Windows tool called AutoIt, which is quite wonderful. It automates Windows programs. It can click the mouse, stuff into the keyboard buffer, and read pixels on the screen.
All I use it for in this context is stuffing the keyboard. I have a script that reads a file, and every time you press a specific key (I use the backtick ` key) it stuffs a single line from the file into the Minecraft keyboard buffer at 10 characters per second. This delay is programmable in case your RedPower computers are more or less responsive than mine.
So, you create your code in a file, edit the AutoIt script to contain the file name, and run the AutoIt script. It should automatically move focus to the Minecraft window as long as the script has the right window name, I've hard coded it to "Direwolf20" as it only needs a substring of the window title. Once you're in the game and at the MineOS > prompt, just keep hitting ` every time MineOS has processed a line. Compiling a complex line of commands can take a few seconds, so wait for it, as MineOS only has a small typeahead buffer.
When it has pasted the last line, the script exits. You can exit it early via the tray icon.
Here's my script.
There are three hard coded strings that you might want to change - the activation key, the file name, and the window title. If you can't find them, then what are you doing trying to write Forth programs?
Beware that some of the AutoIt forum folks are utterly against all forms of game automation, so if you go to their site to discuss this, then prepare for some hostility. Other than that caveat, the forum is fantastic and really helpful.
Here's an example file that defines a few simple words. Actually it's my entire project so far! It waits for one of three signals coming in on an IO Expander and displays which signal it received and then exits. Pretty soon I'll hook it up to another Sortron and get it to actually process the contents of an Enderchest in the appropriate way. I've already got the IO Expander hooked up to a line of Wireless Receivers, so I can send commands with my Wireless Remote.
*EDIT* Fixed a bug where a ! character would not be sent, had to split the Send() call into two calls, one for a literal string and one for the {ENTER} special command.
I use a Windows tool called AutoIt, which is quite wonderful. It automates Windows programs. It can click the mouse, stuff into the keyboard buffer, and read pixels on the screen.
All I use it for in this context is stuffing the keyboard. I have a script that reads a file, and every time you press a specific key (I use the backtick ` key) it stuffs a single line from the file into the Minecraft keyboard buffer at 10 characters per second. This delay is programmable in case your RedPower computers are more or less responsive than mine.
So, you create your code in a file, edit the AutoIt script to contain the file name, and run the AutoIt script. It should automatically move focus to the Minecraft window as long as the script has the right window name, I've hard coded it to "Direwolf20" as it only needs a substring of the window title. Once you're in the game and at the MineOS > prompt, just keep hitting ` every time MineOS has processed a line. Compiling a complex line of commands can take a few seconds, so wait for it, as MineOS only has a small typeahead buffer.
When it has pasted the last line, the script exits. You can exit it early via the tray icon.
Here's my script.
Code:
#Include <Misc.au3>
#include <file.au3>
#Include <Array.au3>
$log = FileOpen("mclog.txt", 1)
WriteLog( "Start " & @ScriptName )
Dim $Code
If Not _FileReadToArray("Programs\signal.txt",$Code) Then
MsgBox(4096,"Error", " Error reading code to Array error:" & @error)
Exit
EndIf
Dim $Line = 1
WriteLog( "Index0 " & $Code[0] )
Opt( "SendKeyDelay",100 )
HotKeySet("`","PasteLine")
$win = "Direwolf20"
$handle = WinActivate($win)
While 1
sleep(250)
If $Line > $Code[0] Then ExitLoop
WEnd
Func PasteLine()
Send( $Code[$Line], 1)
Send( "{ENTER}")
WriteLog( $Line & ":" & $Code[$Line] )
$Line = $Line + 1
EndFunc
Func WriteLog($text)
FileWriteLine($log, @HOUR & ":" & @MIN & ":" & @SEC & "." & @MSEC & " " & $text )
EndFunc
There are three hard coded strings that you might want to change - the activation key, the file name, and the window title. If you can't find them, then what are you doing trying to write Forth programs?
Beware that some of the AutoIt forum folks are utterly against all forms of game automation, so if you go to their site to discuss this, then prepare for some hostility. Other than that caveat, the forum is fantastic and really helpful.
Here's an example file that defines a few simple words. Actually it's my entire project so far! It waits for one of three signals coming in on an IO Expander and displays which signal it received and then exits. Pretty soon I'll hook it up to another Sortron and get it to actually process the contents of an Enderchest in the appropriate way. I've already got the IO Expander hooked up to a line of Wireless Receivers, so I can send commands with my Wireless Remote.
Code:
: colWhite 1 ;
: colOrange 2 ;
: colMagenta 4 ;
: colLightBlue 8 ;
: colYellow 16 ;
: colLime 32 ;
: colPink 64 ;
: colGray 128 ;
: colLightGray 256 ;
: colCyan 512 ;
: colPurple 1024 ;
: colBlue 2048 ;
: colBrown 4096 ;
: colGreen 8192 ;
: colRed 16384 ;
: colBlack 32768 ;
: signalMacerate colRed ;
: signalFurnace colOrange ;
: signalRecycle colYellow ;
: signal
0
BEGIN
1
IOX@ signalMacerate = IF DROP ." Macerate" THEN
IOX@ signalFurnace = IF DROP ." Furnace" THEN
IOX@ signalRecycle = IF DROP ." Recycle" THEN
0= UNTIL ;
*EDIT* Fixed a bug where a ! character would not be sent, had to split the Send() call into two calls, one for a literal string and one for the {ENTER} special command.