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

How to append to a variable containing a string?

Started by Fashter, 27 October 2012 - 11:19 PM
Fashter #1
Posted 28 October 2012 - 01:19 AM
You know how you can append to a file using fs? I was wondering if you can do the same with variables containing strings.

Example:
var = "a"
I want to add-on to it so I can make a word like "add"
Could i do something like var = var"dd"?
KillaVanilla #2
Posted 28 October 2012 - 01:21 AM
Yes, you can, by using the concentation operator, or ".." (2 dots/periods)


myVar = "a"
myVar = myVar.."dd"
print(myVar)

This code should print "add".
Luanub #3
Posted 28 October 2012 - 01:21 AM
concatenate the string so

var = "a"

var = var.."dd"
Fashter #4
Posted 28 October 2012 - 01:24 AM
Thanks! While you're here, the rs.setBundledOutput doesn't seem to be working.

Example:
rs.getBundledInput("right") returns 65
I want to set it to 0 (or any number) so I do rs.setBundledOutput("right",0) just like the wiki entry says, but it doesn't do anything. I do rs.getBundledInput("right") after doing that command, and it's still set to 65…
Luanub #5
Posted 28 October 2012 - 01:29 AM
Is there something else holding the redstone signals on? By doing rs.setBundledOutput("right",0) everything that the computer is sending is turned off.

Since you're using getBundledInput() you're testing what is coming into the computer, Verify that the computer is not sending the signal by testing the output. rs.getBundledOutput("right")
Fashter #6
Posted 28 October 2012 - 01:31 AM
Thanks so much, guys!