Posted 16 November 2014 - 06:32 AM
NOTE: I am running MC version 1.5.2 and CraftOS 1.5, which may be a factor to my problem.
I created an API for easily forming a slideshow. I have a control computer and a display computer (hooked up to a monitor) that are linked via wireless rednet connection.
Whenever my slideshow ends, the display computer always shuts down, even though I haven't put any os.shutdown() in the code.
Here is the code of the API:
The display computer's program:
And the controller program (on pastebin for your intrerest, I don't believe this program causes the problem)
So basically the API takes the info you give it and does all the work. All you do in the actual program is give that info to the API and set up the slide displays.
I have absolutely no clue as to why the computer shuts down. Maybe a bug due to the version? Dunno. Any help is appreciated!
Edit: I managed to catch the message before the shutdown. It read:
Error resuming bios.lua
Check you have installed ComputerCraft correctly.
I created an API for easily forming a slideshow. I have a control computer and a display computer (hooked up to a monitor) that are linked via wireless rednet connection.
Whenever my slideshow ends, the display computer always shuts down, even though I haven't put any os.shutdown() in the code.
Here is the code of the API:
local slide -- variable to hold which slide is activated
local totalSlides -- total slides in the whole slide show
local rnSide -- modem side
local ctrlCom -- computer to take messages from
local com, msg -- event holders, com is id and stands for computer
function setRNSide(side) -- gets the modem side from the program
rnSide = side
end
function setCtrlCom(id) -- gets the computer id to listen to
ctrlCom = id
end
function setTotalSlides(amount) -- gets total slides from program
totalSlides = amount
end
function getSlide() -- used in program to detect which slide should be activated and displays it
return slide
end
function wait() -- for lack of a better name to get msgs from ctrlCom
com, msg = rednet.receive()
if com == ctrlCom then
if msg == "forward slide" then -- next slide msg
if slide == totalSlides then -- if on the last slide return one more than total slides so the program detects if the slideshow is over
rednet.close(rnSide)
return slide + 1
end
slide = slide + 1
elseif msg == "back slide" and slide > 1 then -- back slide msg
slide = slide - 1
else
wait()
end
return slide
else
wait()
end
end
function slideShowStartup() -- sets up necessary things and waits for controller to get online
rednet.open(rnSide)
repeat
com, msg = rednet.receive()
until com == ctrlCom and msg == "start slide"
rednet.send(ctrlCom, "started") -- tells controller that the show started
rednet.send(ctrlCom, "ts: "..totalSlides) -- gives the controller the amount of slides
slide = 1 - initializes the slide to 1
end
The display computer's program:
local totalSlides = 5
os.loadAPI("slideshows/ss")
ss.setRNSide("top")
ss.setCtrlCom(6)
ss.setTotalSlides(totalSlides) -- giving the API info to work on
local slide = 1
local mon = peripheral.wrap("back")
local function slide1()
-- slide 1 display
end
local function slide2()
-- slide 2 display
end
local function slide3()
-- slide 3 display
end
local function slide4()
-- slide 4 display
end
local function slide5()
-- slide 5 display
end
local function display() -- checks which slide to display
mon.setBackgroundColor(colors.cyan)
mon.clear()
mon.setTextScale(3)
mon.setTextColor(colors.white)
if slide == 1 then
slide1()
elseif slide == 2 then
slide2()
elseif slide == 3 then
slide3()
elseif slide == 4 then
slide4()
elseif slide == 5 then
slide5()
end
end
mon.setBackgroundColor(colors.black) -- clears the monitor before the slideshow starts
mon.clear()
ss.slideShowStartup()
while slide <= totalSlides do -- if current slide is not over the total slides
slide = ss.getSlide() -- gets current slide from API
display()
slide = ss.wait()
end
mon.setBackgroundColor(colors.black) -- clears the monitor after the slideshow ends
mon.clear() -- where the program ends but then shuts down the computer
And the controller program (on pastebin for your intrerest, I don't believe this program causes the problem)
So basically the API takes the info you give it and does all the work. All you do in the actual program is give that info to the API and set up the slide displays.
I have absolutely no clue as to why the computer shuts down. Maybe a bug due to the version? Dunno. Any help is appreciated!
Edit: I managed to catch the message before the shutdown. It read:
Error resuming bios.lua
Check you have installed ComputerCraft correctly.
Edited on 16 November 2014 - 06:21 AM