This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Arimus's profile picture

Startup not working correctly

Started by Arimus, 12 August 2013 - 06:34 AM
Arimus #1
Posted 12 August 2013 - 08:34 AM
Hi there,

So I am really new to computercraft (and programming in general to be honest) but I am noticing something strange. I have implemented a couple of APIs in my program and everythings runs great. For instance, I am setting a number of colored wires to true when the program runs. If I start the program the wires in question are enabled. However, if I edit "startup" of my computer add my program and reboot, the colored wires are not "turned on". What is the difference between running the program manually and running it from startup?

I need this to work because the server I play on restarts every couple of hours due to performance issues.

Many thanks!
CometWolf #2
Posted 12 August 2013 - 09:39 AM
Any chance you could post your program and/or the startup file? Usually when you want to execute a program at startup you simply rename your program to startup. Another option is using a startup file with the following code

shell.run"filename"
Arimus #3
Posted 12 August 2013 - 10:29 AM
Here is a link to my program. Please don't laugh :P/> I am pretty sure a lot of things could be done more efficiently:

http://pastebin.com/JrFCEK5U (my program)
http://pastebin.com/BYEsjxvd (implemented API for bundled cable)
http://pastebin.com/S3WmbP1g (implemented API for buttons)

In my program you can see that I set the state of the colored wires at the start. This doesn't seem to happen if I launch my program using shell.run("main") from startup.

Thanks!
campicus #4
Posted 12 August 2013 - 01:12 PM
Is your program called "main" or "mainControl"?
Arimus #5
Posted 12 August 2013 - 01:29 PM
sorry, I changed it half way through. Its called "main" now. I got lazy :)/> I updated pastebin
Kilobyte #6
Posted 12 August 2013 - 01:30 PM
so, are there any error messages? Or just no executation?
Arimus #7
Posted 12 August 2013 - 01:34 PM
Well the program executes (apparently) and there are no error messages. However, the first part of the code seems to be skipped. All of the colored wires should be set to true but they aren't.
LBPHacker #8
Posted 12 August 2013 - 01:42 PM
Put this after line 15:
rs.setBundledOutput("back", 65535)
os.pullEvent("key")
That will stop the execution* until you press a key - check the wires with something (eg. a transciever, if you're using RP), and then press a key. If all the wires are on, that means that something's with the API, and the wires work perfectly. That is, we don't know that yet, that's why I'm suggesting this test. This is one of the rare cases where I have no idea what goes wrong, since there shouldn't be difference between executing something manually or by using a startup script. The only thing I though of was the API - which I suppose is already loaded when you try to run the program manually - but that just makes no sense. Anyways, try to unload both APIs first, and load them after that.

*: it's execution, not executation - no offense
executation
nateracecar5 #9
Posted 12 August 2013 - 01:43 PM
Wouldn't it be easier to use the bundled cable functions in the built in redstone api? Check this page out for more. For the colors, check this page out for more. Hope this helps!
Arimus #10
Posted 12 August 2013 - 01:47 PM
Wouldn't it be easier to use the bundled cable functions in the built in redstone api? Check this page out for more. For the colors, check this page out for more. Hope this helps!

Perhaps I missed something but I wasn't able to toggle the signals with that API?
Arimus #11
Posted 12 August 2013 - 01:48 PM
Put this after line 15:
rs.setBundledOutput("back", 65535)
os.pullEvent("key")
That will stop the execution* until you press a key - check the wires with something (eg. a transciever, if you're using RP), and then press a key. If all the wires are on, that means that something's with the API, and the wires work perfectly. That is, we don't know that yet, that's why I'm suggesting this test. This is one of the rare cases where I have no idea what goes wrong, since there shouldn't be difference between executing something manually or by using a startup script. The only thing I though of was the API - which I suppose is already loaded when you try to run the program manually - but that just makes no sense. Anyways, try to unload both APIs first, and load them after that.

I will try that. But first I will try unloading the APIs and then loading them again. I did read something about that or see it in a YT video. Thanks!
LBPHacker #12
Posted 12 August 2013 - 01:50 PM
Okay, thought about it for a bit, and I realized that the wires ARE working, since they DO work with the startup. Now the only thing I can think of is that the APIs stay loaded and that messes it up somehow. Though I still have no idea how is that possible.
Arimus #13
Posted 12 August 2013 - 01:54 PM
Ok I tried your suggestion LBPHacker and when I add that code, I see the wires light up as expected and I press a key and the program works. But as soon as I remove that test, it doesn't.
Arimus #14
Posted 12 August 2013 - 01:57 PM
I updated the pastebin (http://pastebin.com/JrFCEK5U). As you can see I have added unloading the APIs before loading them but this doesn't seem to help.