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

Simple 'bat' files

Started by Googie2149, 06 July 2012 - 05:20 PM
Googie2149 #1
Posted 06 July 2012 - 07:20 PM
I don't know Lua, and while I plan on learning at some point, I'd like the ability to be able to make batch files that contain commands from CraftOS, like redpulse. Having this would make it so much easier to make complex redstone contraptions, even for those that know Lua. You'd be able to turn on multiple wires on each side at once, turn them off, have it pause to wait for something, have loops, and other things like that to make massive redstone contraptions simple.
MysticT #2
Posted 06 July 2012 - 09:01 PM
If you want a program that can execute every line of a file like a program, it's pretty easy to do:

local tArgs = {...}
if #tArgs ~= 1 then
  print("Usage: run <file>")
  return
end

local file = fs.open(tArgs[1], "r")
if file then
  local sLine = file.readLine()
  while sLine do
    local tWords = {}
    for s in string.gmatch(sLine, "[^ t]") do
	  table.insert(tWords, s)
    end
    if tWords[1] then
      shell.run(unpack(tWords))
    end
  end
  file.close()
else
  print("Error opening file.")
end
That's a simple example of how to do it. Feel free to modify it to add anything you want.
aalleexxx5 #3
Posted 24 January 2013 - 08:08 AM
I really, really like this idea, and i was going to post this myself. i saw an old direwolf episode, where computers was called bat-computer, and I got the idea :)/>
I didn't think that i could sugest it to anyone, but then i saw this thread.
Here is the idea I had: i noticed in RP the "FORTH boot disc" and thought what if other programming languiges where added, that would let people like me (which is horebly good at batch programming) use their prefered languige? i know i'd use this mod a whole lot more :)/> (espeacelly because i can't get used to how lua is written, I derp in somthing as simple as setting a variable -_-/>)

I don't know if it is hard to implement, because i don't know Java at all, but i've been told that it is a miracle that the game runs at all :D/> and both LUA and FORTH seemes to be working fine ;)/>

high hopes.
-Alex
ChunLing #4
Posted 24 January 2013 - 08:43 AM
Er…okay, we can just use shell.run() a bunch to run programs. That strikes me as being conceptually easier to approach than creating a program to parse a file of command line entries into a series of shell.run() calls. And, perhaps less of a diversion from the process of learning Lua and the CC commands.

On the other side, Lua is a remarkably easy language to learn, I'm convinced that at least half the people writing working programs have never even read Programming in Lua or a similar document (true, they aren't writing the best or most complex programs, but they are successfully writing programs without making even the most basic effort to learn the language, which says something about how easy it is).

If you haven't read PIL, then you really don't have an informed basis for claiming that another language is easier…even bat files. I'm not saying that you're wrong, I'm just saying that you should try reading Programming in Lua and making some simple Lua programs before deciding.
TheOddByte #5
Posted 24 January 2013 - 10:35 AM
Er…okay, we can just use shell.run() a bunch to run programs. That strikes me as being conceptually easier to approach than creating a program to parse a file of command line entries into a series of shell.run() calls. And, perhaps less of a diversion from the process of learning Lua and the CC commands.

On the other side, Lua is a remarkably easy language to learn, I'm convinced that at least half the people writing working programs have never even read Programming in Lua or a similar document (true, they aren't writing the best or most complex programs, but they are successfully writing programs without making even the most basic effort to learn the language, which says something about how easy it is).

If you haven't read PIL, then you really don't have an informed basis for claiming that another language is easier…even bat files. I'm not saying that you're wrong, I'm just saying that you should try reading Programming in Lua and making some simple Lua programs before deciding.
First When I looked at your post quickly I thought it was some spam since you posted the same link two times..
Cloudy #6
Posted 24 January 2013 - 10:42 AM
No.