42 posts
Posted 12 August 2013 - 05:52 PM
I'm using Direwolf20's ButtonAPI : http://pastebin.com/S8x0K3uiAnd his demo-programm: http://pastebin.com/xVmKfn2YI think in the newer versions of CC some important thing changedcan anyone help me ?
331 posts
Posted 12 August 2013 - 05:55 PM
an error or wat its not doing plz
101 posts
Location
Norway
Posted 12 August 2013 - 05:59 PM
do you have the monitor on top of the computer?
42 posts
Posted 12 August 2013 - 06: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/cxdKeRdnthere i get : bios:337: [String"fabrik"]:5: '<name>' expected
101 posts
Location
Norway
Posted 12 August 2013 - 06: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
42 posts
Posted 12 August 2013 - 06: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 :(/>
42 posts
Posted 12 August 2013 - 07: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 ?
1522 posts
Location
The Netherlands
Posted 12 August 2013 - 08: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 ) )
42 posts
Posted 13 August 2013 - 04:33 AM
How can i change the redstone output of bundled cables off ?(i want to deactivate 1 color not all)
101 posts
Location
Norway
Posted 13 August 2013 - 11: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
159 posts
Location
A Chair
Posted 13 August 2013 - 12:37 PM
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