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

OpenPeripheral is apparently closed.

Started by CantCode420, 09 June 2016 - 09:00 PM
CantCode420 #1
Posted 09 June 2016 - 11:00 PM
So, me again, i'm trying to make an Open Peripheral HUD and I have two questions. 1. This is my code. Why isn't it working?
bridge = peripheral.wrap("left")

bridge.addBox(5,5,70,10,0xFFFFFF,0.5)
Nothing is popping up. No bar, no nothing. fix?
Question 2. Can someone help me make an HUD that does something remotley interesting? I'm a noob and, hence my username, CantCode. Help!
KingofGamesYami #2
Posted 10 June 2016 - 02:34 AM
IIRC, you need to call bridge.sync after making changes for those changes to appear.
CantCode420 #3
Posted 10 June 2016 - 03:34 AM
Thank you so much, but, i'm still a noob. How to I do?
Bomb Bloke #4
Posted 10 June 2016 - 03:49 AM
Like this, presumably:

bridge = peripheral.wrap("left")
bridge.addBox(5,5,70,10,0xFFFFFF,0.5)
bridge.sync()

You may find this script helpful for discovering more about the bridge's functions and their correct usages.
CantCode420 #5
Posted 10 June 2016 - 04:00 AM
So, me, again, (do I post to much?) with yet another problem with OpenPeripheral. My program is here: (Still don't know how to use pastebin so i'm writing the whole thing.)

bridge.peripheral.wrap("left")

bridge.addBox(5,5,70,10,0xFFFFFF,0.5)
bridge.sync()
bridge.addText(6,6,"Loading…",0x123456)
bridge.sync()
bridge.sync()
w = bridge.addBox(5,21,70,10,0x123456,0.5)
w.addText(5,22,"Complete.",0x123456)
w.sync()
I may have messed up typing here, but what it is supposed to do is have 2 boxes one abother the other with the top one saying "Loading…" and the bottom one saying "Complete.". What it's not doing is writing the text. Box, but empty. Help would be great.
Bomb Bloke #6
Posted 10 June 2016 - 04:47 AM
Threads merged - please keep all posts about the one project in the one place.

I would guess you meant to do something like this:

local bridge = peripheral.wrap("left")

local box1 = bridge.addBox(5, 5,70,10,0xFFFFFF,0.5)
box1.addText(6,6,"Loading...",0x123456)

local box2 = bridge.addBox(5,21,70,10,0x123456,0.5)
box2.addText(5,22,"Complete.",0x123456)

bridge.sync()

But it may well be that you just need to do this:

local bridge = peripheral.wrap("left")

bridge.addBox(5, 5,70,10,0xFFFFFF,0.5)
bridge.addText(6,6,"Loading...",0x123456)

bridge.addBox(5,21,70,10,0x123456,0.5)
bridge.addText(5,22,"Complete.",0x123456)

bridge.sync()

What does the documentation for addBox / addText have to say about it?
CantCode420 #7
Posted 10 June 2016 - 04:09 PM
Thank you so much! Worked really well! And thanks for the mini tutorial!. But I've been playing with a clock HUD, here's the code.
glass = peripheral.wrap("left")
function addBox()
time = textutils.formatTime(os.time(),false)
glass.addText(5,2,"TIME:" .. time. 0xFF0000)
end
function start()
while true do
glass.clear()
addBox()
timeDis()
sleep(.1)
end
end
start()
Again, may have typed somethin wrong here, but it pops up with an error:
bios:14: [string "Clock":5: '<name>' expected.
Help?
(sorry for sucking)
Edited on 10 June 2016 - 02:09 PM
Bomb Bloke #8
Posted 10 June 2016 - 04:21 PM
The 5 tells you the line number - you'll see there that you've placed a period where you meant to place a comma.
CantCode420 #9
Posted 10 June 2016 - 04:36 PM
Where? I can't seem to see it.

Wait, now it's telling me on line 12.
Now its working, but not changing and just sitting there. Can't get rid of it.
Edited on 10 June 2016 - 02:44 PM
Dog #10
Posted 10 June 2016 - 04:37 PM
By my count, line 5 is an end. This sometimes happens with error messages. In this case you want to look at the line immediately preceding line 5 (glass.addText…) - there is a dot after time when it should be a comma.
Edited on 10 June 2016 - 02:38 PM
CantCode420 #11
Posted 10 June 2016 - 04:38 PM
Found the period by the way.
CantCode420 #12
Posted 10 June 2016 - 09:26 PM
So, I am trying to add an icon, and what is a meta?
also, timeDis is apparently not working.
also when I edit a comment I often mess up and dupe things.
Edited on 10 June 2016 - 07:29 PM