This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Hayden_Almeida's profile picture

Getting Multiple RS inputs to store

Started by Hayden_Almeida, 16 May 2015 - 12:12 AM
Hayden_Almeida #1
Posted 16 May 2015 - 02:12 AM
Hello guys, i am trying to make a REAL NUMPAD (like in keyboard) with Buttons in a Wall…

So i have a wall, where i have:

7 8 9
4 5 6
1 2 3


Where these numbers are Buttons, BUT, behind each number, i have one cable with one color, following:
Numer 1: color white;
Number 2: color orange;
etc…
Finnaly number 9 have: color light Grey;

Then i have those connected to a BUNDLED CABLE , and its connect to a Advanced Computer;

1º QUESTION: (I think i get it in my way :)/> SOLVED) I want to get 3 values: if the player press the first, it will store, then jump to second, and third. In the end, it will print the values in sequence the player have pressed.

2º QUESTION: i have 3 variables with numbers;

var1 = 1
var2 = 1
var3 = 1
then i want to put it together, resulting: var4 = 111
Edited on 16 May 2015 - 01:19 AM
HPWebcamAble #2
Posted 16 May 2015 - 03:11 AM
The main API you will be using here is the Redstone API, specifically 'rs.getBundledInput()'


Here is some sudo code to give you an idea of where to start:

--# Define variables (local ones of course)

--# Wait for redstone events with os.pullEvent() (See link below this code block)

--# This code executes when a redstone event was triggered so...
--# Get the current state of the bundled cable. The color that is on is the button that was hit
--# Set the first variable to the color

--# Wait for a redstone event again
--# Get the state again, and set the next variable as the color

--# And again
--# You get it right?

os.pullEvent() on the ComputerCraft Wiki:
http://computercraft...ki/Os.pullEvent
Edited on 16 May 2015 - 01:15 AM
KingofGamesYami #3
Posted 16 May 2015 - 03:34 AM
You can concat your variables like this:


var4 = var1 .. var2 .. var3

var4 will be a string, however you can easily use tonumber to convert it into a number for comparison.
Hayden_Almeida #4
Posted 16 May 2015 - 03:38 AM
You can concat your variables like this:


var4 = var1 .. var2 .. var3

var4 will be a string, however you can easily use tonumber to convert it into a number for comparison.
THANKS MAN :D/>
Bomb Bloke #5
Posted 16 May 2015 - 03:48 AM
I suspect that you'd be better off ditching the var1, var2, etc scheme and using a table as an array instead.