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

Openperiph update issue

Started by apoc123, 23 February 2014 - 01:11 PM
apoc123 #1
Posted 23 February 2014 - 02:11 PM
Ive updated to the most recent Openperipherals version the methods changed, i tried to edit but im still getting an error and my bars are stacking gradientboxes since setZindex no longer is there.
im Using openp core 0.3.1, openlib 0.2, openblocks 1.2.5. this program worked perfect for openp build# 112

The bars are stacking overtop each other instead of adding a new bar lower down


screenshot of issue

http://tinypic.com/r/2w6i8t1/8

Spoilerfunction disBridgeInfo(array1,posStart,BoxName,colBar,addtext)
offset2 = 18
for i=1, #array1 do
for key,value in pairs(array1) do
value["label"] = bridge.addText(5,5+offset2 + posStart,array1[1]["name"],0x33FF33)
value["label"].setScale(0.5)
value["proc"] = bridge.addText(45,5+offset2 + posStart,"FILL: 0.0%",0xC5360F)
value["proc"].setScale(0.5)
if addtext then
value["textadd"] = bridge.addText(10,offset2 + posStart," ",0x33FF33)
value["textadd"].setScale(0.5)
end
value["heatTitle"] = bridge.addText(5,10+offset2 + posStart,"0",0x66FFFF)
value["heatTitle"].setScale(0.8)
value["progressbar"] = bridge.addGradientBox(10,10+offset2 + posStart,100,7,0x66ccff,7,0x000033,0.7,1)
value["progressbar"].setZ(10)
–value["progressbar"].setGradient(1)
–value["progressbar"].setColor2(0x66ccff)
value["progressbarmarker"] = bridge.addGradientBox(10,11+offset2 + posStart,1,7,0xFFFFFF,1,colBar,0.7,1)
value["progressbarmarker"].setZ(11)
–value["progressbarmarker"].setGradient(1)–these need rewritten for new openp
–value["progressbarmarker"].setColor2(0xFFFFFF)
value["capTitle"] = bridge.addText(26,11+offset2 + posStart," 0/0",0x33FF33)
value["capTitle"].setScale(0.5)
offset2 = offset2 + 18
end
end
boxName = bridge.addBox(2, 2+posStart, 111, offset2, 0x262626, 0.2)
boxName2 = bridge.addText(5,5+posStart,BoxName,0x66CCFF)
boxName2.setScale(0.7)
end
function ClearBridge(array1)
for i=1, #array1 do
for key,value in pairs(array1) do
value["label"].delete()
value["proc"].delete()
value["heatTitle"].delete()
value["progressbar"].delete()
value["progressbarmarker"].delete()
value["capTitle"].delete()
end
end
boxName.delete()
boxName2.delete()
end
function upBridgeDis(arrayNames,arrayNumber,capa1,stor1,currBOX,colBr,addtext1,newtext)
for i=#arrayNames,1,-1 do
for j=#arrayNames,1,-1 do
storage1 = arrayNames[j]
if storage1["id"] == arrayNumber then
curStored = widthBR / capa1 * stor1
– storage1["progressbarmarker"].setColor(colBr) <————- This is throwing an error on return works if texted out but bars are stacking
storage1["progressbarmarker"].setWidth(curStored)
if addtext1 then
storage1["textadd"].setText(newtext)
end
curStoredE = round1(curStored)
if curStoredE <= 29 then
storage1["proc"].setColor(0xFF0000)
storage1["proc"].setText("FILL: "..curStoredE.."%")
elseif curStoredE >= 30 and curStoredE <= 79 then
storage1["proc"].setColor(0xFFFF00)
storage1["proc"].setText("FILL: "..curStoredE.."%")
elseif curStoredE >= 80 and curStoredE <= 99 then
storage1["proc"].setColor(0x009900)
storage1["proc"].setText("FILL: "..curStoredE.."%")
elseif curStoredE >= 100 then
storage1["proc"].setColor(0x66CCFF)
storage1["proc"].setText("FULL")
end
disSmalCAP= enu.dot(stor1).."/"..enu.dot(capa1)
storage1["capTitle"].setX(writeCenter(disSmalCAP,100)+11)
storage1["capTitle"].setText(disSmalCAP)
storage1["heatTitle"].setText(tostring(currBOX))
end
end
end
end
Edited on 23 February 2014 - 03:10 PM
CometWolf #2
Posted 23 February 2014 - 02:32 PM
Since these functions are stored in a table, you can just loop through it to get the names.

for k,v in pairs(storage1["progressbarmarker"]) do
  print(k)
end
apoc123 #3
Posted 23 February 2014 - 03:21 PM
Since these functions are stored in a table, you can just loop through it to get the names.
for k,v in pairs(storage1["progressbarmarker"]) do
print(k)
end

read entire post i can get methods fine thats not the entire issue im knew to this im trying to update the code the bars are stacking ive included a screenshot
CometWolf #4
Posted 23 February 2014 - 03:38 PM
If you'd bothered to to what i told you, you'd know it's been changed from setZIndex to setZ…
Edited on 23 February 2014 - 03:21 PM
apoc123 #5
Posted 23 February 2014 - 04:15 PM
lol i did but i am coding something wrong <—– lua noob i made changes to the code and the bars are still stacking i appoligize i did do what you suggested and looked up methods though but i just dont know enough to fix it thats what im asking. everything works in the entire program all bars show info update but they are stacked instead of when adding a bar they create a new one below for example adding a tank of oil stacks the new bar on the old one and becomes unreadable as in the ss i do not know were to begin to fix it because of the changes in the methods in openp im sure its 1 or 2 lines of code but i have no idea

