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

Simple startup script for non programers

Started by neluxjanz, 28 June 2015 - 11:05 AM
neluxjanz #1
Posted 28 June 2015 - 01:05 PM

--#####################user variables########################
local w,h =  term.getSize()
local wm, hm, monitor
local machine = "back"
local lights = "right"
local Monitor = "top"
local Modem = "left"
local password = "necas"
local opentime = 120
local systime = 2
local title = "Welcome NeluxOS"
local iniText = "Iniciating system test"
local lightsText = "Lights on?"
local lightsOtext = "Lights stay off"
local passwordText = "Password:"
local passwordCtext = "Password correct!"
local passwordItext = "Password incorrect!"
local factoryWtext = "Factory is working..."
local factoryStext = "Factory has stop"
--##############get monitor##############
function startMonitor()
  peripheral.call(Monitor, "write", "Test")
  monitor = peripheral.wrap(Monitor)
  wm, hm = monitor.getSize()
end
--#####clear both shell and monitor#####
function clearScreen()
term.clear()
term.setBackgroundColor(colors.black)
term.setTextColor(colors.green)
monitor.clear()
monitor.setBackgroundColor(colors.black)
monitor.setTextColor(colors.green)
monitor.setTextScale(.5)
end
--###keep first line and clear all rest###
function cleanline()
monitor.clearLine(2,x)
term.clearLine(2,x)
end
--###########tittle position#########
function screenTpos()
term.setCursorPos(1,1)
monitor.setCursorPos(1,1)
end
--#########content position########
function screenGpos()
term.setCursorPos(1,2)
monitor.setCursorPos(1,2)
end
--#####start modem - "under test"####
function startModem()
modem = peripheral.wrap(Modem)
modem.open(0)
modem.isOpen(0)
--modem.closeAll()
end
--#### X function echo's to all present devices ###
x = function()
print(t)
monitor.write(t,wm)
modem.transmit(0,1,t)
end
--######initiating peripherals#####
startMonitor()
startModem()
--####gets X/Y and the routine aware of changes in resolution###
for k,v in pairs(peripheral.getMethods(Monitor)) do
print(v)
print("Terminal size = " .. w .. "," .. h)
print("Monitor size = " .. wm .. "," .. hm)
end
--########LOGIC TiME#######
clearScreen()
screenTpos()
t = title
x()
sleep(systime)
screenGpos()
t = iniText
x()
sleep(systime)
sleep(4)
cleanline()
while true do
screenGpos()
t = lightsText
x()
local input = read()
if input == "yes" then
cleanline()
screenGpos()
rs.setOutput(lights,true)
else
cleanline()
  screenGpos()
t = lightsOtext
x()
end
cleanline()
screenGpos()
t = passwordText
x()
local input = read("*")
if input == password then
cleanline()
screenGpos()
t =  passwordCtext
x()
  sleep(systime)
  rs.setOutput(machine,true)
cleanline()
  screenGpos()
t = factoryWtext
x()
  sleep(opentime)
  screenGpos()
  rs.setOutput(machine,false)
t = factoryStext
x()
cleanline()
  screenGpos()
else
t = passwordItext
x()
sleep(2)
os.shutdown()
--shell.run(boolean)
clearScreen()
screenTpos()
end
end
Edited on 10 July 2015 - 12:15 PM
ebernerd #2
Posted 28 June 2015 - 06:29 PM
Use code tags. It'll make your forum post look much neater
98Games_YT #3
Posted 30 June 2015 - 10:03 PM
If you want people to use your code, try putting it on Pastebin. ComputerCraft comes with a Pastebin program that you can use to upload programs and download programs. Using Pastebin with your code will make it much easier for people to use.

EDIT: I put it on pastebin for you to save the trouble

To get the code, type in on CraftOS 'pastebin get GUX9021V startup'
or for the source code, type this URL into your web browser: http://pastebin.com/GUX9021V

Hope I helped you today :)/>
Edited on 30 June 2015 - 08:05 PM
cyanisaac #4
Posted 03 July 2015 - 03:39 AM
I'm… not really sure this is an OS. It doesn't appear to sandbox anything or run around any apps, this appears to be a startup program, in which case it should go in programs.

It's also extremely hard to run, you need a monitor AND a modem and if you don't have that then it will crash, and even then I get some "password incorrect" bug that I don't know how to work around, is there even a password?

Can you maybe explain a bit about what this does and how to set it up? That would help greatly.
Lyqyd #5
Posted 03 July 2015 - 04:41 AM
I'm… not really sure this is an OS. It doesn't appear to sandbox anything or run around any apps, this appears to be a startup program, in which case it should go in programs.

That's not the classification criteria. This is the correct location for this program, as far as I can tell.
neluxjanz #6
Posted 10 July 2015 - 12:53 PM
My friends of course its not a OS, I just put that name to test the refresh rate while the function clearline() and screenGpos() and see if I the monitor buffer holds. Also thanks for the heads up on the code tags. :wacko:/>/>

If you want people to use your code, try putting it on Pastebin. ComputerCraft comes with a Pastebin program that you can use to upload programs and download programs. Using Pastebin with your code will make it much easier for people to use.

EDIT: I put it on pastebin for you to save the trouble

To get the code, type in on CraftOS 'pastebin get GUX9021V startup'
or for the source code, type this URL into your web browser: http://pastebin.com/GUX9021V

Hope I helped you today :)/>/>

Thanks for tip ,this is a quite useful tool :)/>/> , just started to play minecraft a few weeks ago, and when I've learn about computerCraft I just loved it… :lol:/>/>
I've commented the code, and put the code tags on .
Also have to point out that the variables are setup to the world I have in minecraft.

I hope with the comments help. ;)/>/>

I'm… not really sure this is an OS. It doesn't appear to sandbox anything or run around any apps, this appears to be a startup program, in which case it should go in programs.

That's not the classification criteria. This is the correct location for this program, as far as I can tell.


We can argue that it is current form does not resemble a operating system but it takes a good bit of Lua from the user ,meaning all sides of the cube are supported and extra peripherals.
I gave'it the name startup so it starts on boot and the user only has to do one conf.

Thank you for all the reply's and sorry for time it toke to respond…(stuff) :(/>/>
Edited on 10 July 2015 - 03:19 PM