115 posts
Posted 09 May 2013 - 02: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 :)/>
7508 posts
Location
Australia
Posted 09 May 2013 - 02:26 AM
What version of ComputerCraft are you running?
671 posts
Location
That place over there. Y'know. The one where I am.
Posted 09 May 2013 - 02: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
115 posts
Posted 09 May 2013 - 02: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
7508 posts
Location
Australia
Posted 09 May 2013 - 02:32 AM
I'll update the wiki.
EDIT: Done.
Edited on 09 May 2013 - 12:36 AM
671 posts
Location
That place over there. Y'know. The one where I am.
Posted 09 May 2013 - 02:36 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
NP, bro. Any time.
115 posts
Posted 09 May 2013 - 02: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
7508 posts
Location
Australia
Posted 09 May 2013 - 02: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 on 09 May 2013 - 12:42 AM
115 posts
Posted 09 May 2013 - 02:40 AM
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
671 posts
Location
That place over there. Y'know. The one where I am.
Posted 09 May 2013 - 02:43 AM
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 :(/>
115 posts
Posted 09 May 2013 - 02: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
7508 posts
Location
Australia
Posted 09 May 2013 - 02:47 AM
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
while this noob learns lua
Check out the PIL
http://www.lua.org/pil/1.htmlAnd obviously the ComputerCraft wiki
http://computercraft.info/wiki/index.php?title=Category:APIsThe 'Tutorials' section of these forums are quite handy sometimes.
And Google is your friend!