Jump to content




Startup not working correctly


13 replies to this topic

#1 Arimus

  • Members
  • 15 posts

Posted 12 August 2013 - 07: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!

#2 CometWolf

  • Members
  • 1,283 posts

Posted 12 August 2013 - 08: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"


#3 Arimus

  • Members
  • 15 posts

Posted 12 August 2013 - 09: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!

#4 campicus

  • Members
  • 164 posts

Posted 12 August 2013 - 12:12 PM

Is your program called "main" or "mainControl"?

#5 Arimus

  • Members
  • 15 posts

Posted 12 August 2013 - 12:29 PM

sorry, I changed it half way through. Its called "main" now. I got lazy :) I updated pastebin

#6 Kilobyte

  • Members
  • 122 posts

Posted 12 August 2013 - 12:30 PM

so, are there any error messages? Or just no executation?

#7 Arimus

  • Members
  • 15 posts

Posted 12 August 2013 - 12: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.

#8 LBPHacker

  • Members
  • 766 posts
  • LocationBudapest, Hungary

Posted 12 August 2013 - 12: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

View PostKilobyte, on 12 August 2013 - 12:30 PM, said:

executation


#9 nateracecar5

  • Members
  • 94 posts

Posted 12 August 2013 - 12: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!

#10 Arimus

  • Members
  • 15 posts

Posted 12 August 2013 - 12:47 PM

View Postnateracecar5, on 12 August 2013 - 12:43 PM, said:

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?

#11 Arimus

  • Members
  • 15 posts

Posted 12 August 2013 - 12:48 PM

View PostLBPHacker, on 12 August 2013 - 12:42 PM, said:

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!

#12 LBPHacker

  • Members
  • 766 posts
  • LocationBudapest, Hungary

Posted 12 August 2013 - 12: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.

#13 Arimus

  • Members
  • 15 posts

Posted 12 August 2013 - 12: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.

#14 Arimus

  • Members
  • 15 posts

Posted 12 August 2013 - 12: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.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users