Jump to content




Sorry. Another Un-explained Error


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

#1 KDJSAIUH

  • Members
  • 35 posts

Posted 28 October 2013 - 08:48 AM

Sorry for the third topic today.

I went through my 'defcon' code and it says defcon : 209 attempt to index ? (a function value). I have looked everywhere for this error and how to solve it (i even looked in the lua manual) and i couldn't find this error code anywhere. The line that was in the error was 'rednet.close(n)' this had the function to determine n above it.

Pastebin:

http://pastebin.com/

#2 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 28 October 2013 - 09:12 AM

I'd say that at some point, you've named on of your functions `rednet` and since you don't use local variables you're polluting the environment with a bunch of old variables and functions.

NOTE: After your program has finished anything that isn't localised remains! as such you should always localise your variables when you don't need them to be able to be accessed externally (i.e. an API).

I point you back to this: http://www.computerc...post__p__150830

@Hellkid98
Spoiler

Edited by theoriginalbit, 28 October 2013 - 09:19 AM.


#3 TheOddByte

    Lazy Coder

  • Members
  • 1,607 posts
  • LocationSweden

Posted 28 October 2013 - 09:15 AM

I'm not sure, But I just looked at the top of your code and saw that you set the cursorpos to a new line everytime.
write("Hello World")
write("!")

--[[
Output:
Hello World!
--]]
print("Hello World")
print("!")

--[[
Output:
Hello World
!
--]]
Write keeps writing the text on the same line while print prints on another line each time ;)



And you don't need parantheses around every string
I kinda meant this part
if input == ( "Hello World!" ) then
	print("Hello World!")
end

Can be
if input == "Hello World!" then
	print("Hello World!")
end

You can even do this
print"Hello World"
Even though I suggest you use parantheses when printing/writing
It only works with strings and only when you're passing a single argument as mentioned by TheOriginalBIT above.




And I saw when you are trying to call the function 'passwordInput' in the function 'usernameInput' you are trying call it before it's declared.

Undeclared
hello() -- Undeclared so you can't call it

local function hello()
	print("Hello World!")
end

Declared
local function hello()
	print("Hello World!")
end

hello() -- Now you can call it since it's declared above

- Hellkid98

EDIT: Thanks for pointing that out TOBIT :)

#4 KDJSAIUH

  • Members
  • 35 posts

Posted 28 October 2013 - 09:43 AM

i havent named a function 'rednet'

#5 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 28 October 2013 - 09:49 AM

View Postkaioo1312, on 28 October 2013 - 09:43 AM, said:

i havent named a function 'rednet'
You could have at some point in time, test the script again, but this time make sure to disable startup files and reboot the computer before running the script.

Basically what the attempt to index ? (a x value) means is that you've attempted to access a table, or use an API, when it is actually a different value (specified by x in the brackets).

For example this would say a number value
local foo = 5
print(foo.bar)
This would say a boolean value
local foo = true
print(foo.bar)
and this would work fine
local foo = {["bar"] = "hello"}
print(foo.bar)


#6 KDJSAIUH

  • Members
  • 35 posts

Posted 28 October 2013 - 10:28 AM

I have renamed some functions and rebooted and it works :D
p.s the pastebin code will be deleted as this is a secret :ph34r:

#7 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 28 October 2013 - 10:34 AM

View Postkaioo1312, on 28 October 2013 - 10:28 AM, said:

I have renamed some functions and deleted the line the error was on then it came up again so i added it back. This is still not working :unsure:

View Posttheoriginalbit, on 28 October 2013 - 09:49 AM, said:

You could have at some point in time, test the script again, but this time make sure to disable startup files and reboot the computer before running the script.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users