Jump to content




Getting Multiple RS inputs to store


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

#1 Hayden_Almeida

  • Members
  • 49 posts

Posted 16 May 2015 - 01: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 by Hayden_Almeida, 16 May 2015 - 02:19 AM.


#2 HPWebcamAble

  • Members
  • 933 posts
  • LocationWeb Development

Posted 16 May 2015 - 02: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 by HPWebcamAble, 16 May 2015 - 02:15 AM.


#3 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 16 May 2015 - 02: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.

#4 Hayden_Almeida

  • Members
  • 49 posts

Posted 16 May 2015 - 02:38 AM

View PostKingofGamesYami, on 16 May 2015 - 02:34 AM, said:

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

#5 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 16 May 2015 - 02:48 AM

I suspect that you'd be better off ditching the var1, var2, etc scheme and using a table as an array instead.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users