Jump to content




How to stop a loop on a scrolling write



4 replies to this topic

#1 Mindthoth

  • Members
  • 9 posts

Posted 07 January 2017 - 07:09 AM

Alright so I made two program that I would like to run one after the other and loop it, therefore I made a program called "start"

start program is :

shell.run("mdk")
shell.run("big")



The mdk program is :

local pos = 18

mon = peripheral.wrap("right")
mon.clear()
mon.setBackgroundColor(16384)
mon.setTextColor(32768)

while true do

if pos==-26 then
pos = 18
end

mon.clear()
mon.setCursorPos(pos,1)
mon.setTextScale(5)
mon.write("text")
pos = pos-1

os.sleep(0.15)
end

big program is irrelevant since it doesn't include a loop in it.



Now basically when I call "start" the program keeps the loop of "mdk" (therefore you never see "big") I am trying to find how to make "mdk" loop once and make "start" play "mdk" then "big" and loop both program one after the other.

Thank you so much guys its been a brain tease xD

#2 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 07 January 2017 - 08:03 AM

One way is to use the parallel API:

parallel.waitForAny(
  function()
    shell.run("mdk")
  end,

  function()
    shell.run("big")
  end
)

If you're on an advanced computer you can alternatively have multishell open one script in a separate tab:

shell.run("bg mdk")
shell.run("big")


#3 Mindthoth

  • Members
  • 9 posts

Posted 07 January 2017 - 11:20 PM

Thanks for the relpy sadly tho I tried both.

The first code the program doesn't have to time to finish until it jumps to the next one while the second doesn't work at all.... Iam using the advanced computer.

#4 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 07 January 2017 - 11:40 PM

I can't really comment on how your second script will behave without seeing it.

#5 Mindthoth

  • Members
  • 9 posts

Posted 08 January 2017 - 12:11 AM

got it to work I just added the shell.run("big") inside of the "mdk" program after "then"





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users