Version Info: 1.56 Client And 1.56 Server
Description of bug: after running my program it seems to break backspacing/deleting characters in the edit program
How To Reproduce: Run this program here http://pastebin.com/q7vk7hdy then do "edit file" and then write some letters and try to backspace
[Cc1.56][Ssp/smp]Cant Backspace/delete Characters After Running My Program
Started by jay5476, Aug 20 2013 05:43 AM
4 replies to this topic
#1
Posted 20 August 2013 - 05:43 AM
#2
Posted 20 August 2013 - 09:44 AM
Don't overwrite global variables, specifically the keys table that many programs use to look for things like keys.delete.
Moved to Ask a Pro.
Moved to Ask a Pro.
#3
Posted 20 August 2013 - 09:50 AM
keys is already defined, and you're overwriting it with your own keys table. Rename your keys table to something else.
#4
Posted 20 August 2013 - 05:43 PM
Or instead of not calling your variable "keys" just make it a local variable. Then it won't overwrite. I'm surprised how uncommon that ever-important "local" keyword is among the code on these forums.
#5
Posted 22 August 2013 - 10:37 PM
ah, this useless conversation where everybody posts the same way of fixing the overwrite global problem
http://computercraft...i/Category:APIs <- dont overwrite these
this also includes many other built in apis:
http://www.lua.org/manual/5.1/
localization:
bad:
good
this includes do,for,while,function,etc statements
this is how you localize functions:
http://computercraft...i/Category:APIs <- dont overwrite these
this also includes many other built in apis:
http://www.lua.org/manual/5.1/
localization:
bad:
local var=0 for l1=1,100 do local var=1+var end
good
local var=0 for l1=1,100 do var=1+var endlocalized variables only work within their own block and their child blocks
this includes do,for,while,function,etc statements
this is how you localize functions:
local function foo()same dynamics as variables
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











