Jump to content


Ilikemlp123's Content

There have been 9 items by Ilikemlp123 (Search limited from 10-February 22)


By content type

See this member's

Sort by                Order  

#271381 LSC (Latch) - A Lua based batch system

Posted by Ilikemlp123 on 30 October 2017 - 03:08 AM in APIs and Utilities

View Postminebuild02, on 25 October 2017 - 03:10 PM, said:

View PostLuca_S, on 21 October 2017 - 06:00 PM, said:

Tiedied up the loop a bit and also put the execution of the commands after the reading in, so that commands that take a longer time don't keep the FS handle open.
Also this fixes the File not found bug.

Pastebin: R9K4JHZN
Great code here. Can I use this for scripts in my OS? Haven't been able to figure file parsing out for a while.
always. i appreciate people using my programs. i've been quite busy recently so i can't respond immediately



#270943 LSC (Latch) - A Lua based batch system

Posted by Ilikemlp123 on 13 October 2017 - 12:09 AM in APIs and Utilities

if you've ever wanted to have batch files or similar in computercraft OR you clicked on this while browsing programs,
I have just the program
Latch 1.0
Pastebin:uaRxBM0q
how it works:
Latch works by opening the selected file in the filesystem, and reading the lines, then it executes the programs listed in sequential order.
ex: run the code
lsc example
Example Script:
ls
cd ..
cd rom
ls
cd programs
ls
cd ../..
programs
How to write a script(for dummies):
  • type edit, and choose a filename. press enter
  • list the programs and their args in sequential order.
  • press ctrl, then press save
  • run lsc <script name>

Feel free to write programs to go with this, or even improve on this program's design
known bugs:
after executing, it ALWAYS says file not found

Edit:
Thanks to Luca_S for fixing this bug, and changing the code

View PostLuca_S, on 21 October 2017 - 06:00 PM, said:

Tiedied up the loop a bit and also put the execution of the commands after the reading in, so that commands that take a longer time don't keep the FS handle open.
Also this fixes the File not found bug.

Pastebin: R9K4JHZN

You are free to use this in your Operating system, or in any project you want, feel free to add credit, although i don't require it as long as you don't claim it as your own



#270937 [Resolved]Reading file not working

Posted by Ilikemlp123 on 12 October 2017 - 02:46 AM in Ask a Pro

ok, i have a fix that might work. i'm adding a default for if the file doesn't exist



#270935 [Resolved]Reading file not working

Posted by Ilikemlp123 on 12 October 2017 - 02:11 AM in Ask a Pro

i'm trying to load a file for my script program (will be shown in media once complete), but whenever i try to run it with a file, it just gives an error on line 10 or 11
pastebin: uwvtyEhR
local tArgs = { ... } --args
if #tArgs == 0 then --args
print('Usage: lsc <path>') --Print Usage
else
local path = tArgs[1] --path
local Scr = fs.open('path','r') --attempted fs access
local loop = true --loop
while loop do --loop begin
local commands = {} --empties commands
local line = Scr.readLine(1) --reads line
if line then --if the line has things
text = nil --nillifies text
for text in line:gmatch('%w+') --attempts to split text
  do table.insert(commands,text) --more split
end--end split
for i=1,#commands do shell.run(commands[i]) --executes
end --end
else --else loop
loop = false --ends loop
end
end
end
i am a noob at lua.
pls help

Update: the bug was because i put quotes around a variable name
All fixed
lock the thread



#270066 COM port support

Posted by Ilikemlp123 on 06 September 2017 - 01:40 PM in Suggestions

it would be very nice to connect to com ports from computercraft (or craftOS 2.0 for that matter)
so, would this be at all possible in the near future? (i kind of want to use microsoft robotics studio to control my turtles)



#266672 How to make a wireless lua prompt

Posted by Ilikemlp123 on 26 April 2017 - 04:47 PM in Tutorials

How to make a wireless lua prompt:

first: copy the base lua program and edit
to do this, simply run: "copy rom/programs/lua ./wlua"
now type edit wlua

second: locally overwrite read()
type in the following code at the very beginning:
local port = 1337	 //this is very important, it sets the port for the wireless execution, change 1337 to whatever number you want(has to be between 0 and 65535)
local modem = peripheral.find("modem")	 //this wraps the modem. you'll need this
modem.open(port)	 //this opens the previously mentioned port
local function read()	 //this is where we overwrite the read() function
local event,s,r,message,dis = os.pullEvent("modem_message")	 //this gets messages from the modem
if s == 1337 then	 //this makes sure you're on the 1337 channel to avoid errors
return message	 //tells the computer what do do
end	 //ends the if statement
end	 //ends the function
save and exit the editor.
now, for the sending side,

Sender:
create a file named wlua on the sender computer.
edit the file and type the following:
//start
local send = 1337     //sets the transmit channel, change this to the one in the first program
local rec = 137     //arguably useless
local tArgs = { ... }	 //grabs args for stuff
local modem = peripheral.find("modem") //looks for the modem, to send things
if #tArgs then print("to use wireless lua prompt, simply type 'wlua' ") //yells at you for arguing with it
else	 //else
while true do	 //loops it
local x = read()	// sets x to the given input
if  x ~= "end()" then	 //checks x for the end
modem.transmit(send,rec,x)	 //transmits your variable
else	 //else
modem.transmit(send,rec,'end()')	 //transmits the end
break end	 //breaks the loop and ends the IF statement
end	 //ends the other IF statement
end	 //ends the loop


EDIT:what i'm doing on this tutorial:
i'm overwriting the read() function with a custom function that allows me to transmit commands as a string
then, on the other computer i am transmitting the commands so that the host will execute them.
you don't need to include the comments in the code, i will put up a wlua pastebin link in the APIs and utilities
i'm sorry if this is more of a "how i did it" than a tutorial, but it's too late now



#266658 Send Events to computers attached as peripherals

Posted by Ilikemlp123 on 26 April 2017 - 04:58 AM in Suggestions

It would be very great if you could send events to computers/turtles attached as peripherals.
Another addition to my idea is the ability to send programs the same way.

the functions would be like this:
//send event
C1 = peripheral.find("computer")
C1.sendEvent("remoteEvent","params")
//send program
C1.sendProgram("path","remotepath")




#263744 Keep chunks with computers loaded

Posted by Ilikemlp123 on 16 January 2017 - 09:04 PM in Suggestions

there really should be a config option for this.



#263743 Full Multitasking

Posted by Ilikemlp123 on 16 January 2017 - 08:57 PM in Suggestions

are you aware of the bg program on adv computers or coroutines?