Jump to content


L00K3's Content

There have been 4 items by L00K3 (Search limited from 18-April 20)


By content type

See this member's

Sort by                Order  

#237253 term.setCursorPos not working

Posted by L00K3 on 06 November 2015 - 10:40 PM in Ask a Pro

sorry i didn't actually think of that, thnx. :)



#237214 term.setCursorPos not working

Posted by L00K3 on 06 November 2015 - 08:39 AM in Ask a Pro

With the term.setCursorPos its disposed to ensure the bars are centered under there header, but for example term.setCursorPos(3,5) sets the cursor to position (1,5) instead of having an x position of 3. This program is disposed to monitor a reactor and report back the status to me.

--Variables To Store Data For Later UI
local Reactor = peripheral.wrap("right")
local Con_State = false
local FuelAmmount = 0
local WasteAmmount = 0
local CoolantAmmount = 0
local SteamPressure = 0
UpdateBlock = function()
  --Updates UI Display
  term.clear()
  term.setCursorPos(1,1)
 
  --Prints Opening ASCII Graphics Banner
  print "---------------------------------------------------"
  print "||			 Reactor Monitor V0.1a			 ||"
  print "---------------------------------------------------"
 
  term.setCursorPos(1,5)
 
  --States Weather Reactors Active And Status Headers
  print ("Active = " .. tostring(Reactor.callRemote("BigReactors-Reactor_0", "getActive")))
  print ("Fuel  | Waste | Cool  | Steam | Temp")
 
  --Shows Fuel Level (Max 48000)
  term.setCursorPos(3,7)
  for pointer=10, 0, -1 do
    if Reactor.callRemote("BigReactors-Reactor_0", "getFuelAmount") >= (pointer * 4800) then
	  print ("#")
else
	  print ""
end
  end
 
  --Shows Waste Level (Max 48000)
  term.setCursorPos(11,7)
  for pointer=10, 0, -1 do
    if Reactor.callRemote("BigReactors-Reactor_0", "getWasteAmount") >= (pointer * 4800) then
	  print ("#")
else
	  print ""
end
  end
 
  --Shows Coolant Level (Max 10000)
  term.setCursorPos(19,7)
  for pointer=10, 0, -1 do
    if Reactor.callRemote("BigReactors-Reactor_0", "getCoolantAmount") >= (pointer * 1000) then
	  print ("#")
else
	  print ""
end
  end
 
  --Shows Steam Level (Max 10000)
  term.setCursorPos(27,7)
  for pointer=10, 0, -1 do
    if Reactor.callRemote("BigReactors-Reactor_0", "getHotFluidAmount") >= (pointer * 1000) then
	  print ("#")
else
	  print ""
end
  end
 
  term.setCursorPos(35,7)
 
 
  --Test If Reactor Heat Critical (Max I've Left Is 2800 Before Warning)
  while (Reactor.callRemote("BigReactors-Reactor_0", "getFuelTemperature") >= 2800) do
    term.clear()
    print ("WARNING REACTOR TEMPERATURE HIGH")
  end
 
  --Shows Reactor Temperature Level (Max 3000)
  for pointer=10, 0, -1 do
    --print (tostring(Reactor.callRemote("BigReactors-Reactor_0", "getFuelTemperature")))
    if ((Reactor.callRemote("BigReactors-Reactor_0", "getFuelTemperature")) >= (pointer * 300)) then
	  term.write("It Worked")
   term.write("#")
else
	  print ""
end
  end
end--Ensures Connection Available
Con_State = Reactor.callRemote("BigReactors-Reactor_0", "getConnected")
--Test If Connected
if (Con_State == false) then
  print ("Error, Please Ensure The Reactor Is Connected")
else
 
  --Runs Program Until Lost Connection
  while ((Reactor.callRemote("BigReactors-Reactor_0", "getConnected")) == true) do
    --Runs GUI Update
UpdateBlock()
sleep(5)
  end
 
  --Ends Program
  term.clear()
  print "Error, Can't Connect To Reactor"
end



#204913 Door Lock

Posted by L00K3 on 02 February 2015 - 09:45 AM in Ask a Pro

thanks but it exits after main has finished (i think possibly it could have run the others in the background) but i need to take input from "userInput".



#203992 Door Lock

Posted by L00K3 on 24 January 2015 - 11:24 AM in Ask a Pro

I'm making a program that will control a 3 x 3 piston door and uses coroutines, but crashes on load.

This is the code:

--Ask's for password
function main()
io.write("Enter Password: ")
passwordEntered = io.read()

if (passwordEntered == passwordSet) then
   passwordCorrect = true
end

while (passwordCorrect == false) do
   io.write("Password Incorrect, Re-Enter Password:")
  
   if (passwordEntered == passwordSet) then
  passwordCorrect = true
   end
end
end--Test for a signal from a second computer, locks if signal is true
function signaltest()
label = cheackPasswordForST
if (passwordCorrect == true) then
  print("Signal Tester Started")
  while (signalRecieved == false) do
   if (redstone.getOutput("top", true) == true) then
    signalRecieved = true
   end
  end
else
  sleep(2)
  goto = cheackPasswordForST
end

end-- Asks on host computer if user wants to lock door
function userInput()
label = cheackPasswordForUI
if (passwordCorrect == true) then
  print("User Input Started")
  local stateReset = true  while (stateReset == true) do
   io.write("Lock (y/n):")
    stateRecieved = io.read()
   if (stateRecieved == "n") then
    stateReset = true
   else
    signalRecieved = true
    stateReset = false
   end
  end
else
  sleep(2)
  goto = cheackPasswordForUI
end

end
--Opens door on correct password, locks if user asks to lock door
function doorOpen()

label = testForOpen
if (passwordCorrect == true) then
  print("Door Opened")
  redstone.setOutput("back", true)
else
  sleep(2)
  goto = testForOpen
end

label = testForSignal
if (signalRecieved == true) then
  print("Door Closed")
  redstone.setOutput("back", false)
  redstone.setOutput("bottom", true)
  redstone.setOutput("bottom", false)
  os.reboot()
else
  goto = testForSignal
end
end-- Global Variables
passwordEntered = "na"
passwordSet = "admin"
stateRecieved = "n"
signalRecieved = false
passwordCorrect = false
threadMain = "nil"
threadST = "nil"
threadUI = "nil"
threadDO = "nil"
--Sets Threads Up
threadMain = coroutine.create(main)
  coroutine.resume(threadMain)
threadDO = coroutine.create(doorOpen)
  coroutine.resume(threadDO)
threadST = coroutine.create(signaltest)
  coroutine.resume(threadST)
threadUI = coroutine.create(userInput)
  coroutine.resume(threadUI)-- Loops to prevent program from closing
while true do
end