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

[Solved]Terminal Glasses

Started by Czarified, 07 September 2013 - 06:19 PM
Czarified #1
Posted 07 September 2013 - 08:19 PM
Hey guys. So i was just playing around with the terminal glasses from the OpenPeripherals addon. This program should list all connected users (which it does fine as far as I can tell), and then wrap to the firebox to the left of it. Everything seems to be working, except my IF statement. The "boilerInfo" box color does not update and the "boilerFuel" text does not update. I can't figure out what I'm doing wrong…

Please help. Keep in mind this was just a test program. I'm trying to really grasp what this mod can do and eventually plan on using in to display and control multiple things, but this should just do the two listed above.

here's the pastebin file: http://pastebin.com/BHrM4HfY

and the code:
Spoiler
--Glasses testing program

--Peripheral wrapping:
glass = peripheral.wrap("right")
boiler = peripheral.wrap("left")

--Variable definition
name1 = boiler.getInvName()

while true do


glass.clear()

users = glass.getUsers()
local y = 25
for k, v in pairs(users) do
  glass.addText( y, 50, tostring(v), 0xffffff )
  y = y + 10
end

usertitle = glass.addText( 15, 42, "Connected Users:", 0xffffff )

boilerInfo = glass.addBox( 12, 295, glass.getStringWidth(name1)+7 , 34, 0xffffff, .15)
boilerTitle = glass.addText( 15, 300 , name1..":", 0 )
boilerTemp = glass.addText( 20, 310, "Temp:  "..boiler.getTemperature(), 0 )

sleep(.1)
local refuel = boiler.needsFuel()
sleep(.1)

if refuel == TRUE
then
   boilerFuel = glass.addText( 20, 320, "Needs Fuel!!", 0 )
   boilerInfo.delete()
   boilerInfo = glass.addBox( 12, 295, glass.getStringWidth(name1)+7, 34, 0xfb0000, .15)
   sleep(5)
else
   boilerFuel.setText("Fueled")
   boilerInfo.setColor( 0xffffff )
end

sleep(.5)
end
theoriginalbit #2
Posted 08 September 2013 - 05:18 AM
its true not TRUE … Lua is a case-sensitive language.
Czarified #3
Posted 10 September 2013 - 07:46 PM
Thanks for the reply, originalbit! I modified the program and it still isn't working. the if statement still doesn't seem to be working, as nothing is updating when i put fuel in the boiler, and even when there is no fuel the "Needs Fuell!!" text isn't showing up.

Thank you for all your help!

Code: http://pastebin.com/Ljf7RaXZ

Spoiler

--Glasses testing program

--Peripheral wrapping:
glass = peripheral.wrap("right")
boiler = peripheral.wrap("left")

--Variable definition
name1 = boiler.getInvName()

while true do


glass.clear()

users = glass.getUsers()
local y = 50
for k, v in pairs(users) do
  glass.addText( 25, y, tostring(v), 0xffffff )
  y = y + 10
end

usertitle = glass.addText( 15, 42, "Connected Users:", 0xffffff )

boilerInfo = glass.addBox( 12, 195, glass.getStringWidth(name1)+7 , 34, 0xffffff, .15)
boilerTitle = glass.addText( 15, 200 , name1..":", 0 )
boilerTemp = glass.addText( 20, 210, "Temp:  "..boiler.getTemperature(), 0 )
--boilerFuel = glass.addText( 20, 220, "Needs Fuel!!", 0 )

sleep(.1)
local refuel = boiler.needsFuel()
sleep(.1)

if refuel == true
then
   --boilerFuel.delete()
   --boilerFuel = glass.addText( 20, 220, "Needs Fuel!!", 0 )
   boilerFuel.setText("Needs Fuel!!")
   boilerInfo.delete()
   boilerInfo = glass.addBox( 12, 195, glass.getStringWidth(name1)+7, 34, 0xfb0000, .15)
   sleep(.5)
else
   --boilerFuel.delete()
   --boilerFuel = glass.addText( 20, 220, "Needs Fuel!!", 0 )
   boilerFuel.setText(" ")
   boilerInfo.setColor( 0xffffff )
   sleep(.5)
end

sleep(.5)
end


Noticed the commented line "boilerFuel = glass.addText(……..)" and uncommented. Still no change.
Edited on 10 September 2013 - 05:49 PM
Czarified #4
Posted 10 September 2013 - 10:04 PM
SOLVED!

The openperipherals needsFuel() function returns a string of "true" or "false" , not a boolean. I don't know if this is a bug, but it seems fairly weird to me. checking for a string instead of a boolean fixed the problem and everything is working fine now.