Jump to content




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


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

#1 CreeperGoBoom

  • Members
  • 91 posts

Posted 22 October 2013 - 04: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

#2 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 22 October 2013 - 05: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!")


#3 CreeperGoBoom

  • Members
  • 91 posts

Posted 25 October 2013 - 10:12 PM

exactly what i was after, thankyou :D





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users