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

How To Update One String On Terminal Glasses Without Clearing Each Time?

Started by CreeperGoBoom, 22 October 2013 - 03:12 AM
CreeperGoBoom #1
Posted 22 October 2013 - 05:12 AM
ive seen someone write that you can use a "changer" to change the string instead of clearing the glasses, what is this so called "changer"?

if i just simply change the string thats on the glasses without clearing, say from "Sparta" to "Imagine" i get something that looks like "$#a&&ne"

so how exactly do i change the string without clearing? i cant find any lines i can use like glasses.changeText
theoriginalbit #2
Posted 22 October 2013 - 06:07 AM
each time you call one of the base methods on a terminal glasses bridge, such as addBox, addGradientBox, addText, (latest 1.6.4 version) addLiquid, (latest 1.6.4 version) addIcon, they return a table of functions that you can use to directly modify the element. You can see a list of all of these functions by doing the following

local bridge = peripheral.wrap("left")
local mainHeading = bridge.addText(10, 10, "<<default text>>", 0xFF0000)
for k,v in pairs(mainHeading) do
  print(k, ' = ', v)
end
If you run the above code you will notice that there'll be a function listed there called setText, this is what you use to change the text of a text element.

Just in case this simple explanation isn't clear enough, example:

local textBox = peripheral.call("left", "addText", 10, 10, "Some text", 0xFF0000)
sleep(10)
textBox.setText(":0 the text has changed!")
CreeperGoBoom #3
Posted 25 October 2013 - 11:12 PM
exactly what i was after, thankyou :D/>