Jump to content




Attempt to index ? (a function value)


2 replies to this topic

#1 yosomith

  • Members
  • 2 posts

Posted 11 February 2013 - 01:29 PM

Alright, so I was trying to get fancy with a line of code that didn't need to get fancy. My Coding is short and the function is not needed but I would like to know why it doesn't work.

Here is the code:

local side = back

local function Door()
	redstone.setOutput("side", true)
	sleep(0.5)
	redstone.setOutput("side", false)
  end

Door()
sleep(10)
Door()

I found the issue, I originally tried naming the function wrong, which gave me the error and it messed up the computer. Just picked it up and put it back down (with label cleared) and it kinda works, different error but I can work around that.

#2 Kingdaro

    The Doctor

  • Members
  • 1,636 posts
  • Location'MURICA

Posted 11 February 2013 - 01:48 PM

Quotes are in the wrong places, buddy. Remove them around "side" and put them around back at the top.

local side = "back"

local function Door()
    redstone.setOutput(side, true)
    sleep(0.5)
    redstone.setOutput(side, false)
  end

Door()
sleep(10)
Door()


#3 RoD

  • Members
  • 313 posts

Posted 21 June 2013 - 11:22 AM

If you want to use a string you need to tell the code that the string is back (For example)
local side = back
is different from
local side = "back"
and when you want to use the string you need to do the opposite
redstone.setOutput ("side", false)
need to change to
redstone.setOutput (side, false)






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users