Jump to content


AadamZ5's Content

There have been 2 items by AadamZ5 (Search limited from 29-March 23)


By content type

See this member's

Sort by                Order  

#229134 Parallel API - Updating statuses while also taking input

Posted by AadamZ5 on 06 August 2015 - 09:16 AM in Ask a Pro

View PostBomb Bloke, on 06 August 2015 - 07:13 AM, said:

Less to do with your use of the Parallel API (there are steps you need to take there, but you're performing them correctly), more to do with you sticking "" as a parameter when you call read(). It prints the value of that parameter when people type stuff, see. If you want it to print what they actually type, use read() instead of read("").

Aside from some missing variable localisation, the only other change I'd suggest would be to your "clear()" function - if a variable is set to false / nil, then simply sticking it into an "if" conditional check on its own'll make the result false. Any other variable is treated as true. You can therefore do:

if sec then sleep(sec) end

But those are minor issues.

Aha, Didn't know quotes weren't needed.
3rd edit, ftw. not reading right.

Problem solved, Not sure how to lock topic.



#229113 Parallel API - Updating statuses while also taking input

Posted by AadamZ5 on 06 August 2015 - 05:12 AM in Ask a Pro

So, I'm trying to make a control computer for a reactor lab, and what I've been trying to do is take input from the user while also updating the statuses of redstone signals on-screen.

Specifically, I have the redstone signal of my alarm system (A remote thermal monitor)

The problem then becomes, while using the read() function with parallel, My characters are not displayed, or so I have read, they are overwritten, and not redrawn on the screen.

I've searched and looked into similar problems, and have researched methods with using os.startTimer(1) but I cant figure out how I can apply this to my situation, for I am not too advanced in LUA.

My question is,

Is there any better method of doing this that could display similar results?
I still want my redstone signals to be tested and updated every 1 second, but I also want to type, while still seeing the characters.

function clear(sec)
  term.clear()
  term.setCursorPos(1,1)
  if not sec == nil then
	sleep(sec)
  end
end

function getAllInputs()
  clear()
  while true do
	alrm = rs.testBundledInput("bottom", colors.red)
	chmbrdoor = rs.testBundledInput("bottom", colors.orange)
	labdoor = rs.testBundledInput("bottom", colors.yellow)
	local retx,rety = term.getCursorPos()
	term.setCursorPos(1, 1)
	term.clearLine()
	if alrm then
	  term.write("Alarm: ")
	  term.setTextColor(colors.red)
	  term.write("Triggered")
	  term.setTextColor(colors.white)
	else
	  term.write("Alarm: ")
	  term.setTextColor(colors.green)
	  term.write("Ready")
	  term.setTextColor(colors.white)
	end
	term.setCursorPos(retx,rety)
	sleep(0.5)
  end
end

function labDoors()
  print("wip")
end

function cmds()
  while true do
	term.setCursorPos(1,2)
	print("Choose an option from the list to manipulate")
	print("LabDoors  ChamberDoors  Alarm  Reactor")
	inp = read("")
	if inp == "LabDoors" then
	  labDoors()
	else
	  print("Working on it still..")
	  sleep(2)
	end
  end
end

parallel.waitForAll(cmds, getAllInputs)