Jump to content




[Question] This code is melting my brain!


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

#1 Matrixmage

  • Members
  • 116 posts
  • LocationAt my Computer coding for the Computer in my Computer

Posted 09 September 2012 - 12:18 AM

I'm trying to get this code working but I can't seem to fix it, its melting my brain!

Spoiler

The printing for testing purposes only.

#2 Kingdaro

    The Doctor

  • Members
  • 1,636 posts
  • Location'MURICA

Posted 09 September 2012 - 12:23 AM

That's because your white and pink variables are both local to your functions and can't be access outside of them. That and you have to call them (by doing whitetest() and pinktest() ) before even being able to access the variables.

Try removing the word "local" from them, and then calling the functions before testing the variables.

#3 Matrixmage

  • Members
  • 116 posts
  • LocationAt my Computer coding for the Computer in my Computer

Posted 09 September 2012 - 12:31 AM

I expected it to be something this trivial... well thanks for the help! :D/>

#4 ltstingray

  • New Members
  • 12 posts

Posted 09 September 2012 - 01:20 AM

Or if you wanted to keep them localized (for some reason)
function whitetest()
local a = redstone.getBundledInput( "back" )
local white = colors.test( a, colors.white )
return white
end

function pinktest()
local b = redstone.getBundledInput( "back" )
local pink = colors.test( b, colors.pink )
return pink
end

whitetest()
if white == true then
print("white on")
elseif white == false then
print("white off")
else
print("white failed")
end


pinktest()
if pink == true then
print("pink on")
elseif pink == false then
print("pink off")
else
print("pink failed")
end






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users