Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal
  • Announcements

    • Lizzy Trickster

      Latest Stable OpenComputers Version   11/26/16

      The latest released version of OpenComputers is version 1.7 for MC 1.7.10, 1.8.9, 1.9.4, 1.10.2, 1.11.2 & 1.12.1. See more information here! Beta/Dev builds can be found at the Jenkins Build Server (ci.cil.li)
  • 0
noahthegame

thread question #2

Question

i don't know if this is even possible but what i am trying to do is this

 

NOTE: that is know that useing a thread in this scene is 100% Unnecessary but remeber this is a simple test

--------------------------------------------------------------------------------

thread = require "thread"

e = require "event"

 

running = true

 

t = thread.create(function()

  e.pull("touch")

  

-- i know that i can put a os.exit() here but the thing is to try to get this to work

running = false --<< that

end)

 

while running do

  --some random thing to run a io.read() will be a good combo

 

  print( "you said: "..io.read() )

end

-----------------------------------------------------------------------------------------------

 

so this ends the thread as inspected but does not end the loop my guess is that all things in the thread function is local only but what can i then do to update the "running" value in the global process aka in the while loop???

 

all help will be great

 

--thanks

Share this post


Link to post
Share on other sites

6 answers to this question

Recommended Posts

  • 0

io.read() is a blocking operation so io.read() must complete before it checks if it is still running.

Share this post


Link to post
Share on other sites
  • -1

Thanks for the massage i sure that i testet that but i Will test it again. i Will have ny computer i 20 hours then i Will test it 

 

maybe You Can test it for me?

 

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×