Jump to content




Trouble With Buttons


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

#1 Alexander0507

  • Members
  • 42 posts

Posted 12 August 2013 - 04:52 PM

I'm using Direwolf20's ButtonAPI : http://pastebin.com/S8x0K3ui
And his demo-programm: http://pastebin.com/xVmKfn2Y


I think in the newer versions of CC some important thing changed

can anyone help me ?

#2 jay5476

  • Members
  • 289 posts

Posted 12 August 2013 - 04:55 PM

an error or wat its not doing plz

#3 MR_nesquick

  • Members
  • 106 posts
  • LocationNorway

Posted 12 August 2013 - 04:59 PM

do you have the monitor on top of the computer?

#4 Alexander0507

  • Members
  • 42 posts

Posted 12 August 2013 - 05:07 PM

No i have it behind the computer but i changed it in the program.

I'm getting the error: button:2 attempt to index ? (a nil value)

I also wrote my own program with the buttonAPI: http://pastebin.com/cxdKeRdn

there i get : bios:337: [String"fabrik"]:5: '<name>' expected

#5 MR_nesquick

  • Members
  • 106 posts
  • LocationNorway

Posted 12 August 2013 - 05:09 PM

did you change it in the api??

EDIT:
and in your own code you got the error because it's function filltable() not function.filltable()

AND you need to put your getclick() function in a loop

#6 Alexander0507

  • Members
  • 42 posts

Posted 12 August 2013 - 05:12 PM

ohh no i changed it in my program but not in the API.
I changed it now and it works thanks :D
blame me that i didn't see it ^^
My program(Fabrik) doesn't work also with the change :(

#7 Alexander0507

  • Members
  • 42 posts

Posted 12 August 2013 - 06:09 PM

Ok this problem is solved but i have one more question.

Could i code it so that if i toggle the button to on the redstone output is true und when the button is off the output is false ?

#8 Engineer

  • Members
  • 1,378 posts
  • LocationThe Netherlands

Posted 12 August 2013 - 07:02 PM

Sure! I do not give the place where to put it in your code, because I simply didnt look at it.
So, lets take the redstone wiki page: Click for the link!

You see overthere the redstone.getInput( side ) function. The explanation is overthere for it. Now, I want you to know this:
local bool = true
local newbool = not bool
-- not true -> false
bool = not newbool
-- not false -> true

Now we can do this:
redstone.setOutput( side, not rs.getInput( side ) )


#9 Alexander0507

  • Members
  • 42 posts

Posted 13 August 2013 - 03:33 AM

How can i change the redstone output of bundled cables off ?(i want to deactivate 1 color not all)

#10 MR_nesquick

  • Members
  • 106 posts
  • LocationNorway

Posted 13 August 2013 - 10:45 AM

first you need to know how the bundled cable works

1 = white
2 = orange
3 = white and orange
4 = magenta
5 = white and magenta
6 = orange and magenta
7 = white, orange and magenta
...

if you want to turn OFF one color you need to subtract the color number.
if you want to turn ON one color you need to add the color number

example
BundledOn = 3                             -- BundledOn = 3 = white and orange
rs.setBundledOutput("side",BundledOn)

--if you want to turn of white do

BundledOn = BundledOn - 1		  --BundledOn = 2 = orange
rs.setBundledOutput("side",BundledOn)  

you can see the color Api here

#11 albrat

  • Members
  • 162 posts
  • LocationA Chair

Posted 13 August 2013 - 11:37 AM

a simple way to do this would be using a couple of functions.

eg...
function colRemove(col)
	local works = colors.test(redstone.getBundledOutput("front"),col)
	if works then
		redstone.setBundledOutput("front", (redstone.getBundledOutput("front")-col))
		return true
	else
		print("Color already de-activated")
		return false
	end
end

function colAdd(col)
	local works = colors.test ( redstone.getBundledOutput( "front" ), col )
	if not works then
		redstone.setBundledOutput("front", ( redstone.getBundledOutput ( "front" ) + col ) )
		return true
	else
		print("Color Already Active")
		return false
	end
end

-- Usage

colAdd(colors.white)
colAdd(colors.black)
colAdd(colors.magenta)

colRemove(colors.black)
colRemove(colors.white)
colRemove(colors.magenta)

Then you just have to call the add or remove... Also it has a catchment built in so the same color can not be activated twice, or deactivated twice. (this can lead to strange color combinations if you do not catch this occurance)

I decided to return a true and false for if the action succeeded. ( to call the function with success capture use "varible = colAdd(colors. {your color} )" and "varible = colRemove(colors. {your color} )" and the varible will contain "true" or "false")

* I run MineCraft v 1.4.7 and ComputerCraft V 1.481 -- tested on here and working





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users