replacing setZindex() with setZ() did not fix it.
Edited on 23 February 2014 - 03:17 PM
CometWolf #6
Posted 23 February 2014 - 04:24 PM
Not entirely sure what you want it to do. Do you want it to render the bars somewhere else? Im assuming you made the program, and as such would know that you'd have to specifically tell it where to render the bars, regardless of what openP version you're running.
apoc123 #7
Posted 23 February 2014 - 04:33 PM
well simple lol "supposed to be" i have a program that monitors machines,tanks, powerstorage and a reactor i just tooks the tables and made them into gradient bars like how much power you have and they are hot pluggable if you connect a modem to a new tank or machine or battery like an mfsu it shows on a bar.

when adding the bars like in the screen shot the setZindex placed the new bar alittle lower on the screen but instead they just stack on top of each other and overlap so you cant read them the screen shot above clearly shows the issue i just must have not fixed it correctly it display power and liquids level and percent filled they just overlap i dont know how to change the code to make the bars start at pos1 then the next bar 1 down



if you look at the screen shot there are catagories like liquids and there should be a bar for every liquid ex lava, water , oil there are multiple bars there just stacked and overlapping

they need to list like
lava %—————————
water%————————–
oil%—————————–


but all 3 are on one line

if you can look at the screen shot click on it it will zoom in and you can see the bars are overlapping there should be more well there are but i dont know how to explain it any clearer


http://tinypic.com/r/2w6i8t1/8
Edited on 23 February 2014 - 03:41 PM
CometWolf #8
Posted 23 February 2014 - 04:48 PM
That is not what Z index is. The Z index is like a layer, it specifies which element to display on top, incase any of them overlap. From what i can tell, these are all set to render at the same spot. But then again, don't know the structure of your table, so i can't be sure.
Edited on 23 February 2014 - 03:50 PM
apoc123 #9
Posted 23 February 2014 - 10:06 PM
Now were getting somewhere lol finnally thank you for explaining what Z is. Yes thats exactly the issue the bars as shown in screenshot are RENDERING in the same spot. I wish t fiX this pls
The program is not all mine i have edited an old program incorrectly to suit my needs i need to finish fixing it so the bars RENDER in the proper pos. i being a noob dont quite understand how to acheive this. I can pm you the entire program i dont want to post it because its not all mine i thought i included the relavent code pertaining to openperipherals glasses but if you need more deatils and all the code to explain how to fix it then i can provide otherwise i will edit out the openp and keep all of the working code to monitor all the stuff i need openp documentation is seriously lacking unless your all ready a pro which i am not. Ive spent 2 days( many hrs)trying to search and learn from information sources scattered outdated incomplete. I can list the table from the instructions you gave me what do you need to help resolve this. I want the bars to render seperate not in the same space how do i fix that specifically were can i find the information to edit the code i dont care how far apart or what colors just so they dont render on the same line
CometWolf #10
Posted 24 February 2014 - 02:23 AM
Just send me the entire code and i'll take a look at it later today. Easier that way, since i need to see what's in the table, and how the function is used.
apoc123 #11
Posted 05 March 2014 - 03:20 AM
Well i don't know if you were assigned to ask a pro or just take it upon yourself to Answer these post but you sir are not a pro, or a professional or patient. You did nothing to help, your fix of course did not work. You did nothing to help it took several post (wasted time) to as a pro get you to see an obvious and easy issue which no thanks to you as a PRO was repaired. Meh i could say more but why… Oh and the icing on the jerk cake is labeling the pastebin that you created with the so called repairs "SHIT" thanks.
theoriginalbit #12
Posted 05 March 2014 - 04:06 AM
There was nothing wrong with CometWolf's replies; it is something any 'pro' would have done. If you expect your problem to be resolved in 1 or 2 replies then you have too higher expectations for this forum it seems, just take a look at the threads some of them are 10's of posts long before they're solved.

As for getting bars to render in different locations. If you run the code that CometWolf suggested you'd notice that there are several 'setters' for each object you create. The ones you want to take particular note of are setX, setY, and setZ. As CometWolf has already explained Z is the 'layer' it sits on, so the higher the Z the 'closer' it is to the front of the screen. X is the horizontal space across the screen and Y is the vertical space where (0,0) (x,y) is the top left of the screen.

From a quick scan of your code the reason you're getting the stacking problem is that you're not setting different Y positions for them, you're doing different start positions, but not actually moving them within their groups.

Also are you clearing the terminal glasses when your program first starts? I didn't notice it in there, have you not included your entire program? if so I definitely suggest next time you upload your entire program to http://pastebin.com or similar, especially when they are a longer program; we may be 'pro's but it's still difficult to read code when it's like how you posted it, and having all the code means we can notice mistakes elsewhere, sometimes problems aren't where you think they are.

Lastly a pro tip for the future, use [code][/code] tags around your code to get the nice syntax highlighting and indentation on the forums.
CometWolf #13
Posted 05 March 2014 - 05:22 AM
Im not specifically assigned to Ask a pro, so sorry i took the time to help… Im not exactly too great at working with large amounts of code by an unknown person, to be honest, i wasn't expecting 600+ lines. This code is obviously not yours. Like i already told you, i wasn't going to setup all those machines to test this, so i couldn't really get much further. For anyone interested, here's what i managed to wrangle out of the code.
I can't really get much further, cause i can't be bothered to set up all those machines, but give it a shot
http://pastebin.com/vgfvfx3z
I'd suggest asking the guy who made this if it dosen't work at this point, cause this is clearly not meant to be adaptable.
The pastebin title was just random, i didn't think much of it.
Edited on 05 March 2014 - 06:41 AM