Jump to content




Attempt to call nil


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

#1 Inumel

  • Members
  • 120 posts

Posted 09 May 2013 - 01:24 AM

Right! I am brand new to lua coding, I understand very little.

I am having an issue with a bit of code I was messing around with
x = rs.getAnalogInput("left")

I have written it exactly as the wiki wrote it, but I am getting the error "Attempt to call nil"

Is it because I am assigning it to a variable? Or am I doing something else wrong I don't understand..

Please be patient, I am new to this :)

#2 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 09 May 2013 - 01:26 AM

What version of ComputerCraft are you running?

#3 Shnupbups

  • Members
  • 596 posts
  • LocationThat place over there. Y'know. The one where I am.

Posted 09 May 2013 - 01:27 AM

Which CC/MC version are you using? For this function you must use CC 1.51 or above and Minecraft 1.5 or above.
EDIT: Half ninja'd

#4 Inumel

  • Members
  • 120 posts

Posted 09 May 2013 - 01:28 AM

Ahh I should have posted that in my OP, Apologies.. I am still using FTB ultimate on 1.4.7! Thanks for the help, guys

#5 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 09 May 2013 - 01:32 AM

I'll update the wiki.

EDIT: Done.

Edited by theoriginalbit, 09 May 2013 - 01:36 AM.


#6 Shnupbups

  • Members
  • 596 posts
  • LocationThat place over there. Y'know. The one where I am.

Posted 09 May 2013 - 01:36 AM

View PostElgriton, on 09 May 2013 - 01:28 AM, said:

Ahh I should have posted that in my OP, Apologies.. I am still using FTB ultimate on 1.4.7! Thanks for the help, guys
NP, bro. Any time.

#7 Inumel

  • Members
  • 120 posts

Posted 09 May 2013 - 01:37 AM

While this thread is still slightly relevant, is there a way to detect the signal of the redstone signal without using that code? I had some neat ideas to use with this

#8 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 09 May 2013 - 01:38 AM

rs.getInput( [side] )
where [side] is the side that the redstone is on.

EDIT: Here are some usage examples:
One off check to create a branch in code
if rs.getInput('left') then
  print('There is a redstone signal on the left')
else
  print('There is no redstone signal on the left')
end
Remember the state, but also print some stuff
local leftState = rs.getInput('left')
print('The redstone input on the left is '..(leftState and 'on.' or 'off.'))
Loop through all the sides and print the state
for _,side in pairs(rs.getSides()) do
  print('The redstone input on the '..side..' is '..(rs.getInput(side) and 'on.' or 'off.'))
end

Edited by theoriginalbit, 09 May 2013 - 01:42 AM.


#9 Inumel

  • Members
  • 120 posts

Posted 09 May 2013 - 01:40 AM

View Posttheoriginalbit, on 09 May 2013 - 01:38 AM, said:

rs.getInput( [side] )
where [side] is the side that the redstone is on.

Sorry I should say, read the strength of the signal! I know this code makes it possible, I am just wondering if it is possible without it. hmm

#10 Shnupbups

  • Members
  • 596 posts
  • LocationThat place over there. Y'know. The one where I am.

Posted 09 May 2013 - 01:43 AM

View PostElgriton, on 09 May 2013 - 01:40 AM, said:

Sorry I should say, read the strength of the signal! I know this code makes it possible, I am just wondering if it is possible without it. hmm
Nope, sorry but this is not possible using that version of CC :(

#11 Inumel

  • Members
  • 120 posts

Posted 09 May 2013 - 01:44 AM

No worries! Thanks for the help! I'm sure you will see me around more while this noob learns lua ;) just hope ya put up with me

#12 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 09 May 2013 - 01:47 AM

View PostElgriton, on 09 May 2013 - 01:40 AM, said:

Sorry I should say, read the strength of the signal! I know this code makes it possible, I am just wondering if it is possible without it. hmm
The "redstone update" came out in Minecraft 1.5, so there was no way to get strength in 1.4.7


View PostElgriton, on 09 May 2013 - 01:44 AM, said:

while this noob learns lua
Check out the PIL http://www.lua.org/pil/1.html
And obviously the ComputerCraft wiki http://computercraft...e=Category:APIs
The 'Tutorials' section of these forums are quite handy sometimes.
And Google is your friend!





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users