Jump to content




[LUA] Help With Creating A Database


  • You cannot reply to this topic
2 replies to this topic

#1 BabyCodder

  • Members
  • 87 posts

Posted 01 April 2013 - 03:10 AM

I am currently coding a rednet message receiving system. I need something that saves (The save function) the message as a number or in a table and i need to print when I click on the monitor displaying this. Currently i have a sleep(5) and then do the print code but eventually this will be controlled by a os.pullEvent("screen_touch") Also I wondered how I can do all this but at the same time run a piece of code that checks for the screen_touch. Any help is appreciated. My current code is posted bellow.

d = 0
z = 1
i = 1
x = 0
rednet.open("back")
m = peripheral.wrap("top")
function save()
  q =(d+1)
  msg = tonumber(q)
  d =(d+1)
end
function printq()
  m.clear()
  m.setCursorPos(1,1)
  m.write(msg)
end
function message()
  x =(x+1)
  i =(i+2)
  m.setCursorPos(z,i)
  m.write("Sender: "..id)
  save()
  i =(i+1)
  m.setCursorPos(z,i)
  m.write("Message Saved As: "..tonumber(q))
  sleep(5)
  printq()
end

function new()
  m.clear()
  m.setCursorPos(1,1)
  m.write("NEW MESSAGE(S):")
  message()
end
while true do
  id, msg = rednet.receive()
  if x == 0 then
	new()
  elseif x == 6 then
	z = 19
	i = 1
	m.setCursorPos(z,i)
	message()
  else
	message()
  end
end


#2 Dlcruz129

    What's a Lua?

  • Members
  • 1,423 posts

Posted 01 April 2013 - 03:27 AM

You can run two functions at once with parallel. Use parallel.waitForAny(func1, func2)

#3 BabyCodder

  • Members
  • 87 posts

Posted 01 April 2013 - 03:33 AM

View PostDlcruz129, on 01 April 2013 - 03:27 AM, said:

You can run two functions at once with parallel. Use parallel.waitForAny(func1, func2)
Thank you. I'll note that on my 'notes' monitor so I remember to add it.





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users