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

[1.6.4][CC1.6]Can't edit a script properly after having launched a program

Started by emimi100, 05 August 2014 - 05:23 PM
emimi100 #1
Posted 05 August 2014 - 07:23 PM
This problem never happened to me before.
Basically I have a program that displays stuff on a monitor and that sends informations via rednet. http://pastebin.com/RXsBRrML
It is using the API from Direwolf20 that I tweaked a little bit. http://pastebin.com/35kxLaS3
And I have another computer next to an EnderChest which on top of it there is a book receptacle. http://pastebin.com/uPQTBbrG

The problem basically occurs when I start the program "s", if I "ctrl+t" then I try to edit it, my keyboard refuses to let me type "backspace", "return", any arrows, "ctrl",…
However I can type without any problems any letters, "spacebar".
The problem doesn't occur before I start once the program "s"; so if I break the computer (labelled) and I place it where it was, while I don't start "s", I can edit it without any problem.
If I want to get out of it, I need to press "ctrl+t" (or break the computer) but the text where all the code is doesn't disappear.
That ONLY happens after I started "s"
Note that the ID of the computers are correct.

If you need more details or screenshots about the problem, ask me. I am sorry if this problem has already been reported, I only searched on google but I couldn't find anything,
Btw I play on FTB Monster if that can help

Thank you for taking the time to read this and maybe helping me to solve this problem,

Kind regards,
emimi100
Edited on 05 August 2014 - 06:22 PM
Lyqyd #2
Posted 05 August 2014 - 10:13 PM
Moved to Ask a Pro.

You declare a table named "keys" in s, overwriting the keys API. Localize the variable or choose a different variable name to fix the problem.
emimi100 #3
Posted 05 August 2014 - 10:41 PM
Moved to Ask a Pro.

You declare a table named "keys" in s, overwriting the keys API. Localize the variable or choose a different variable name to fix the problem.

Thank you very much Lyqyd !
May I ask you why this happened?
theoriginalbit #4
Posted 06 August 2014 - 12:37 AM
He already said why this happened. You named one of your variables the same as an API, thus overriding the API, program's such as the shell use this API. Localising your variable means that the API isn't overridden (however you cannot access it from your program without implicitly accessing it) and once your program has finished running your variable no longer exists in memory.
Agorath #5
Posted 06 August 2014 - 01:37 AM
Hello there. Co-coder of the above script, and I would like to thank you for your assistance and the issue has been resolved.

P.S. Thank you Lyqyd for always solving my problems with coding. This is the first I've had to ask vs. find it via google.
emimi100 #6
Posted 06 August 2014 - 07:02 AM
He already said why this happened. You named one of your variables the same as an API, thus overriding the API, program's such as the shell use this API. Localising your variable means that the API isn't overridden (however you cannot access it from your program without implicitly accessing it) and once your program has finished running your variable no longer exists in memory.

That's the details I wanted to have, I couldn't understand the link between overriding the API and not being able to edit properly.
Thank you again. That saved us a lot of time, I wouldn't have imagine an issue such as this.
theoriginalbit #7
Posted 06 August 2014 - 07:59 AM
you're welcome. for the future, localise everything, unless it is in an API and you want it accessible. you should avoid polluting the global scope unless absolutely needed.