Jump to content




Printing a File Directory

computer lua utility

  • You cannot reply to this topic
30 replies to this topic

#21 surferpup

  • Members
  • 286 posts
  • LocationUnited States

Posted 27 January 2014 - 01:12 AM

I am suspicious of your setup a bit. It seems as if when I run it, I have no trouble. When you run it, fail. I am not sure what is happening there other than some cache issue or some failure to get refreshed files from pastebin. That is why I like to develop locally and then add remote functionality. I use a Mac, so I have all sorts of Lua development options. There are a number of Lua editors for Windows based desktops as well. Lua Edit is one I just looked up. You can keep the code open and save directly to your world/computer/0/myProgram file even while you keep the game up. That way you do not need to deal with the vagrancies of pastebin until you are ready to fully test that. If I destroy a turtle or computer accidentally, I just copy the programs over to the new computer ID or turtle ID folder.

I just tested again on a new computer and on my original computer. It worked fine.

I am calling it a night. I will check on this in the morning some time. Best of luck, you are making progress.

#22 ClassicRockFan

  • Members
  • 56 posts

Posted 27 January 2014 - 01:14 AM

Thank you very much for all of your help.

#23 surferpup

  • Members
  • 286 posts
  • LocationUnited States

Posted 27 January 2014 - 01:16 AM

More than welcome. I have been exactly where you are -- even recently... There are some great coders on this site, and they are always happy to help people who ask well-formed questions and make honest attempts at coding.

#24 ClassicRockFan

  • Members
  • 56 posts

Posted 27 January 2014 - 07:25 PM

I will upload a new pastebin with the "final" product as soon as it's ready. Thank you so much

#25 surferpup

  • Members
  • 286 posts
  • LocationUnited States

Posted 28 January 2014 - 09:39 AM

Let me know when it is done -- I will look at it.

#26 ClassicRockFan

  • Members
  • 56 posts

Posted 21 February 2014 - 12:18 AM

I am experiencing some setbacks due to pastebin deleting my files so there will be a great delay as I remake my code.

#27 Engineer

  • Members
  • 1,378 posts
  • LocationThe Netherlands

Posted 21 February 2014 - 05:35 AM

View PostClassicRockFan, on 21 February 2014 - 12:18 AM, said:

I am experiencing some setbacks due to pastebin deleting my files so there will be a great delay as I remake my code.
You should make a pastebin account. That way you don't have to write down paste ID's (at least, not to remember them) plus you have no limit iirc.

I really would recommend to use an external editor like Surferpup already suggested. I read this thread quickly, and saw something about a server.
Really development is way quicker in singleplayer with a proper text editor (Notepad++ or Sublime Text 2) and point the editor to: world/computer/id/program.

You don't have to reboot the computer to run your just saved program, Cc handles that perfectly fine.

One extra tip: make a logging file and log that certain things happen. It helps you with debugging and most likely speed up things.

#28 ClassicRockFan

  • Members
  • 56 posts

Posted 21 February 2014 - 08:09 PM

Yeah. It's not that I have a problem with remembering the pastebin, rather that it deleted my file. Couple this with my test world (where I do my coding) getting corrupted, I'm just having some segbacks. Shouldn't be much longer to fix the damage done. And I just recently found a file editor that I like. I'm not sure I understand about the logging file however. I will make a pastebin account for sure. However, I'm not sure I understand about the logging file. Can you elaborate on that?

Edited by ClassicRockFan, 21 February 2014 - 09:33 PM.


#29 ClassicRockFan

  • Members
  • 56 posts

Posted 22 February 2014 - 08:41 PM

Hey guys, I'm in the final stages of restoring my code and now I can't get one of my old functions to work properly. Can anyone tell me why its not working properly? The error shows up after you left-click on the file icon after the program starts. I can get the selected file(backcolor of yellow) to go up, and back down, but can t get it to go past the first file downward. Also, I want it to go to the bottom of the list if you are at the top (and push the up) and to the top if you are at the bottom (if you are pressing the down key). I have no clue why its not working properly. just download Xa0c6GiD as startup and run it. If you want to look at the code, its in the file() of the file login near line 54. The selected variable is defined near the top of the entire code. Any other tips are welcome.

#30 Bomb Bloke

    Hobbyist Coder

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

Posted 22 February 2014 - 09:16 PM

For quick reference, the script in concern is here.

I would re-write the "file()" function as something like:

Spoiler

It still needs further work though; as-is, as soon as the amount of files exceeds the number of lines available on the screen it'll run into trouble. Hopefully it points you in the right direction.

Note that having "file()" call "redrawFile()" (a function which simply calls "file()") was much the same as just having "file()" call "file()". Generally speaking, functions should not call themselves to perform jobs they're already supposed to be doing - this is called recursion, and it fills up the stack with unfinished function calls until Lua runs out of the memory reserved for them and crashes your script.

#31 ClassicRockFan

  • Members
  • 56 posts

Posted 22 February 2014 - 10:53 PM

Okay. Thanks for the tips. I will be adding an addition to deal with large volumes of files. Probably something to the extent of finding the max length of all of the files in the first column and setting x larger than that. Will deal with left and right selection after that. Are there any other comments you have on my script to make it run better or other function ideas?

Edited by ClassicRockFan, 22 February 2014 - 10:55 PM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users